How to Send parameter to Notification without hard coding

Deva3
Tera Contributor

Here My requirement is based on variable values it should trigger a event and send the recipient 
Written Business rule on RITM  and sending parm1 and parm2

This is here its hard code , can anyone please help me with this without hard code how we can achieve 

code 

(function executeRule(current, previous /*null when async*/) {
 
// Add your code here
var subapp = current.variables.sub_application;
var Recipient ="";
if(subapp=="Global"){
Recipient="abcd1@xyz.com";
}
else if(subapp=="Safety"){
Recipient="abcd2@xyz.com";
}
else if(subapp=="Portal"){
Recipient="abcd3@xyz,com";
}
 
gs.eventQueue("xyz.search.platform.application",current,Recipient,subapp);
})(current, previous);
5 REPLIES 5

_Gaurav
Kilo Sage

Hi @Deva3 
What hardcoded value you want to remove from the above code?
If the value of subapp that is Global, Safety and Portal then you can create a system property and use the system property here in the above code like:

if(subapp==gs.getProperty('property_name')){
Recipient="abcd1@xyz.com";
}

Please hit helpful if this resolves your query
Thanks!



Deva3
Tera Contributor

I want to Remove user emails as it is hard coded , So any alternate way please let me know

Hi @Deva3 
So do you have any field present on the form level or how you're picking the recipient email ID?
However, if the user is predefined then you can add the email id in the system property and use it.

Syte m property>value>abc.com

if(subapp==gs.getProperty('property_name')){
Recipient=gs.getProperty('system_property_name');
}




Siddhesh Gawade
Mega Sage
Mega Sage

Hello @Deva3 ,

 

If the email id is dependent on some user field on record or the user who initiated the session. then you can use below methods.

//this will give you mail address of current user who initiated the session.
var gr = gs.getUser();
gs.info(gr.email);

// this will give email address from user field of record.
current.field_name.email

 

If the email address is not depedent of any field or user who intiated or any other relation and it is a indepedent value, Then you can create system properties as follow:

1. Navigate to sys_properties.LIST

2. Create New, and add email address in value field as follow and save the reocord.

SiddheshGawade_0-1706884736355.png

3. In your business rule, use below method to call the property and get the email address.

Recipient = gs.getProperty('email_address')   // use your property Name

 

Kindly mark the answer ✔️Correct or Helpful ✔️If it addresses your concern.


Regards,

Siddhesh