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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Update unrelated record with workflow

(0) ShareShare
ReportReport
Posted on by

Hello,

I have 2 custom entities, Subscription and Preference.

They both share 3 fields: Individual, list, status.

When a new preference record is created, we want it to automatically check if the individual already has a Subscription record, if they do then update it, if they don't then create one.

How can I do this with a workflow?

The 2 entities currently do not have a relationship.

I thought that if I created a 1:N relationship between them, then created a workflow I could update/create a Subscription record when a Preference record was created. Sure enough, by creating a 1:N relationship I can now see 'Subscription' under the 'relate entities' heading in the Update record function, but it does not seem to work - I think this is because it doesn't know which Subscription record is the parent of the newly created Preference record (it should be the one where the individual and the list are the same).

I hope I have explained myself clearly.

Hope you can help!

*This post is locked for comments

I have the same question (0)
  • Mahadeo Matre Profile Picture
    17,021 on at

    You can create 1:N relationship between preference and subscription and 1:N from Subscription to preferences.

    If you dont have unique subscription records or subscription records are not shared between other preferences.

    Now when creating new preference.. create subscription record also and update preference with subscription, and when preference is updated then update subscription also.

    Another option is just created 1:N relationship between preference and subscription, and write custom workflow activity, and in code you can easily find related subscriptions and insert / update subscription based on your business logic.

  • Community Member Profile Picture
    on at

    Thanks for the reply Mahadeo. I'd like to try doing this using the workflow interface rather than resorting to a custom workflow if possible.

    A subscription may have multiple preferences. But a preference will only ever have one subscription. So I created an 1:N relationship where Subscription is the 1 and Preferences are the many.

    I've created a workflow on the Preference entity that initiates when a Preference record is created.

    I've set the workflow to update Subscription. But when I create a Preference the workflow runs but it does not update the Subscription record. (When I look at the workflow sessions it is stuck at 'Waiting' - when I open it up it says 'A record required by this process could not be found')

    If I change the workflow to create (instead of update) Subscription, it works fine. So I conclude, that the update is not working, because it doesn't know which Subscription record to update. But I don't know why?

  • Community Member Profile Picture
    on at

    Does anyone have any suggestions? I am still stuck on this.

    My workflow that runs on the Preferences entity is able to create a Subscription record thanks to the 1:N relationship that I have created. But it cannot update an existing Subscription record, because it doesn't know which Subscription record to update.

  • Alessandro Graps Profile Picture
    2,664 on at

    Hi,

    you can create a custom activity workflow in c#. With c# you check if individual has un subscription record or not. with c# always you can create or update the entity.

    After you can create a workflow on created preferece and inside this you call the custom activity workflow.

    Thanks

    A.G.

  • Suggested answer
    Community Member Profile Picture
    on at

    You created a 1:N relationship from Subscription to Preference, which sounds good.

    Now you need to add a condition to your Workflow so it goes something like this:

    If <Subscription lookup field> Does not contain data

    then Create Subscription record (copy relevant fields from Preference record, if any)

    Update preference record > Set the lookup to the new Subscription record. This will appear in the pane on the right using the name of the previous step where you created this.

    Update Subscription (whether it was already there or just got created, the lookup is now filled in so this will work).

  • Community Member Profile Picture
    on at

    [quote user="Adam Vero"]

    You created a 1:N relationship from Subscription to Preference, which sounds good.

    Now you need to add a condition to your Workflow so it goes something like this:

    If <Subscription lookup field> Does not contain data

    then Create Subscription record (copy relevant fields from Preference record, if any)

    Update preference record > Set the lookup to the new Subscription record. This will appear in the pane on the right using the name of the previous step where you created this.

    Update Subscription (whether it was already there or just got created, the lookup is now filled in so this will work).

    [/quote]

    Hi Adam,

    Thanks for your reply - this is EXACTLY what I had thought. Unfortunately, it seems that the problem is that the lookup field created on the Preference entity by the relationship is never finding a Subscription record.

    Perhaps I have done something wrong in creating the relationship. The lookup field is looking up the "subscription name" field on the Subscription record so I don't know exactly how it would select a Subscription record.

    [quote user="Alessandro Graps"]

    Hi,

    you can create a custom activity workflow in c#. With c# you check if individual has un subscription record or not. with c# always you can create or update the entity.

    After you can create a workflow on created preferece and inside this you call the custom activity workflow.

    Thanks

    A.G.

    [/quote]

    Hi Alessandro, we're hoping to do this solely through the process interface without a custom activity workflow, but this will be our plan B. Thanks.

     

  • Community Member Profile Picture
    on at

    Accidental duplicate post - sorry!

  • Suggested answer
    Community Member Profile Picture
    on at

    It depends how you create your preference records, I guess.

    On your Subscription record form you could have a sub-grid to display (child) Preferences, or use the navigation bar to open the Preferences associated view. From either of those you should be able to create a Preference record that will have this Subscription as the parent in the lookup already.

    If you just create a Preference record out of thin air, and don't bother to link it to an existing Subscription record then the lookup will be blank.

    Which is where my method works. If you don't have a Subscription in the lookup, we create one, then fill in the lookup to point to that new record. To fill in the lookup, you need to find the NEW subscription entity in the list in the Workflow. I have done a mockup here with a step called "Create parent Subscription record" (for the purpose of the mockup I created an Account record, rather than build your data model in my CRM!)

    In the update step that follows, I can access this new record under the "local values" section near the bottom of the list, where it shows the name of the create step, as shown in the attached screenshot. I then choose the GUID field, which has the same name as the entity. So in your case you would select "Create parent Subscription (Subscription)" then select the "Subscription" field (the only option you will have).

    Workflow-update-step-for-previously-created-record.png

    Maybe try building it and you will see how it works.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans