Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

Query between Entities

Posted on by 1,670

i have 2 entities (opportunity and Caution),i need to pass values from opportunity to caution (opportunity subject, value and date)i developed 2 functions :

function GetValues(){ // call this function when the opportunity forms saved
// get opportunity name
	var opportunityID = Xrm.Page.data.entity.getId();
	var opportunityEntityType = Xrm.Page.data.entity.getEntityName();
	var opportunityName = Xrm.Page.data.entity.attributes.get("name").getValue();
			
   
    var extraqs = "new_nameid="+opportunityID+"";
	extraqs += "&new_namename="+opportunityName+"";
	extraqs += "&new_nametype="+opportunityEntityType+"";

 
    var features = "location=no,menubar=no,status=no,toolbar=no";
    var newWindow = window.open("/main.aspx?etn=new_marchepublic&pagetype=entityrecord&extraqs=" +
    encodeURIComponent(extraqs), "_blank", features, false);
    
    newWindow.resizeTo(690, 699);
}

function setCautionValue(context){ // call this function On Load caution entity
	
	
	try{
		var extraqs = context.getQueryStringParameters();
		console.log("params: ",extraqs);
        if(extraqs != null){
			var lookupName = new Object();
			lookup.id = extraqs["new_nameid"];
			lookup.name = extraqs["new_namename"];
			lookup.entityType = extraqs["new_nametype"];
			Xrm.Page.getAttribute("new_name").setValue([{
			id:extraqs["new_nameid"],
			name:extraqs["new_namename"],
			entityType: extraqs["new_nametype"]
			}]);
		}		
			
	}catch(e){
		console.log("error: ",e.message);
	}
	
	
}

new_nameid, new_namename and new_nametype defined in forms property as parameter, but always i show the same problem

7723.Sans-titre.png

*This post is locked for comments

  • Ammar Zaied Profile Picture
    Ammar Zaied 1,670 on at
    RE: Query between Entities

    All values verified.

    yes the second entity "Caution" but the schema name : new_marchepublic

  • Suggested answer
    abhishek_255 Profile Picture
    abhishek_255 1,612 on at
    RE: Query between Entities

    Hi,

    To troubleshoot this issue you may do following

    1. Add javascript alerts in each block of function and check whether the query string parameters are getting populated or not, & lookup exists etc.

    2. If any alert shows "undefined" then that needs to be fixed.

    3.  var newWindow = window.open("/main.aspx?etn=new_marchepublic&pagetype=entityrecord&extraqs=" +

    Is "etn" value pointing correct entity? As you said the second entity is "caution".

    If my response helps you, please mark it as "Verified"

    Best Regards,

    Abhishek

  • nghieppham Profile Picture
    nghieppham 4,755 on at
    RE: Query between Entities

    Hi Ammar.,

    You should open the log file to know the exactly reason.

    Regards,

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,240 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans