Get Fields From Related Records Using Actions

Have you ever had that requirement where you know you can solve most of it with a workflow but the information you are after is one relationship too far away? For example:

I have a custom entity called Event Registration that is related to Contact but the discount information is placed on Account.

This article will explain how you can use an action as a placeholder for that information that is out of reach, and use it in your workflow either as a condition or to populate a field.

At the end of January I was one of the speakers at D365 Saturday Scotland where I did a session I called “No-code Hacks”. My presentation was a live demonstration where I did no-code configuration solving a couple of fairly complex requirement. This action-hack I’m about to go through in this article is one of those hacks, a hack I first learnt from my very talented colleague Stina Persson, so big thanks to Stina!

Our scenario

We have two custom entities, Event and Event Registration. We have a field on Account called Event discount that we want to check if it contains data, and if so, populate the Event Registration with that information.

Note that there is no relationship between Account and Event Registration.

So as for now we can’t use information on Account in a workflow that triggers on Event Registration. So let’s create the action that solves that problem!

Creating the Action

First I create an action on the Contact entity and add a process argument with the following information:

Type: EntityReference
Entity: Account
Direction: Output

Easy peasy so far, right?

So next step is to define which relationship between Account and Contact I want to receive when I run my action. In my scenario I only have one relationship, the default one, so it’s an easy decision but other scenarios might very well contain several options so be careful with what you choose here.

First I add the Assign Value step in my action (1) and define the value as the dynamic value of Company name(2).

All done! Now I just activate my action so I can use it my workflow.

Using the Action in a Workflow

To start with I create a real-time workflow that triggers on create of Event Registration. Since the first thing I want to do is check if the participant’s (Contact) are entitled to an event discount I start with running my action so I can use Account information in my condition

I add the Perform Action step and pick the action I just created.

In properties for the action I define what relationship between Event Registration and Contact I want to get the Account for.

Now I can add my condition (1) and find my action in Local Values (2) and there after use any field on the Account entity in my condition (3).

Next step is to update my Event Registration with the discount information. Same thing here – I have a Local value that refers to my action information that I can use to populate my discount field. Awesome!

Using an Action in an Action in a Workflow

What was that? Using an action in an action in a workflow? Well what if we need to reach another entity that is one step even further away? Let’s say that if the Parent Account of the Account have a discount, that should override the other discount. How would that look? Let’s check it out!

First of all – let’s create a similar action to the previous one that retrieves the Parent Account. I create my action on the Account entity (1), add the process argument (2), add the assign value step (3) and make sure to pick the right relationship to retrieve (4).

Now I need to make some changes to my workflow. First I remove my condition (since we’re going to change it anyways), then I perform my second action straight after the first one (2). When I set the properties of the “Get Parent Account”-action I use my local value to make sure I retrieve the Parent Account from the Account I retrieved in my first one.

So finally in my condition I first check for if the Account have a Parent Account and that Parent Account’s Discount field contains data (1), if so update the Event Registration with the Discount from Parent Account (2).

If not check if Account’s Discount field contains data, if so update the Event Registration with the Discount from Account.

There you go peeps! That’s it! So no need for unnecessary relationships between entities (or god forbid – CODE) to solve issues like this. Actions are the way to go! Also remember that these actions are re-usable for when ever you need to get that relationship again.


11 thoughts on “Get Fields From Related Records Using Actions

Add yours

  1. The only thing I do not understand is how you collect the discount information.

    You retrieve the account linked to the contact. But how do you know that the discount information must be retrieved specifically?

    Like

    1. Well the discount information is just a field on the Account form (whole number). So what I do is that I retrieve that field and populate it on my Event Registration by using the local value from either Account or Parent Account. Did that answer your question?

      Like

  2. Thank You Very Much Sharing the Data and the Presenation is Very Good please keep on posting the this Kind Articles Miss. Sara Lagerquist

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Blog at WordPress.com.

Up ↑

%d bloggers like this: