Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

On Demand Workflow, but one step only once

Posted on by

I need a solution to allow a user to select multiple records and create a parent record to which they all become a child.  I tried creating an on demand workflow which creates the parent record, but if I selected three records, I get three parent records.  I only want one.  For example ...

User selects three line item records and runs an on demand workflow which creates an invoice record with a unique id.  Problem is I want all three line item records to be related to one unique id, not three separate ones.  On demand workflows will repeat all steps for each record.  Is there some type of memory variable I can use to identify the running of the workflow in a sessions, per se, so I can specify one step to only run once per session?

*This post is locked for comments

  • Suggested answer
    Aric Levin Profile Picture
    Aric Levin 30,188 on at
    RE: On Demand Workflow, but one step only once

    Hi Deb,

    Another option is using combination of possibly webapi and actions.

    You select the records and have a custom button on the command bar that's called associate (for example).

    You create the parent record via web api and get the id of the new parent record.

    You then call a custom action that will update the parent in each one of these records.

    I think either this solution or anyone of the solution above will work for you.

    Good luck.

  • Verified answer
    Aiden Kaskela Profile Picture
    Aiden Kaskela 19,692 on at
    RE: On Demand Workflow, but one step only once

    Hi Deb,

    You won't be able to do this in a workflow without having some custom plugins behind the scenes (and even then it would be pretty ugly).

    An alternate approach would be to add a button to the view and handle the logic in javascript. When they click the button, read which fields are selected by using getSelectedRows (Details: msdn.microsoft.com/.../dn932126.aspx)

    By moving the code outside the specific records, you have control over spawning just one parent and associating the children, without having to worry about creating duplicates.

    Hope this helps! I'd appreciate if you'd mark this as Answering your question.

    Thanks,

     Aiden

  • Verified answer
    Guido Preite Profile Picture
    Guido Preite 54,081 Super User 2024 Season 1 on at
    RE: On Demand Workflow, but one step only once

    Hi Deb,

    for this kind of scenario you will need custom code. I will break in two workflows, the first one (standard) will set a custom field to a specific value on the selected records (to mark them as future children)

    the second workflow that will contain custom code (using a custom workflow activity) will look for records that are children candidate and create the parent and put the records as children.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans