Without any ado, let’s get started building a process in bpm’online*. [If you need a quick intro: bpm’online – https://www.bpmonline.com/studio/business-process-management, BPMN – http://www.bpmn.org/]
We start with a scenario – updating a Contact address from the parent Account. Maybe when you enter a contact, you don’t want to have to enter the address, because it should be the same as the parent account. Maybe the parent account address changed and you want to update the contact as a result (although there are other ways to handle that scenario!). Either way, or another, we will proceed with this as our goal.
CREATE A NEW PROCESS
To begin, we will create a new process in bpm’online. I will access it from the Studio menu, Process Library.
Hit the New Process button to begin. A new browser window/tab should open, with an empty process canvas.
Every process has a start; in our case we will run this process manually, so an empty green-lined circle will denote that. Bpm’online calls that a Simple start method (there are 3 other options currently; you can read more here: https://academy.bpmonline.com/documents/technic-bpms/7-12/process-elements-start-and-end-events).
Let’s name our process something else besides “Business process 1.” Simply click into the title field and enter the name. I chose “Run Process – Update Contact Address from Account.” The Run Process tells me it is run manually, the rest is the description. Feel free to use your own naming methodology.
Over on the right side of the process design window, you will notice a properties-like area. This area is used to define properties of the process or whatever element you are working with.
We are not going to worry about all of these settings right now, but you can access the bpm’online Academy to learn more (http://academy.bpmonline.com). But we are going to create a Process Parameter that will capture the Contact record.
ADD A PROCESS PARAMETER
Click on the Parameters tab of the Process Properties window. Hit Add Parameter, and select Lookup. Fill out the rest like so:
Yes, leave the Select value empty. When this is run from a Contact record, the value will be passed to the process.
ADD PROCESS ELEMENTS
So now we have a new process with a name and parameter, which is a good start. But it doesn’t do anything yet, other than offer potential. If we are going to update the Contact address from the parent Account, the first thing we need to have the process do is read the Contact record and get the parent Account. So, from the left side of the process design window, scroll down to System Actions, and drag “Read data” over onto the line between the start and finish.
Click on the Read data 1 process element, and you will notice the right side of the design window changes to the properties of that element. Click in the title area, and change the name to “Read Contact Account” or similar.
Now we need to tell this element what to read:
Which data read mode to use? = Read the first record in the selection
This tells the element to read just the first record, which in our case is what we want, a single contact.
Which object to read data from? = Contact
This is a system lookup. We want to read the Contact record type.
How to filter records?
Use the built-in bpm’online filtering criteria to select which record(s) to read. In our case, we want to read the contact that was selected when we ran the process. Hit Add condition and select Id. Then set that to a Process Parameter by selecting Compare with Parameter. In the window that opens, select the Process Parameters tab, and select “Contact” (or whatever you named the parameter earlier).
How to sort records?
We will leave a Full Name, Ascending.
What record data should the process read?
Select “Read data from selected columns only” because we do not need all of the data, just a few fields. Add Account, City, and Id. We are adding City to determine in a later step if the address exists or not. Yes, this is a simple check but it works for this article!
Okay, so now the process is reading the Contact record, and grabbing the parent Account. Next we need to read the Account and get the address. From the left side of the window, drag “Read data” onto the line after “Read Contact Account” and before the end.
Click on this element, and rename to Read Account Address. Setup your properties as follows:
This is similar to the “Read Contact Account” element, but we are looking at the Account object, and filtering the data so the Id is the account record we read from the Contact. Do this by selecting Id as a filter condition, then selecting Compare with Parameter. In the window that opens, select the Process Elements tab, then click on the Read Contact Account element, then select the Account parameter.
That tells this process to look for the Account that is set on the Contact record from which we read previously. Yeah! Now we have the Contact info and the related Account address info. Next we determine if the address exists on the Contact or not, to know if we need to add a new record, or update an existing value.
ADD AN EXCLUSIVE OR (XOR) ELEMENT
To build logic into the process, scroll down the left side of the design window and select Exclusive gateway (OR) from the Gateways area. Drag that onto the process after Read Account Address and before the end. Move the end element around if you need more room.
Click on the newly added element, and in the right side of the window (in the properties area) change the name to “Contact Address Exists?” or similar. This XOR (Exclusive OR) will follow only one path, based on the conditional logic we build next.
Now, we need 2 new elements added before we can connect them to the XOR element; one for adding a new Contact Address record, and another for updating the contact address that already exists. We will be using a simple check (does City exist on the Contact?) to figure this out.
From the left side, drag over a new Read data element, and a new Add data element. Name the Read data element something like “Update Contact Address from Account” and the new Add data element “Add Contact Address.” You will then want to select the line between our XOR element and the end (red circle) and delete it.
Now to connect the XOR with the 2 new elements. First, click on the XOR element and hover over the
icon that looks like an empty diamond connected to an arrow.
This is a Conditional Flow, and we will drag this to the “Update Contact Address from Account” element. Second, click on the newly created line, and in the properties area on the right side of the design window, name it something like “Yes” or “Address Exists.” We also need to give it a condition, so in the properties area, under the “Condition to move down the flow” click the lightning symbol. A new window should open to enter a Formula. On the Process Elements tab, select the Read Contact Account element, then double-click on “City” in the Search element parameter area. This will add the value to the formula area as “[#Read Contact Account.First item of resulting collection.City#]”. Now add to the end of the formula the text “!= Guid.Empty” and make sure the case is exact (otherwise it will let you know!). The full formula should be
[#Read Contact Account.First item of resulting collection.City#] != Guid.Empty
Note that your formula may be different based on what you named the Read Contact Account element. Basically, this formula says “follow me if the City value from our Contact is not empty.” We are making an assumption that if a City value exists on the Contact, the rest of the address exists as well and can be updated. As I stated earlier, this is a very basic check, but will work for the purposes of this article.
Now that our Update element is connected, we need to set a default flow from the XOR element. Select the XOR element, and select the icon that is an arrow with a line through it. Drag that to the Add data element (Add Contact Address) so the process knows where to go. There is no logic on a default flow.
Our process looks like this now:
Now we need to define the Update and Add elements and tell them what to do.
Select the Update Contact Address from Account element, and fill it out thusly:
In the “Modify all records that match condition” we select Id and set it equal to the Process Parameter named “Contact” that we set earlier on the process itself. This tells the system to update that contact only. Next we set what fields to update. We update City, State/Province, Street, Zip/Postal Code, and Address Type. Address Type we set to a lookup value and hardcode Business. We pull the rest of the data from the “Read Account Address” element.
Next click on the Add data element named “Add Contact Address” so we can tell that what to do. This one is a little different, because we will not be updating the contact itself, but adding a new record to the Contact Address object. Fill out the properties as such:
Again, we set Address Type to be a lookup value of Business. We also set the Contact to be the Process Parameter named “Contact” and the Primary checkbox we are setting to be a Boolean value of True. Everything else comes from the same Read Account Address element.
Lastly in this process design, drag a connector from the Update element and the Add element to the end. Your process should look like this now:
Yeah! If you were following along your process should be complete. Save the process so we can run it soon.
CONNECT A PROCESS TO AN OBJECT
Before we run it, we need to attach this process to the Contact entity/object so we get the right value when the process is run. To do that, we need to get to the Section edit area of the Contact object. In bpm’online, go to a list of contacts or a single contact record. If you are on a list of Contacts, near the top right of the grid select View – Open Section Wizard. A new window will open showing the properties of the Contacts section. BE CAREFUL IN HERE!
Select the Business Processes tab so we can relate our new process to the contact record. On that tab, hit the plus sign next to “Run business process from section.” Select the new process from the list. Then select “For selected record” and select Contact. Your properties should look like this:
Save that and then Save the section by hitting the green Save button. This will take a moment.
Once complete you can close this tab/window and go back to the Contacts list. Refresh the screen so bpm’online refreshes itself (F5 to refresh on your keyboard works). On the list of contacts, if you select one you will see a Run Process button, and you can select to run the new process.
If you are on a single contact record, the button will be near the top of the window:
When you run the process it will find the contact’s account, read the address, and copy or add it to the contact record. Just make sure your account has a valid address!
If you encounter any errors or don’t see things working, you can view the process log (under Studio).
That’s it for now! Hopefully this was helpful for those of you new to bpm’online! If you have any questions please reach out to us!
*Bpm’online became Creatio on 10/30/19