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

Notifications

Announcements

No record found.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans