When we create a new Company, the routine written in UpdateRecord() function has gets fired. we can check the company id generated in the IF statement to decide whether it should proceed further or not.
We can use the following code to resolve the problem:
function UpdateRecord()
{
var compid = new String(eWare.GetContextInfo(‘Company’,’Comp_CompanyId’));
if(compid==”” || compid==”undefined” || compid==”NULL”) compid =0;
if(compid>0)
{
// Update Acct Mgr on Person record when updated at the Company Record level
var accmgr = comp_primaryuserid;
var compid = eWare.GetContextInfo(‘Company’,’Comp_CompanyId’);
// sql string that will update the person records associated with this company
sql=”UPDATE Person SET Pers_PrimaryUserId=”+accmgr+” WHERE Pers_CompanyId=”+compid
// execute the sql
UpdateQuery = eWare.CreateQueryObj(sql);
UpdateQuery.ExecSql();
}
}