MS CRM 2011 - retrieving data from another form(entity) with N:1 relation RRS feed

  • Question

  • So, it is simpe to retrieve data from another form using 1:N look up method. By how is this done to another direction, for N:1?

    I need to get data from that form where the look up is.

    I have a scale form. In that form there is a look up for scale product. The scale form contains a site field and I need to get that site field also to the scale product form. So the site must be same on the both form and must be automa way or another.

    Wednesday, June 26, 2013 8:52 AM

All replies

  • A workflow will do this job.

    Regards Faisal

    Wednesday, June 26, 2013 9:55 AM
  • You could also hit the REST endpoint with JavaScript during the OnChange event for the entity you are selecting.

    Something like (this gets a contact's mobile number and places it into a field)...

    function Contact_OnChange() {
    	var contact = new Array();
    	contact = Xrm.Page.getAttribute("new_contact").getValue();
    	if (contact == null) {
    	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 () {
    function GetContactData(retrieveReq) {
    	if (retrieveReq.readyState == 4) {
    		if (retrieveReq.status == 200) {
    			var retrieved = JSON.parse(retrieveReq.responseText).d;

    Jason Lattimer
    My Blog -  Follow me on Twitter -  LinkedIn

    Wednesday, June 26, 2013 11:32 AM
  • you can get value with REST endpoint that is explained below by Jason Lattimer and Parent Form Client javascript approach.

    var parentForm = (window.parent.opener.Xrm.Page.data == null ? window.parent.opener.parent : window.parent.opener);

    var entityName = parentForm.Xrm.Page.data.entity.getEntityName();

    var value = parentForm.Xrm.Page.data.entity.attributes.get("new_attribute").getValue();

    Ms Crm developer

    Wednesday, June 26, 2013 12:33 PM
  • A workflow will do this job.

    Regards Faisal

    Yes, the problem is that there is a need to edit that scale product immediately, and with workflow it doesn't pop up. So using workflow it will be forgotten which is a problem.
    Thursday, June 27, 2013 9:01 AM