Announcements
Hello everyone,
I have a custom territory field in the accounts entity that is a lookup to the Territory table (OOB) and we're using that field instead of the Service Territory that is OOB for some reason.
The users are required to assign a territory value for new or existing accounts but we're not making that field mandatory in the account form until they have all the information of the account they previously created.
What I need to achieve is the below:
If the user wants to create an agreement for an account that has no territory assigned in the account table and he tried to save the agreement main form, it should prevent the user to save it and throw an exception saying that:
"The CurrentAccountName does not have a territory assigned please assign a territory by clicking on (LINK OF THE ACCOUNT) here!"
The logical name of the territory field is:
territory
Can please someone provide an example of the code to achieve the above scenario to add the validation rule on the agreement form?
In addition, where this logic should be applied onLoad or onSave of the form?
Any help is highly appreciated.
Thank you!
Hi EBMRay,
The data type of message in workflow is 'Single Line of Text', but you fill lookup value into it, the error will appear.
You need add record url into it, just as following screenshot:
which will show url of the account, but you can't click it to navigate to other pages directly(it just show as a string).
Hi Leah,
Thank you for sharing the above thread. It helped me to build a real-time workflow based on my requirements.
However, I still have a concern on how to pass the link of the current service account record in the business process error. (I was able to populate the service account name)
Please find below the workflow step parameters for the custom message:
Is it doable to add the link of the account in the error message that navigates the user to the account to assign a territory?
If it is possible, please provide an example.
Thank you!
Hi EBMRay,
Based on your description, you need custom territory lookup field related to accounts in agreement is not null in order to save agreement successfully, right?
Maybe you can create a real-time workflow to check custom territory lookup field of related accounts in agreement and restrict saving it.
The workflow has one action--Stop workflow:
Test record is NOT created and you’ll see a Business Process Error When workflow stops with status Canceled. The record will NOT be saved due to the error. (Real-time workflows rolls back the transaction, if workflow is stopped with status Canceled.)
You can refer following the thread, which provides similar scenario:
community.dynamics.com/.../blocked-accounts-in-field-service
André Arnaud de Cal... 291,359 Super User 2024 Season 2
Martin Dráb 230,370 Most Valuable Professional
nmaenpaa 101,156