How to update existing case in support.js for tracking cases

Trying to update an existing case after a new communication comes in for a case.

Trying to do this in CreatComm function however it doesn't work and gives error on line ExecSql().

Any help would be appreciated.

function CreateComm(bNotify)

.......

if (bNotify)
{
var commdate = new Date();
mydate = commdate.getVarDate();
comm("Comm_NotifyTime") = mydate;


var StrSql = "SELECT * from Cases where Case_ReferenceID='"+ + mycase + "'";
var casrec;
casrec = eWare.CreateQueryObj(StrSql);
casrec.SelectSql();

var stage = "Active";
var sql = "UPDATE Cases SET case_notifytime = " + mydate + ", case_stage =" + stage + ", WHERE Case_ReferenceID='" + mycase + "'";
var UpdateQuery = eWare.CreateQueryObj(sql);
UpdateQuery.ExecSql();
}

  • 0

    I get the following error.

    jscript error: [SafeCall Exception]: SQL Error Line: 394 Char: 6

    Which is line UpdateQuery.ExecSql();

  • 0

    Hi Allan,

    From your below post we understand that you want to update the case when new communication is created for that case. Here you are trying to update the case record using case referenceid. First you need to get the case reference id value from context area then pass the same in the select query. As you have mentioned you are getting SQL error when you are trying to do the same. We are able to identify the error in your code. Kindly refer our below code for your reference.

    var StrSql = "SELECT * from Cases where Case_ReferenceID='"+mycase+"'";

    casrec = eWare.CreateQueryObj(StrSql);

    casrec.SelectSql();

    if(!casrec.eof)

    {

    sCaserefid = new String(casrec("Case_ReferenceID"))

    if(sCaserefid=="" || sCaserefid=="null" || sCaserefid=="undefined")sCaserefid=""

    }

    var stage = "Active";

    var sql = "UPDATE Cases SET case_notifytime = '"+mydate+"', case_stage ='"+stage+"' WHERE Case_ReferenceID='"+sCaserefid+"'";

    eWare.ExecSQL(sql);

    Hope this helps!

    Regards

    Dinesh

  • 0

    Thanks for your reply. I tried implementing the code and now get the following error with code.

    jscript error: [SafeCall Exception]: Method not available. Line: 408 Char: 8

    Any additional help would be appreciated.

    var StrSql = "SELECT * from Cases where Case_ReferenceID='" + mycase + "'";

    casrec = eWare.CreateQueryObj(StrSql);

    casrec.SelectSql();

    if (!casrec.eof)

    {

    sCaserefid = new String(casrec("Case_ReferenceID"))

    if (sCaserefid == "" || sCaserefid == "null" || sCaserefid == "undefined") sCaserefid = ""

    }

    var stage = "Active";

    var sql = "UPDATE Cases SET case_notifytime = '" + mydate + "', case_stage ='" + stage + "' WHERE Case_ReferenceID='" + sCaserefid + "'";

    jscript error: [SafeCall Exception]: Method not available. Line: 408 Char: 8

    eWare.ExecSQL(sql);