Extract substring from end of string in Power automate

AGD 21 Reputation points
2020-09-15T22:06:30.987+00:00

I am trying to write a workflow with Power automate (previously written in SharePoint 2010 workflow). How can I achieve the function "Extract substring from end of string" like the below function:
24963-capture.png

I am trying to add zeroes before the ID to create a 4 digit number. Using that 4 digit number, I am trying to set another field Service Request Number and append with the current year.
Example:

if ID=9
Service Number = 2020-0009

if ID=18
Service Number = 2020-0018

If ID=100
Service Number = 2020-0100

How can I achieve this using Power automate?

Microsoft 365 and Office SharePoint Server For business
Microsoft 365 and Office SharePoint For business Windows
Microsoft 365 and Office SharePoint Server Development
{count} votes

Accepted answer
  1. JoyZ 18,111 Reputation points
    2020-09-16T04:31:10.96+00:00

    Hi @AGD ,

    We can use the Substring, Sub and Length functions to extract the last n characters as needed in flow.

    Try as follows:

    24977-image.png

    substring(variables('TemDocId'), sub(length(variables('TemDocId')),4),4)  
    

    Result:

    25078-image.png


    If an Answer is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Anonymous
    2020-09-15T22:34:11.01+00:00

    Power automate is not currently supported here on QnA. They're actively answering questions in dedicated forums here.
    https://powerusers.microsoft.com/t5/Microsoft-Power-Automate/ct-p/MPACommunity

    --please don't forget to Accept as answer if the reply is helpful--

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.