Add default option

shaik23
Tera Expert

Hello experts,

Add Business rule to the “Service” cmdb table. This will run on query, and if the 'operational_status' field is not included in the query, add operational_status = operational.

 

Any help appreciated.

 

Thanks.

8 REPLIES 8

psphanindrakuma
Tera Guru
Tera Guru

@shaik23 

 

 

// add this to excisting conditions

if(!(current.getEncodedQuery().includes('operational_status')){
current.addQuery('operational_status' , 'operational');

 

 

Please try above code. 

 

Please mark my answer as correct and helpful if it solves your issue

 

Thanks,

Phanindra.

 

 

@psphanindrakuma  can you please check my previous script. if it is correct or not ?

 

if (current && !gs.nil(current.operational_status)) {
// current.addQuery('operational_status', 'Operational');
// gs.info("Added operational_status=Operational to the query.");
// } else {
// gs.info("Skipped adding operational_status to the query. Current or operational_status is null.");
// }

@psphanindrakuma I have used you script the in the list it doesn't show any records Screenshot (137).png

@shaik23 

if ( !gs.nil(current.operational_status)) {

current.addQuery('operational_status', 'Operational');

}