web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Query between Entities

(0) ShareShare
ReportReport
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

I have the same question (0)
  • nghieppham Profile Picture
    4,755 on at

    Hi Ammar.,

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

    Regards,

  • Suggested answer
    abhishek_255 Profile Picture
    1,614 on at

    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

  • Ammar Zaied Profile Picture
    1,670 on at

    All values verified.

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

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
Varsha deshpande Profile Picture

Varsha deshpande 5

#2
JS-09031509-0 Profile Picture

JS-09031509-0 3

#3
Ciprian  P Profile Picture

Ciprian P 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans