Wednesday, January 21, 2009

Checking to see if an owner lookup is an account or contact

//In this examples the code block would only run when a contact is selected

var luField = null;
if (crmForm.all.customerid.DataValue != null ) { luField= crmForm.all.customerid.DataValue[0];}

if ((luField != null) && (luField.typename != 'account') ){

            //stuff goes here

}

You could make the initial assignment and if statement use the funky little JS ? operator but I prefer this approach as it is easier to expand etc.

No comments: