I had a previous post about this and had this working but it now will not work completely even though I have not made any changes to the script. I have a table script on the comm_link table to update another field on insert and update, and everything works fine. This same script, adapted for communication fields, does not work on update, although insert works fine.
Original Post - community.sagecrm.com/.../24752.aspx
Working Comm_link Script
function PostInsertRecord()
{
// Handle post insert record actions here
var intLinkRecordID = Values('cmli_commlinkid');
//ErrorStr = "CommLinkID:"+Values('cmli_commlinkid');
var FirstLinkRecord = CRM.FindRecord("comm_link","cmli_commlinkid="+ Values('cmli_commlinkid'));
strSQL2 = "UPDATE COMM_LINK SET CMLI_COMM_PERSONID="+FirstLinkRecord.cmli_newperson+" where cmli_commlinkid="+ Values('cmli_commlinkid');
CRM.ExecSql(strSQL2);
}
function UpdateRecord()
{
var FirstLinkRecord = CRM.FindRecord("comm_link","cmli_comm_communicationid="+CRM.GetContextInfo('communication','comm_communicationid'));
strSQL2 = "UPDATE COMM_LINK SET CMLI_COMM_PERSONID="+FirstLinkRecord.cmli_newperson+" where cmli_comm_communicationid="+CRM.GetContextInfo('communication','comm_communicationid');
CRM.ExecSql(strSQL2);
}