Count Affected CIs on incident form

Sagar_pawar
Tera Contributor

Hello All,

can anyone please guide me how to count affected ci on incident form and display when form load?

Thank You.

1 ACCEPTED SOLUTION

Saurav11
Kilo Patron
Kilo Patron

Hello,

 

Please do the below:-

 

Write a display BR on incident table with the below code:-

 

Saurav11_0-1671174544869.png

 

 

(function executeRule(current, previous /*null when async*/) {
var rec = new GlideRecord('task_ci');
   rec.addQuery('task', current.sys_id); 
   rec.query();
   if(rec.next()){
     g_scratchpad.count=rec.getRowCount();
   
}
})(current, previous);

 

Then write a onload client script with below code:-

 

Now if you want to show it as a message on load use below:-

 

function onLoad() {
   //Type appropriate comment here, and begin script below
   var count=g_scratchpad.count;
	g_form.addInfoMessage(count);
}

 

Now if you want to set it on a field on load use below:-

 

function onLoad() {
   //Type appropriate comment here, and begin script below
   var count=g_scratchpad.count;
	g_form.setValue('fieldname',count);
}

 

Please mark my answer as correct based on Impact. 

View solution in original post

6 REPLIES 6

Hello, @reshmapatil what will be the condition of the data policy? our requirement is when we add ACIs the particular field will be visible.

 

Hi @Sagar_pawar ,

 

For now, I can only think of having one temporary field which will be updated through ACL and in Data policy we can check that field value and set our actions.

 

Regards,

Reshma

**Please mark my answer correct or helpful based on the impact**