cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
elaaadani
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
WarrenBelz
Super User
Super User

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.

 

 

elaaadani
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

elaaadani
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
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (2,791)