Monday, January 19, 2009

Read and assign Owner attribute value to another owner attribute.

When it come to copying Owner attribute value aand assinging it to another owner attribute in CRM Form, its not just like a simple textbox value (where u can directly assing .DataValue property to the another attribute)

Have a look at the below code, which Reads and assign Owner attribute value to another owner attribute on CRM Form.

// Get hold of Owner and default it to the Commission Owner 1
var oOwner = new Array();
oOwner = null;

oOwner = crmForm.all.ownerid.DataValue;

//Create an array to set as the DataValue for the Owner control.
var lookupData = new Array();
var oCommissionOwnerOne = new Object();

if (oOwner[0] != null)
// Set the id, typename, and name properties to the object. = oOwner[0].id;
oCommissionOwnerOne.typename = oOwner[0].typename; = oOwner[0].name;

// Add the object to the array.
lookupData[0] = oCommissionOwnerOne;

// Set the value of the lookup field to the value of the array.
crmForm.all.new_commissionmarginownerone.DataValue = lookupData;

Happy copying (and Coding too) !!!!

1 comment:

Anonymous said...

Thanks for the sharing of such information.This is a great stuff of reading. I will pass it on to our audience. Thanking you,CRM Services