The CreatorCon Call for Content is officially open! Get started here.

Email notification --> subject is not displaying properly (Code is displaying as it is)

SatheeshKumar
Kilo Sage

Hi,

I am trying send notifications based on user language . so i used the below code to change the subject of the email depending on the user language.

But what the problem now was , the subject is working fine for some notifications and not working fine some notifications. when i trigger the event manually everything is fine but when it is triggered automatically it throws the below error. Anyone suggest me to overcome this issue,

find_real_file.png

var getSub = subject_value.toString().split("${");

  gs.log(getSub.toString());

  var getEle = [] ;

  for(var i=0;i<getSub.length ;i++)

  {

  if(getSub[i].indexOf('}')>=0)

  getEle.push(getSub[i].toString().split("}")[0]);

  }

  getEle = getEle.toString().split(',');

  var newElevalues = [] ;

  var finalSubject = objSubjectBody[0] ;

  for(var p=0;p<getEle.length;p++)

  {

  if(getEle[p] !="event.parm1" && getEle[p] !="event.parm2")

  { newElevalues.push(current[getEle[p]]);

  if(getEle[p].toString().split('\.').length > 1)    

  {

  var getDotWalked ="" ;

  if(getEle[p].toString().split('\.').length == 2)

  {

  getDotWalked = current[getEle[p].toString().split("\.")[0]][getEle[p].toString().split("\.")[1]].getDisplayValue();

  }

  if(getEle[p].toString().split('\.').length == 3)

  {

  getDotWalked = current[getEle[p].toString().split("\.")[0]][getEle[p].toString().split("\.")[1]][getEle[p].toString().split("\.")[2]].getDisplayValue();

  }

          finalSubject =finalSubject.replace("${"+getEle[p]+"}",getDotWalked );

  }

  else

  {

  finalSubject =finalSubject.replace("${"+getEle[p]+"}",current[getEle[p]].getDisplayValue());

  }

  }

   

  else{

  if(getEle[p] =="event.parm1" )

  {newElevalues.push(current[getEle[p]]);

  finalSubject =finalSubject.replace("${"+getEle[p]+"}",event.parm1);}

  else

  {newElevalues.push(current[getEle[p]]);

  finalSubject =finalSubject.replace("${"+getEle[p]+"}",event.parm2);}

  }

  }

  email.setSubject(finalSubject);

Thanks,

satheesh

6 REPLIES 6

Jack
Tera Guru

Hi Satheesh,



I have an idea and hope it will be useful for you:


  1. Assume, you have created the notification under "sysapproval_approver" table
  2. In the subject, you have the script used the dot working ${sysapproval.cat_item.xxxx} and ${sysapproval.request.xxxx} ==> I think error here, because the "sysapproval_approver" table will reference to multi-table that extended from "task" table. I'm not sure these table have "cat_item" or "request" field (invalid field in some case).

You can try and verify the table of "approval for" field.



Hope it will help for you!


amlanpal
Kilo Sage

Hi Satheesh,



Please make sure that the Notification is configured in the Approvals (sysapproval_approver) table. If not, then the Subject line won't make any sense as you are fetching as sysapproval.xxx.



I hope this helps.Please mark correct/helpful based on impact


Hi satz ,



May I know the status of this thread?


tarleen
Tera Contributor

Hi ,


The subject line written by you indicates that you have created notification for table - sysapproval_approver.


I would suggest you to try once by replacing the subject line by -


REMINDER: Action Required: ${sysapproval.request_item.cat_item} was requested for ${sysapproval.request.requested_for}



Regards,


Tarleen