Answered by:
CRM 2011: Javascript, retrieving data from parent entity

Question
-
I have a entity called Household, which holds the info of two people: Client A and Client B. When I create a new Contact from within this entity, I want to auto populate some fields based on a picklist within Contact that contains the options Client A and B. Normally I would do this through relationship mapping and workflows, but in this case I'm unable to map both a Client A and Client B field from Household, to a singular field in Contact.
So I'm using window.top.opener.parent.Xrm.Page to access the parent form Household, and putting this in the onChange event in the picklist. I've tested this, and this code so far works; the parent page exists.
However, when I try window.top.opener.parent.Xrm.Page.getAttribute(<name>).getValue() I get an error that says "Error:Object doesn't support this property or method." Is this a bug in CRM 2011? I've tested similar code in CRM 4.0 and it works as intended.
Wednesday, April 13, 2011 4:05 PM
Answers
-
You can get the parent entity GUID through a parent lookup on the form in Jscript, then you can do a retrievemultiple to get back whatever information you need from the parent entity from the GUID.
jscript retrieve multiple calls - http://mileyja.blogspot.com/2011/03/crm-2011-retrievemultiple-calls-in.html
Parsing response from retrievemultiple - http://mileyja.blogspot.com/2011/03/microsoft-dynamics-crm-2011-parsing.html
Jamie Miley
http://mileyja.blogspot.com
Linked-In Profile
Follow Me on Twitter!- Proposed as answer by Jamie MileyModerator Thursday, April 14, 2011 5:49 PM
- Marked as answer by Andrii ButenkoMVP, Moderator Wednesday, February 8, 2012 2:40 PM
Wednesday, April 13, 2011 4:27 PMModerator
All replies
-
You can get the parent entity GUID through a parent lookup on the form in Jscript, then you can do a retrievemultiple to get back whatever information you need from the parent entity from the GUID.
jscript retrieve multiple calls - http://mileyja.blogspot.com/2011/03/crm-2011-retrievemultiple-calls-in.html
Parsing response from retrievemultiple - http://mileyja.blogspot.com/2011/03/microsoft-dynamics-crm-2011-parsing.html
Jamie Miley
http://mileyja.blogspot.com
Linked-In Profile
Follow Me on Twitter!- Proposed as answer by Jamie MileyModerator Thursday, April 14, 2011 5:49 PM
- Marked as answer by Andrii ButenkoMVP, Moderator Wednesday, February 8, 2012 2:40 PM
Wednesday, April 13, 2011 4:27 PMModerator -
Thanks, will look into those links.Wednesday, April 13, 2011 4:51 PM
-
Did this help you at all? If so you should come back and mark as an answer.
Jamie Miley
Check out my about.me profile!
http://mileyja.blogspot.com
Linked-In Profile
Follow Me on Twitter!Thursday, July 28, 2011 9:08 PMModerator