query through name value pairs in system property and populate the fields on form accordingly

Indira8
Kilo Sage

Hi All,

 

We have a requirement to populate a group field based on the name value pairs in the system property. 

for example: 
The value of the system property is A-groupA;B-GroupB; 

Could you help me with how to query the value, fetch the exact match and populate in the related field. 

The following script is not working , could you please help 

 

var gmatch = gs.getProperty('abc_sysprop');
var gr_ar = gmatch(";");
var sender = email.recipients;
for (var i = 0; i < gr_ar.length; i++) {
for (var j = 0; j < gr_ar.length; j++){
var gr_sysid = gr_ar[i].split(":");
if (gr_sysid[0] == sender) {

current.field_to_be_populated = gr_sysid[1];
current.update();

} else{
current.field_to_be_populated = gs.getProperty('xyz_sysprop');
current.update();

9 REPLIES 9

AnubhavRitolia
Mega Sage
Mega Sage

Hi @Indira8 

 

Can you tell where are you writing this script? Business rule or Background script?

 

Also what value you are populating from property?

 

Also 'A-groupA;B-GroupB; ' is correct format?

 

 

 

Please mark this as correct answer and helpful if it resolved, or mark this helpful if this help you to reach towards solution.

Thanks
Anubhav Ritolia
ServiceNow Rising Star 2023

Hi @AnubhavRitolia ,

We are writing this script in the inbound email.

We are populating the workgroup from the property.

Sorry the correct format is 

email1:group1;email2:group2;

thank you 

Thanks for info.

 

Also can you tell what will happen to email1 and group1 in this case?

 

where is this 'workgroup' field present?

 

Please mark this as correct answer and helpful if it resolved, or mark this helpful if this help you to reach towards solution.

Thanks
Anubhav Ritolia
ServiceNow Rising Star 2023

Hi @AnubhavRitolia 

When workgroup field is present on the incident form.

When mail is received form email 1 then the group 1 should be populated, similar to the other pairs. 

thank you