Comma separated value of system properties is not working.

rajesh29
Tera Expert

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

7 REPLIES 7

@Hitoshi Ozawa 

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.

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');
}

 

Aanshul Maru1
Tera Contributor

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