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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Field valiation

(0) ShareShare
ReportReport
Posted on by 37

Hello,

I have a question regarding field validation. What is the best/easiest way to create a validation for the customer field in the agreement.

The customer entity has a new field "blocked" and choosing a blocked customer in the agreement should throw an exception.

I tried a jscript function but I am not sure how to fetch related customer record, or if it is possible? Or is the best way using an c# plugin?

Or is there an easier way?

Thanks

Dominik

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Priyesh Profile Picture
    7,396 User Group Leader on at

    Hi,

    Yes, plugin would be the best approach going forward because Real-Time workflow can't run before the creation of the record.

    Hope this helps.

  • Verified answer
    RaviKashyap Profile Picture
    55,410 Moderator on at

    Hi,

    The best option is to instead of validating, you create a view for unblock customers and use that view in the lookup field. This way there will be no record to select from.

    If you still want to display all records, then add the validation using real time workflow. For this, create a real time workflow and trigger it on create of agreement. Within the workflow check if the customer is blocked. If it is then stop the workflow as cancelled and display error message. This is the simple/ easy way to add the validation.

    If you want to trigger the validation on select the account then you will have to write javascript, retrieve the details of the selected account and then check if it is blocked if yes then display error. To me writing this is unnessary effort as you have the above to easy options.

    I would not suggest plugin s for this requirement as it requires coding (the same reason as javascript)

    Hope this helps.

  • DominikG Profile Picture
    37 on at

    Hello Ravi,

    as the customer wants to see all customers at all time, I built a workflow as you suggested. This works just fine.

    Out of curiosity do you have any idea how a jscript function could look like?

    I tried this approach and managed to get an error when changing the value of the field. Yet I have no idea how to fetch the related customer record.

    Thanks for your help!

  • RaviKashyap Profile Picture
    55,410 Moderator on at

    Hi,

    You need to use Web API query to retrieve the record. Once the value is retrieved, check the value and display error accordingly. The easiest way to write Web API query is to use Rest Builder Tool-

    Refer this blog carldesouza.com/.../

    You can download the tool here- github.com/.../releases

    For further reference on using this in an actual scenario, refer below blog which retrieves the value and set it on a field. In your case, once the value is retrieved, you need to check the value and display alert.

    community.dynamics.com/.../get-lookup-value-from-other-entity-and-set-it-on-the-form-using-web-api-in-microsoft-dynamics-crm

    If you still can't figure out then create a new thread with your script and I (or someone else) can take a look and assist you further :)

    Hope this helps.

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans