Advertisements

Archive

Archive for August 12, 2011

Get Parent Record Id from child record form + crm 2011

August 12, 2011 1 comment

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