configure mulitple sys_ids in sys_properties

Sweta24
Tera Contributor

Hi All,

 

we are using multiple sys_ids in businessrules with  'or' codintion  like if(current.cat_item = 'sys_id1' ||  current.cat_item = 'sys_id2' ||  current.cat_item = 'sys_id3' || current.cat_item = 'sys_id4') 

 

we want to do  through 'sys_properties'  , i tried with comma seperated sys_ids  but not working .

kindly help me on this to call these sys_ids in one property 

4 REPLIES 4

Emmanuel Jay Mu
Tera Contributor

Hi,

 

You can use comma separated sysIds in your properties, try using indexOf.
for example

gs.getProperty('cat_item_ids').indexOf(current.cat_item) > -1 // returns true sys_id matches from properties

 

shloke04
Kilo Patron

Hi,

You can store multiple sys id in form of an JSON object in your system property as shown below as an example:

{"Label1":"SysID1",
"Label2":"SysID2",
"Label3":"SysID3",
"Label4":"SysID4"}

Now once all your sys id are stored in 1 System Property in form of an JSON as shown above in the example, then retrieve it in your Business Rule and parse the JSON object to retrieve the values for each label as you need . For example sample reference code below which you can use in your BR:

var props = gs.getProperty('Property Name here');
var hashMap = JSON.parse(props); // Add global prefix if in scope
var answer = hashMap[Label1];

Similarly if you need other values of Label like for example the sys id corresponding to Label 2 then replace answer as below:
var answer = hashMap[Label2];

 

Print the answer or perform the logic you need based on your answer variable.

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Sweta24
Tera Contributor

So can we use like below?

if(hashMap[Label1] || hashMap[Label2] || hashMap[Label3] ||  hashMap[Label4] )

 

kindly clarify

Yes, but you need to first store it in System Properties as I showed you above in sample example.

Once the sys id are stored then you can update your Business Rule as below:

var props = gs.getProperty('Property Name here');
var hashMap = JSON.parse(props); // Add global prefix if in scope
if(hashMap[Label1] || hashMap[Label2] || hashMap[Label3] ||  hashMap[Label4] ){
...Your logic here
}

 

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke