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

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 V
Helper V

@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.

 

elaaadani
Helper V
Helper V

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
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on June 15, 2022 at 8am PDT.

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Top Kudoed Authors
Users online (4,338)