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)

Javascript - Checking the value of a field on parent entity?

(0) ShareShare
ReportReport
Posted on by 205

I'm trying to do kind of an onSave data validation script on the Incident entity. I want to check a value on the Incident's parent customer (Account) to see if they're authorized for the type of Incident the user is trying to create. If yes, the Incident will save. If no, the save will be interrupted and an alert will inform the user that the customer is not authorized.

So, my question is... what function can I use to check the value of the field on the parent Account? Is there something like Xrm.Page.Parent.GetAttribute ?

I appreciate any guidance.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Mahadeo Matre Profile Picture
    17,021 on at

    Hi..

    To do this I will suggest create quick view form for account, put it on case form.

    In quick view form you can add attribute which you want to check when case is saved.

    and on case save event access quick view form and add your business logic

    Here is link to access quick view form value

    mahadeomatre.blogspot.com/.../access-quick-view-form-values-in.html

    another option is, you need to retrieve parent account entity details using JavaScript and REST, and check required value of parent account on case entity on save.

    Hope this will help..

  • ChadF Profile Picture
    205 on at

    Thanks for the suggestions, but I think the quick view forms as described in your blog are a CRM 2015 feature, correct? I am working with 2011.

    Could you expand your second option a bit more?

  • Verified answer
    Mahadeo Matre Profile Picture
    17,021 on at

    Hi,

    As you need to get information from parent account, to see this account is authorized to create this case or not.

    you need to use JavaScript code on case entity OnSave event.

    In this JavaScript code you need to retrieve parent account details, mainly authorization details.

    Here are details how to retrieve data using JavaScript and REST

    crmbusiness.wordpress.com/.../crm-2011-javascript-code-to-lookup-parent-customer-addresses-from-contact-form

    msdn.microsoft.com/.../gg334427(v=crm.5).aspx

    then if this account is not authorized then you can throw alter to user with some message and stop save event.

    here are details on how to prevent save

    crmbusiness.wordpress.com/.../crm-2011-quick-tip-javascript-to-stop-a-form-saving

    www.infinite-x.net/.../crm-2011-canceling-the-save-operation

    If you are creating case always from account.. I mean open account, then create case from form navigation, then another option is to use attribute mapping.

    You can create similar authorization attribute in case entity, and use relationship mapping to map values.

    Then use directly authorization attribute details from case entity..

    This is all client side code.. so it will affect only when user is creating case from CRM user interface. if cases are created from some another way into CRM, then you can use same logic into Plugin and register plugin on Pre-Create event.

    So that case will not be create if account is not authorized.

    If this is not more clear, please let me know I will try to explain in some another way..

    Hope this will help

  • ChadF Profile Picture
    205 on at

    Thanks for the clarification. Sounds like I might be out of my depth on this one!

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