Wednesday, September 12, 2012

CRM 2011-javascript to make another field empty between two fields

function MakeEmpty(field1,field2)
{
var firstfield=Xrm.Page.data.entity.attributes.get(field1);
if(firstfield!=null)
{
var firstfieldvalue=firstfield.getValue();
if(firstfieldvalue!=null)
{
var secondfield=Xrm.Page.data.entity.attributes.get(field2);
if(secondfield!=null)
{
var secondfieldvalue=secondfield.setValue(null);
}
}
}
}

Note : call this method onchange event of  the two fields but  pass the field names as comma separated parameter
Field1-Current Field
Field2-Field to be empty

No comments:

Post a Comment