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

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Answered

Agreement Form Validation

(0) ShareShare
ReportReport
Posted on by 903

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!

I have the same question (0)
  • Verified answer
    Community Member Profile Picture
    on at
    RE: Agreement Form Validation

    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

  • EBMRay Profile Picture
    903 on at
    RE: Agreement Form Validation

    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:
    RealTimeWorkflow.PNG

    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!

  • Verified answer
    Community Member Profile Picture
    on at
    RE: Agreement Form Validation

    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:

    pastedimage1637904630347v1.png

    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).

    pastedimage1637905039146v2.png

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…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 72 Super User 2025 Season 2

#2
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 58

#3
Martin Dráb Profile Picture

Martin Dráb 54 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans