cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Helper IV
Helper IV

Put a - before the last character

Hi, I need to put a - before the last character. The field will receive 1234567890 and I need to put 123456789-0
How can I do this?
Thank you very much.

1 ACCEPTED SOLUTION

Accepted Solutions

@elaaadani ,

On the OnChange of the Text Box

UpdateContext(
   {
      varDash: 
      With(
         {wChar: Self.Text},
         Left(
            wChar,
            Len(wChar) - 2
         ) & "-" & 
         Right(
            wChar,
            1
         )
      )
   }
);
Reset(Self)

On the Default of the Text Box

If(
   !IsBlank(varDash),
   varDash,
   Parent.Default
)

On the OnVisible of the screen and at with any Save code (if you do not leave the screen)

UpdateContext({varDash:false})

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

 

View solution in original post

14 REPLIES 14
Super User III
Super User III

Hi @elaaadani ,

Try this

With(
   {wChar:YourTextControlName.Text},
   Left(
      wChar,
      Len(wChar)-2
   ) & "-" & 
   Right(wChar,1)
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

It does not work. It says it has a number of invalid arguments. Besides an unexpected character in this line

{wChar:YourTextControlName.Text},

 I put this

 

With(
   {wChar:RutOnombre.Text},
   Left(
      wChar,
      Len(wChar)-2
   ) & "-" & 
   Right(wChar,1)
)

 

 

Hi @elaaadani ,

It does work as below using a text box named exactly as your example

AddDash.png

 

InsertDash.gif

What are you doing different?

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

 

 

Helper IV
Helper IV

@elaaadani ,

Are you trying to do it to the same text box as the input? That is a bit more complex. Please confirm That code was designed to write to the source and then display it.

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

@WarrenBelz Yes, it's the same text box as the input

@elaaadani ,

On the OnChange of the Text Box

UpdateContext(
   {
      varDash: 
      With(
         {wChar: Self.Text},
         Left(
            wChar,
            Len(wChar) - 2
         ) & "-" & 
         Right(
            wChar,
            1
         )
      )
   }
);
Reset(Self)

On the Default of the Text Box

If(
   !IsBlank(varDash),
   varDash,
   Parent.Default
)

On the OnVisible of the screen and at with any Save code (if you do not leave the screen)

UpdateContext({varDash:false})

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

 

View solution in original post

Helper IV
Helper IV

Hi @WarrenBelz 

It doesn't work for me. I always get this same error !

Number of invalid arguments. 1 was received, but 2 were expected

elaaadani_0-1611159995854.png

 

@elaaadani ,

Here is the exact code I used and it worked exactly as expected in testing

AddDash2.png

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Helpful resources

Announcements
New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

Top Solution Authors
Top Kudoed Authors
Users online (16,511)