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

This should work all fine

 

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

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 Sanjiv,

 

I have tried this now again, But still the assignees is getting removed now.

 

Can u pls suggest me how can i achieve my other condition, Assigneed should be removed when the ticket is updated for assignement groups which are not used in property.

I am trying to writhe an else condition but its not workng..can u pls correct my code

 

find_real_file.png

 

I wont prefer looping through each item. It is not an efficient code. I would prefer below code. Also make sure, this is an onBefore business rule

var dss = gs.getProperty('glide.dss.groups');

var grp = dss.split(',');


var asgroup = current.getValue('assignment_group');

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

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

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

}

 

But if you still want it, you can use below code

 

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

// Add your code here

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

var gr = new GlideRecord('incident');
gr.addEncodedQuery('sys_id='+current.sys_id+'^assignment_groupIN'+dss);
gr.query();


if(gr.next()){
current.state = 3;
}
else

{
current.state = 3;
current.assigned_to = '';
}


})(current, previous);


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