web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Compose Action in lieu...
Power Automate
Answered

Compose Action in lieu of Variables

(0) ShareShare
ReportReport
Posted on by 68

 

I am using a SharePoint list with a Flow.

 

For the current item, I want to read one field, subtract 10 from the field, then update another field in the list.

 

I don't see any ability to use a variable in Flow, so can I use a Compose Action for this?

 

Something like:

 

1. Trigger: When new item is created then

2. Compose Action: ContractNo=[ID]-10 then

3. Update Action: NewField=ContractNo Output

 

Would this work?  Any better ideas?

Categories:
I have the same question (0)
  • v-micsh-msft Profile Picture
    Microsoft Employee on at

    Hi @MikeInCairns,

     

    Yes, that would work.

     

    I have a few concern about the ID you used here. The ID should already be used as an system field, which can't be set to an available item field, so could you please explain a bit for this field?

    In addition, what is the New Field (ContractNo) and th ID field type?

    To be able to subtract, the field type need to be Number.

    If for string field, we could take use of the Float() or int () function to convert the number into the corresponding type.

    For example, the following flow would convert the title field from string into Float, then subtract 10 from the number, update the ContactNo with the compose outputs,

    Formula used in Compose:

    "@sub(float(triggerbody()?['Title']),10)"

    Function reference

    74.PNG

     

    See the results:

    75.PNG

    If you need any further assistance on this, please post back.

    Regards,

    Michael

  • MikeInCairns Profile Picture
    68 on at

    Thought I should provide clearer details about what I am trying to achieve.  I have a SharePoint Designer workflow that does what I want, but I would rather use the new Flow if possible.

     

    I have a SharePoint list.  Every item in the list is assigned an item ID by SharePoint.  I also have another column (lets call it ContractNo).  The ContractNo field must be calculated from the ID field, but this is not allowed in SharePoint so I need to do it using workflow.

     

    I need to produce a ContractNo in the format ABC-0100, where ABC is static text and 0100 is the ID number minus 10.

     

    So for an ID=30 the calculated ContractNo field need to be ABC-0020.

     

    It is so easy in Designer because you can use Variables and also functions like TEXT(x,"0000").

  • sergeluca Profile Picture
    500 on at

    we cannot create custom variables in Flow. Not yet. I also need it, and yes we could do it in SPD 🙂 

     

    Cheers

     

    Serge Luca

    SharePoint MVP

    www.shareql.com

     

  • MikeInCairns Profile Picture
    68 on at

    Thankyou Serge, but your post does not answer the question.

     

    I know we cannot use variables in Flow...hence the question...can we do something with Compose Action instead?  I believe Micheal has suggested we can.  So i am hoping someone can post more detail.

  • sergeluca Profile Picture
    500 on at

    something like this ?  "@Concat('ABC-',sub(float(triggerbody()?['ID']),10))"  ; that works on a SharePoint list (I've tested it) but indeed the issue is formatting the string  in the format you want and the Logic Apps Workflow Definition Language doesn't provide that as far as I know.

     I would rely on the Custom API (like an Azure function) to achieve it. But that requires coding.

  • Verified answer
    v-micsh-msft Profile Picture
    Microsoft Employee on at

    Hi @MikeInCairns,

     

    What is your current situation?

    Could you please share information about the ID range?

    If the ID range is within 10000, then we could somehow workaround the number format with the substring () function in Workflow definition language:

    Substring('string',Start Index, length)

    For example, we would keep the 0xxx format, the following should work:

    "@concat('ABC-',substring(string(add(sub(float(triggerbody()?['Title']),10),10000)),1,4))"

    Reference:

    83.PNG

    84.PNG

    Regards,

    Michael

  • MikeInCairns Profile Picture
    68 on at

    Thanks Michael

    That looks perfect - I will try it in the next few days.  We will have far less than 10,000 items in the list so the xxxx formatting should be OK.

  • MikeInCairns Profile Picture
    68 on at

    This is BLOODY BRILLIANT!!!  Thank you very much Michael for your persistence with me to get this working.  This has really open up my eyes to the power of Workflow Definition Language.  I am quite good with XML, VBA and DAX, but I obviously now have another language I need to learn!!  

     

    So apparently we dont need Variables if we understand how to use the Compose Action.  I look forward to learning more.  Any good resources you could reccoment to a newbie?

     

    Thanks Again

    Mike

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    For anyone else reading this in August or thereafter, variables are now supported in Microsoft Flow. 

     

    There are four actions - initialize variable, increment variable, decrement variable and set variable. 

     

    The Initialize action needs to happen after your trigger in the beginning of the flow, and there you can specify the type (Bool, Int, Float, String, Obj, Array). 

     

    The set variable can then be used to modify a string variable in a switch case or whatever else you want. 

  • jessicaf31 Profile Picture
    6 on at

    Hello ! Is this possible then to use a variable for a list address?!

    I have a first list with a selection of 20 business units (yes/no radio button).

    If the user selects "yes" for one(or more) business unit(s), then the business unit list is updated...can you help me ?! Thanks!

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Automate

#1
David_MA Profile Picture

David_MA 60 Super User 2026 Season 1

#2
Haque Profile Picture

Haque 54

#3
Expiscornovus Profile Picture

Expiscornovus 47 Most Valuable Professional

Last 30 days Overall leaderboard