How to call system property in a business rule

naveenmyana
Giga Expert

Hi Everyone,

I have a requirement to clear out assignee field in incidents/requests when it is updated by caller of that ticket and this feature should exclude some groups like for particular assignement groups in that tickets say xyz and abc and bcd and...like this 40 groups are there.

When these are assignment groups the assignee should not be removed when the ticket is updated by caller and for rest of the assignment groups the assignee of that ticket should be removed when the ticket is update by caller.

I have created a system property and stored all the CI's in that property and trying to call it in the BR, but it is not working.

 

var dss = gs.getProperty('glide.dss.groups');
var asgroup = current.assignment_group.getDisplayValue();


if( dss == asgroup){
gs.log('inside if');
current.state = 3; //state to assigned

}
else
gs.log('inside else');
current.state = 3;
current.assigned_to = '' ";
 

7 REPLIES 7

SanjivMeher
Kilo Patron
Kilo Patron

Try this

 

var dss = gs.getProperty('glide.dss.groups');
var asgroup = current.assignment_group.getDisplayValue();


if( dss.indexOf(asgroup)>-1){ 
gs.log('inside if');
current.state = 3; //state to assigned
}
else 

{
gs.log('inside else');
current.state = 3;
current.assigned_to = '' ";

}
 


Please mark this response as correct or helpful if it assisted you with your question.

Hi Sanjiv,

 

Tried this one, But it is not going inside the if loop. Any other suggestions

Can you use this and let me know what message you get

var dss = gs.getProperty('glide.dss.groups');
var asgroup = current.assignment_group.getDisplayValue();

gs.addInfoMessage('dss ------'+dss+'-----------assignment------'+asgroup  );

if( dss.indexOf(asgroup)>-1){ 
gs.log('inside if');
current.state = 3; //state to assigned
}
else 

{
gs.log('inside else');
current.state = 3;
current.assigned_to = '' ";

}


Please mark this response as correct or helpful if it assisted you with your question.

HI Sanjeev,

 

Yes please refer below screenshot, it displayed all the sys id's once ticket is updated...

I have tried the below code and is working fine for dss groups the assigneed is not getting removed as expected, but I am unable to write another condition here.

 

which is to remove assignee from the ticket when it is updated for groups which are not dss

 

My code here:

(function executeRule(current, previous /*null when async*/) {

// Add your code here

var grp1 = [];
var dss = gs.getProperty('glide.dss.groups');
grp1 =dss.split(',');

for(var k=0; k < grp1.length; k++)
{
var gr = new GlideRecord('incident');
gr.addQuery('sys_id',current.sys_id);
gr.addQuery('assignment_group',grp1[k]);
gr.query();
if(gr.next()){
gr.state = 3;
gr.update();
}
/*else
current.state = 3;
current.assigned_to = '';*/

}


})(current, previous);

 could you pls let me kknow wr should i add the else code to get this code work for my other condition

 

find_real_file.png