This function should be embeded on the form onLoad and then called by the relevant fields onChange event.
The code for getattribsByLookup and getLookupObject can be found here. They should be included either in the forms onLoad function definitins or ina common .js library
//----------------------------------------------------------
setSystemUserInformation = function() {
//----------------------------------------------------------
//setup some vars to use in constructing the formula and storing the values
var f = crmForm.all;
var entityForList = 'systemuser';
var attribForFilter = 'systemuserid' ;
var idToFetch = f.ownerid.DataValue[0].id+ '' ;
var attribsToReturn = ['mobilephone', 'new_departmentid' ];
//clear the existing values
f.new_departmentid.DataValue = "";
f.new_mobilephone.DataValue="";
var resultXml = getattribsByLookup( entityForList, attribForFilter, idToFetch, attribsToReturn );
if ( resultXml.selectSingleNode("//mobilephone") != null ) {
var tempText = resultXml.selectSingleNode("//mobilephone").text;
f.new_mobilephone.DataValue = tempText;
f.new_mobilephone.ForceSubmit=true;
}
if ( resultXml.selectSingleNode("//new_departmentid") != null ) {
f.new_departmentid.DataValue = getLookupObject( resultXml.selectSingleNode("//new_departmentid").text,
resultXml.selectSingleNode("//new_departmentid/@name").text,
'new_department' ) ;
}
};
No comments:
Post a Comment