Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Unanswered

Text to update option set using flow

(0) ShareShare
ReportReport
Posted on by 511

I'm trying to create a new entity from another.

The field in the originating entity is a simple text field, but the one I want to update is an option set.

I'm aware that this can't be done using an ordinary workflow, but can this be done using Microsoft Flow, or am I stuck with writing a custom workflow in C#?

Thanks

Lee

  • LeoAlt Profile Picture
    16,331 Moderator on at
    RE: Text to update option set using flow

    Hi Lee,

    Since you want to tirgger the action when creating record, so you should use plug-in with C# to do this.

    You could register the plug-in before or after the creation of the new records.

    docs.microsoft.com/.../tutorial-write-plug-in

    Hope it helps.

    Best Regards,

    Leo

  • Lee-Martin Profile Picture
    511 on at
    RE: Text to update option set using flow

    Thanks

    The originiating custom entity is being populated from a  third party system via Logic Apps, so I have to use the creation (or update) on the entity as a trigger.

  • LeoAlt Profile Picture
    16,331 Moderator on at
    RE: Text to update option set using flow

    Hi partner,

    In default workflow, we could not set value between fieds with different types.

    So I suggest that you could use custom workflow created by C# or use web api directly to create new record.

    1.C#

    Since you want to set the value from text to options set, so you should konw the labels and vaules, you could do a judgement first to confirm the real value according to the text field and then set the value to option set field.

    http://rokhri.com/get-optionset-value-and-set-optionset-value-in-crm-2015-plugin/

    2.Web Api

    You could create a custom ribbon on the main entity form and add a js function which could create a new record of other entity in it.

    Here is the sample code to create a new record and set value from text to option set.

     


    function createNewRecord(executionContext) {
        var formContext = executionContext.getFormContext();
        var optionValue = 0;
        //get text value
        var textValue = formContext.getAttribute("textField").getValue();
        //Match the correct value according to label
        if (textValue == "...") {
            optionValue = 1;
        }
        if (textValue == "...") {
            optionValue = 2;
        }
        //...
        var data =
        {
            "optionSet": optionValue
        }

        // create account record
        Xrm.WebApi.createRecord("entityLogicName"data).then(
            function success(result) {
                console.log("entity created with ID: " + result.id);
                // perform operations on record creation
            },
            function (error) {
                console.log(error.message);
                // handle error conditions
            }
        );
    }

    Hope it helps.

    Best Regards,

    Leo

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

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

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,865 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,723 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Product updates

Dynamics 365 release plans