Retrieving Parent Subject from Dynamics subject tree

bronafon_ict
bronafon_ict used Ask the Experts™
on
Hi all

I am using subject trees in Microsoft Dynamics CRM, is there a way of retrieving the parent subject of a selected node.

I managed to grab this code off the net which populates the value but cant determine the parent subject, just wondering if there is a property which holds this information that I am missing.

var lookupItem = new Array;

// This gets the lookup for the attribute new_phonesubjectid on the Phone Call form.
lookupItem = crmForm.all.new_phonesubjectid.DataValue;

// If there is data in the field, show it in a series of alerts.
if (lookupItem[0] != null)
{
   // The text value of the lookup. Set the subject line of the Phone call to this value
  // alert(lookupItem[0].name);
      crmForm.all.subject.DataValue=lookupItem[0].name;

   // The GUID of the lookup.
   alert(lookupItem[0].id);

   // The entity type name.
   alert(lookupItem[0].typename);

}

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
using javascript, if you want to get the parent of an element then you need to use element.parentNode

check this here
http://www.w3schools.com/jsref/dom_obj_all.asp
Chinmay PatelChief Technology Ninja
Distinguished Expert 2018

Commented:
Hi bronafon_ict, 
You will have to query CRM using XmlHttp call to get the parent, When you get subject in the lookup 
Regards,
Chinmay

Chief Technology Ninja
Distinguished Expert 2018
Commented:
Sorry, I clicked submit by accident, I meant to say :
You will have to query CRM using XmlHttp call to get the parent, When you get subject in the lookup, it won't have the parent details.
So you will have to query CRM with current subjectid and check its parentsubject column.
Regards,
Chinmay

Author

Commented:
Hi Chinmay

Thanks for the explanation on this one, in a bid to try and recycle some infomation back I found this thread very useful which gave me what I needed, following on from the solution you gave me.

http://www.go4answers.com/Example/retrieve-selected-child-parent-item-120064.aspx

:-)


Chinmay PatelChief Technology Ninja
Distinguished Expert 2018

Commented:
Oh these are screen scrapping sites. They steal information from legit sites. The article you are looking at is ripped from Social.msdn.com :)
Anyways... Thanks this will come handy someday.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial