locked
Show Lookup field's additional attributes RRS feed

  • Question

  • Hi All,

    I have a lookup field on my custom entity's form that point to the Contact entity.  On the custom entity's form, I want to display the additional fields that are on the contact form; one of the fields on the Contact form is a sub-grid that has a list of items.  What is the best way to do this?


    • Edited by Mego123 Tuesday, May 21, 2013 4:50 PM
    Tuesday, May 21, 2013 4:35 PM

Answers

  • Hi,

    If you want to show the parent entity's fields on the child, you could create those fields on the child and use mapping to map the fields from parent to child. If you want to show a sub grid from the parent you could use IFrame.



    My Weblog | My Website

    Tuesday, May 21, 2013 5:03 PM
    Moderator
  • In addition to Payman's answer - to display additional fields you could set the additional fields using a workflow or if you are inclined to use code a plugin or JavaScript could also populate the values.

    JavaScript sample:

    function Contact_OnChange() {
    	var contact = new Array();
    	//verfiy field name is correct
    	contact = Xrm.Page.getAttribute("new_contactid").getValue();
    
    	if (contact == null) {
    		return;
    	}
    
    	var serverUrl = Xrm.Page.context.getClientUrl();
    	var oDataSelect = serverUrl + "/XRMServices/2011/OrganizationData.svc/ContactSet?$select=MobilePhone&$filter=ContactId eq guid'" + contact[0].id + "'";
    
    	var retrieveReq = new XMLHttpRequest();
    	retrieveReq.open("GET", oDataSelect, false);
    	retrieveReq.setRequestHeader("Accept", "application/json");
    	retrieveReq.setRequestHeader("Content-Type", "application/json;charset=utf-8");
    	retrieveReq.onreadystatechange = function () {
    		GetContactData(this);
    	};
    	retrieveReq.send();
    }
    
    function GetContactData(retrieveReq) {
    	if (retrieveReq.readyState == 4) {
    		if (retrieveReq.status == 200) {
    			var retrieved = JSON.parse(retrieveReq.responseText).d;
    			Xrm.Page.getAttribute("new_mobilephone").setValue(retrieved.results[0].MobilePhone);
    		}
    	}
    }
    


    Jason Lattimer
    My Blog -  Follow me on Twitter -  LinkedIn

    Tuesday, May 21, 2013 5:06 PM
    Moderator

All replies

  • Hi,

    If you want to show the parent entity's fields on the child, you could create those fields on the child and use mapping to map the fields from parent to child. If you want to show a sub grid from the parent you could use IFrame.



    My Weblog | My Website

    Tuesday, May 21, 2013 5:03 PM
    Moderator
  • In addition to Payman's answer - to display additional fields you could set the additional fields using a workflow or if you are inclined to use code a plugin or JavaScript could also populate the values.

    JavaScript sample:

    function Contact_OnChange() {
    	var contact = new Array();
    	//verfiy field name is correct
    	contact = Xrm.Page.getAttribute("new_contactid").getValue();
    
    	if (contact == null) {
    		return;
    	}
    
    	var serverUrl = Xrm.Page.context.getClientUrl();
    	var oDataSelect = serverUrl + "/XRMServices/2011/OrganizationData.svc/ContactSet?$select=MobilePhone&$filter=ContactId eq guid'" + contact[0].id + "'";
    
    	var retrieveReq = new XMLHttpRequest();
    	retrieveReq.open("GET", oDataSelect, false);
    	retrieveReq.setRequestHeader("Accept", "application/json");
    	retrieveReq.setRequestHeader("Content-Type", "application/json;charset=utf-8");
    	retrieveReq.onreadystatechange = function () {
    		GetContactData(this);
    	};
    	retrieveReq.send();
    }
    
    function GetContactData(retrieveReq) {
    	if (retrieveReq.readyState == 4) {
    		if (retrieveReq.status == 200) {
    			var retrieved = JSON.parse(retrieveReq.responseText).d;
    			Xrm.Page.getAttribute("new_mobilephone").setValue(retrieved.results[0].MobilePhone);
    		}
    	}
    }
    


    Jason Lattimer
    My Blog -  Follow me on Twitter -  LinkedIn

    Tuesday, May 21, 2013 5:06 PM
    Moderator