Comma separated value of system properties is not working.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2022 10:08 AM
Hi,
I have added the approver email id in system property value. I have configured the approvers by using system properties in some catalog items. if value is having one approver it working properly.
when I add more than one email id's with Comma seperated it's not working. how to get two approvers by adding value in system property?
script Include:
if(r == 'test_BSBS')
a.push(this.getApproverSysID('hbw.approvers.bs.test_bsbs'));
return a;
},
Thanks,
Rajesh Bandila
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-12-2022 03:47 AM
Thank you!
I have tried by adding the above code, but it's not working. please refer the below code for reference.
var approverUtil = Class.create();
approverUtil.prototype = {
initialize: function() {
},
gs_hardware: function(obj) {
if (obj.org != "GS")
return;
gs.info("JSON "+ new JSON().encode(obj));
var r = obj.gsnow;
var a = [];
if(r == 'backup')
a.push(this.getApproverSysID('hdw.approvers.gs.backup'));
if(r == 'UPS')
a.push(this.getApproverSysID('hdw.approvers.gs.UPS'));
return a.join(',');
//return a;
},
Thanks In advance.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-12-2022 08:41 PM
The problem probably isn't with this part of the script but with the script that's calling this script to set the approvers. Would need to see the script that's setting approvers.
If the method "getApproverSysID()" is returning a csv string of approvers, pushing value into an array probably isn't necessary. That is, just return value returned by .getApproverSysID()" method.
if(r == 'backup') {
return this.getApproverSysID('hdw.approvers.gs.backup');
} else if(r == 'UPS') {
return this.getApproverSysID('hdw.approvers.gs.UPS');
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-12-2022 04:23 AM
Hi @Rajesh
Let's assume your property name is 'approver.list' which contains email IDs separated by commas and you need to get the approvers.
Wherever you want the approvers you can use below mentioned code:
setApprovers();
function setApprovers() {
var approvers = [];
var approverEmailList = gs.getProperty('approver.list');
var getApprovers('sys_user');
getApprovers.addEncodedQuery('emailIN' + approverEmailList);
getApprovers.query();
while (getApprovers.next()) {
approvers.push(getApprovers.getValue('sys_id'));
}
return approvers;
}
Please mark my answer as correct if this solves your issues!
If it helped you in any way then please mark helpful!
Thanks and regards,
Aanshul