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 / how to set choice (opt...
Power Automate
Unanswered

how to set choice (option set) by text in power automate

(0) ShareShare
ReportReport
Posted on by 7

Hi guys,

I have a option set feild in the Opportunity table. 

asmilie2b_0-1716799689192.png

and I'm getting data from a another data source and creating the opportunities using a power flow.

This is how I tried to populate values for the option set field and it doen't work like that.

asmilie2b_1-1716799843446.png

 

 

Please suggest me to do it proper way. 

Categories:
  • Inogic Profile Picture
    1,297 Moderator on at

    Hi,

     

    As per our understanding, you've encountered an issue with setting a choice (option set) by text in Power Automate.

    Let's consider your scenario where you have a text field in the opportunity entity, and you want to set the option set field based on this text field.

     

    The forecast category is an option set, and you can use the following expression to map the text field to the corresponding option set value:

     

    Use the below expression :-

     

    if(

        empty(triggerOutputs()?['body/cre80_forecast']),

        null,

        if(

            equals(triggerOutputs()?['body/cre80_forecast'], 'Pipeline'),

            100000001,

            if(

                equals(triggerOutputs()?['body/cre80_forecast'], 'Best case'),

                100000002,

                if(

                    equals(triggerOutputs()?['body/cre80_forecast'], 'Committed'),

                    100000003,

                    if(

                        equals(triggerOutputs()?['body/cre80_forecast'], 'Omitted'),

                        100000004,

                        if(

                            equals(triggerOutputs()?['body/cre80_forecast'], 'Won'),

                            100000005,

                            if(

                                equals(triggerOutputs()?['body/cre80_forecast'], 'Lost'),

                                100000006,

                                null

                            )

                        )

                    )

                )

            )

        )

    )

     

    This expression checks the value of the cre80_forecast field and maps it to the corresponding option set value. If the text field is empty, it returns null. Otherwise, it assigns the appropriate value based on the text.

     

    Hope this helps.

     

    Thanks!

    Inogic Professional Services: Power Platform/Dynamics 365 CRM
    An expert technical extension for your techno-functional business needs
    Drop an email at crm@inogic.com
    Service: https://www.inogic.com/services/
    Tips and Tricks: https://www.inogic.com/blog/
  • asmilie2b Profile Picture
    7 on at

    Thank you for the answer.  

     

    I tried to use your suggestion by modifying it.

     

    if(empty(items('Apply_to_each')?['PROJECTSTAGE']),null,
           if(equals(items('Apply_to_each')?['PROJECTSTAGE'], 'Preconstruction'),1,
                if(equals(items('Apply_to_each')?['PROJECTSTAGE'], 'Design and Documentation'),2,
                    if(equals(items('Apply_to_each')?['PROJECTSTAGE'], 'Construction'),3,
                        if(equals(items('Apply_to_each')?['PROJECTSTAGE'], 'Concept'),4,null)
                    )
                )
          )
    )

     

    But this is always going to last null part. what is the issue in this query..?

  • Inogic Profile Picture
    1,297 Moderator on at

    Hi @asmilie2b ,

    The issue might be related to how the values in items('Apply_to_each')?['PROJECTSTAGE'] are being compared. Power Automate can sometimes be picky about exact matches, including leading/trailing spaces or case sensitivity.

    Steps to Debug and Correct the Issue

    1. Check for Leading/Trailing Spaces: Ensure there are no leading or trailing spaces in the PROJECTSTAGE values.
    2. Check for Case Sensitivity: Ensure the case matches exactly.
    3. Output the Values: Use a Compose action to output the values of items('Apply_to_each')?['PROJECTSTAGE'] to verify what the flow is actually seeing.

    Adjusted Expression

    Here is your expression with added trim to remove any leading or trailing spaces and ensure that the values are correctly compared:

    if(

        empty(trim(items('Apply_to_each')?['PROJECTSTAGE'])),

        null,

        if(

            equals(trim(items('Apply_to_each')?['PROJECTSTAGE']), 'Preconstruction'),

            1,

            if(

                equals(trim(items('Apply_to_each')?['PROJECTSTAGE']), 'Design and Documentation'),

                2,

                if(

                    equals(trim(items('Apply_to_each')?['PROJECTSTAGE']), 'Construction'),

                    3,

                    if(

                        equals(trim(items('Apply_to_each')?['PROJECTSTAGE']), 'Concept'),

                        4,

                        null

                    )

                )

            )

        )

    )

     

    Using Compose for Debugging,

     

    Add a `Compose` action before the condition to output the `PROJECTSTAGE ` value:

     

    1. Add Compose Action:

     

    • Click on "New step" and search for `Compose`.
    • Set the input to `items('Apply_to_each')?['PROJECTSTAGE']`.

     

    1. Run the Flow:
    • Save and run your flow.
    • Check the output of the `Compose` action to see what `PROJECTSTAGE` value is being processed.       

     

    By using the `Compose` action, you can see the exact value being used in the comparison, which will help you identify any discrepancies.

     

    This approach should help you pinpoint the issue and ensure that the condition works correctly. If you continue to face issues, please share the exact output from the `Compose` action so I can provide more specific guidance.

    Thanks!

    Inogic Professional Services: Power Platform/Dynamics 365 CRM
    An expert technical extension for your techno-functional business needs
    Drop an email at crm@inogic.com
    Service: https://www.inogic.com/services/
    Tips and Tricks: https://www.inogic.com/blog/

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Automate

#1
Mohsin Ali Profile Picture

Mohsin Ali 289

#2
11manish Profile Picture

11manish 288 Super User 2026 Season 2

#3
Henil Profile Picture

Henil 125

Last 30 days Overall leaderboard