Skip to main content

Notifications

Microsoft Dynamics 365 | Integration, Dataverse...
Answered

Agreement Form Validation

(0) ShareShare
ReportReport
Posted on by 873

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!

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee 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

  • EBMRay Profile Picture
    EBMRay 873 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
    Community Member Microsoft Employee 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

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

News and Announcements

Announcing Category Subscriptions!

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,359 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,370 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans