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
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.
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.
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!
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.
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.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,253 Super User 2024 Season 2
Martin Dráb 230,188 Most Valuable Professional
nmaenpaa 101,156