problem in window.openr()
-
Saturday, May 05, 2012 7:05 PM
hi
i work with crm4, when i use this code in onloade of second form, fields doesnt fill with primform fields
if (crmForm.FormType == 1)
{
// Check to confirm that the window.opener is present.
if (window.opener)
{
// Get the values of the parent form.
var oParentCrmForm = window.opener.document.all.crmForm;
// Check that you obtained the values of the parent form and
// that the parent form is an account.
if (oParentCrmForm && oParentCrmForm.ObjectTypeCode == 1)
{
// Get the name of the account.
var sAccountName = oParentCrmForm.all.name.DataValue;
// Set the default value of the task subject to
// include a reference to the related account.
crmForm.all.parent_name.DataValue = "account: " + sAccountName;
}
}
}
All Replies
-
Saturday, May 05, 2012 10:16 PM
If it's just the Account Name you need, you could just get the name from the Regarding Lookup reference on the Task:
if (crmForm.FormType == 1) { var regardingObject = crmForm.all.regardingobjectid.DataValue; var regardingType = regardingObject[0].typename; // Check to confirm that it is regarding an account if (regardingType == "account") { // Get the name of the account. var sAccountName = regardingObject[0].name; // Set the default value of the task subject to // include a reference to the related account. crmForm.all.parent_name.DataValue = "account: " + sAccountName; } }Here's more information about getting the lookup data:
http://www.magnetism.co.nz/blog/nathan/10-05-28/Retrieving_Data_from_Lookup_Fields.aspxHope that helps!