Skip to main content

Notifications

Power Automate - General Discussion
Answered

Need help writing an expression to add to and format a number.

(0) ShareShare
ReportReport
Posted on by 23

Hello,

I have a flow that autogenerates ticket numbers in the format we want. An example of the format is 22322. I was able to change the format to start with 23 for the new year but I don't seem to be able to figure out how to make my number start at 1 for the new year (23001). I would like to add -314 to the number but it gives me an error when I try to use the add function. I will need to manipulate the format of the 'ID' and add a number to it every January 1st in order to make the LIS Ticket # start at 23001, 24001 and so on but I don't know how to write the expression to do it. Can anyone help me with this? 

I think one of the issue is that the column 'LIS Ticket #' is built as a text line and we can default the word 'generating...' while waiting for the flow to run and generate the number. I suspect this is why I cannot seem to get the 'add' function to work. The expression probably needs to change the data type to an integer but I can't get it to work!

 

This is the expression in the LIS Ticket # field in the action 'Update Item' below

formatNumber(triggerOutputs()?['body/ID'],'23000')

 

RUSLO_0-1673009487874.png

 

 

 

  • Verified answer
    Expiscornovus Profile Picture
    Expiscornovus 31,144 on at
    Re: Need help writing an expression to add to and format a number.

    Hi @RUSLO,

     

    You can use a utcNow with the yy format. This way every year you get the correct starting number (23, 24, etc).

     

    You can convert that yy string value to a number with an int function. After that you can mul(tiply) that number by a 1000. And as a last action you can add the ID field number to it.

     

    Below is an example

     

    add(mul(int(utcNow('yy')), 1000), triggerOutputs()?['body/ID'])

     

    listicketnumber.PNG

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,691

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 65,019

Leaderboard