Advertisements
Home > CRM 2011, JScript > Get Parent Record Id from child record form + crm 2011

Get Parent Record Id from child record form + crm 2011

Hi,

When you create/update a record form Associated view of Parent record, below is the JScript to “Get Parent Record Id from child record form”.

//Get Parent Record Id
var parentRecordID = GetUrlParameter();
parentRecordID = parentRecordID .substring(3, parentRecordID .length – 3);

function GetUrlParameter() {
var id = “”;
var name = “_CreateFromId”;

name = name.replace(/[\[]/, “\\\[“).replace(/[\]]/, “\\\]”);
var regexS = “[\\?&]” + name + “=([^&#]*)”;
var regex = new RegExp(regexS);
var results = regex.exec(window.location.href);

if (results == null) {

} else {
id = results[1];
}
return id;
}

How do i use this?

In child record FormLoad, Call this method

  •     var parentRecordID = GetUrlParameter();
  •     parentRecordID = parentRecordID .substring(3, parentRecordID .length – 3);
  • alert(“My Parent Record Id – “+parentRecordID  );

Hope it helps 🙂

Advertisements
  1. Chris
    April 25, 2013 at 7:53 PM

    or you could use window.top.opener.parent.Xrm.Page.data.entity.getId() 🙂

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: