CRM 2013 - Javascript Form Alert (onload Event) Referencing Child Records
I need some Jscript help for a CRM 2013 Form onload event that needs to reference a property from it's child records.
The parent entity is 'Contact'. The child entity is custom, lets call this entity 'Child'. The property referenced by the onload event is a Boolean two option field (yes/no), lets call this field 'Happy'.
What I need is for the 'Contact' form to display an alert message when none of the 'Child' records have the property 'Happy' set to 'yes'.
Example;
-If a 'Contact' has 2 'Child' records and both child records have property 'Happy' set to 'no', then show alert 'the children are not happy'
-If a 'Contact' has 2 'Child' records, one 'Child' record has 'Happy' set to 'yes', one 'Child' is set to 'no', then do not show alert
Any help with this would be great. Thanks
Answer
You'll need to perform a Rest Call (You can use the FetchXml Query Builder or some other tool to generate the URL you will need) to lookup the Child records from the onLoad. It should have a filter on it to filter the Child's parent Contact to be the Xrm.Page.data.entity.getId()
(Might need to change the formatting on that) and for the Happy field to be true
. If you don't get any results, throw your alert.
Related Questions
- → How to update data attribute on Ajax complete
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → Octobercms Component Unique id (Twig & Javascript)
- → Passing a JS var from AJAX response to Twig
- → Laravel {!! Form::open() !!} doesn't work within AngularJS
- → DropzoneJS & Laravel - Output form validation errors
- → Import statement and Babel
- → Uncaught TypeError: Cannot read property '__SECRET_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED' of undefined
- → React-router: Passing props to children
- → ListView.DataSource looping data for React Native
- → Can't test submit handler in React component
- → React + Flux - How to avoid global variable
- → Webpack, React & Babel, not rendering DOM