Wednesday, October 17, 2007

Setting a Lookup Value

This code snippet should be copied into the form onLoad event code so that it is available as a global function for the form.

//--------------------------------------------------------------------------------------------
setlookupValue = function( idValue, textValue, entityName ) {
//---------------------------------------------------------------------------------------------
var lookupItem = new Object();
var lookupData = new Array();
lookupItem.id = idValue;
lookupItem.name = textValue;
lookupItem.typename = entityName;
lookupData[0] = lookupItem;
return( lookupData );
};


It can then be called from within the form (replace the bits in square brackets[ ]):
var f = crmForm.all;
f.[fieldSchemaName].DataValue = setlookupValue( [idValue], [lookupText], [entitySchemaName] );

No comments: