Enable/Disable a button named "integration" on incident form based on confditions

Sravanthi Dhara
Tera Contributor

Hi All,

 

I have a requirement to hide a button called "integration" on incident form for the below mentioned conditions.

1. Assignment group should "WINTEL TEAM".

2. Business service should be "in contact type".

3. There is a related list on the incident form where integration tickets records available. I need to filter the incident ticket if it is already integrated. If it is integrated already, then button should not be visible. If it is not integrated then, "integration" button should be visible on the incident form. 

 

I have been trying to achieve it via business rule. But can you help me how to enable or disable the button after filtering the related lilist records. Is there any function available to achieve it. Please help

2 ACCEPTED SOLUTIONS

Anil Lande
Kilo Patron

Hi,

You need to use condition field on UI action to manage visibility.

For related list condition your need to query the related list table and return true/false.

Your condition would be like below:

current.assignmemt_group == 'sys_id of WINTEL' && current.u_business_service == 'sys_id of Service' && new scriptIncludeName().functionName(current)

 

your script include function would look like below:

functionName: function(current){
var integrationGr = new Gliderecord('integration_table_name');
integrationGr.addQuery('field_name_having_incident_reference',current.sys_id);
integrationGr.query();
return !integrationGr.hasNext();
}

 

Replace custom field and table names in above script as per your configuration

https://www.servicenow.com/community/developer-forum/how-to-call-script-include-in-ui-action-conditi...

https://www.servicenow.com/community/developer-blog/use-script-include-in-a-condition-field/ba-p/227...

 

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

View solution in original post

Hi @Sravanthi Dhara, You need to correct line 5 in your script include from  Gliderecord to GlideRecord

Regards,

Sunil

 

View solution in original post

4 REPLIES 4

Anil Lande
Kilo Patron

Hi,

You need to use condition field on UI action to manage visibility.

For related list condition your need to query the related list table and return true/false.

Your condition would be like below:

current.assignmemt_group == 'sys_id of WINTEL' && current.u_business_service == 'sys_id of Service' && new scriptIncludeName().functionName(current)

 

your script include function would look like below:

functionName: function(current){
var integrationGr = new Gliderecord('integration_table_name');
integrationGr.addQuery('field_name_having_incident_reference',current.sys_id);
integrationGr.query();
return !integrationGr.hasNext();
}

 

Replace custom field and table names in above script as per your configuration

https://www.servicenow.com/community/developer-forum/how-to-call-script-include-in-ui-action-conditi...

https://www.servicenow.com/community/developer-blog/use-script-include-in-a-condition-field/ba-p/227...

 

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

Hi Anil, 

 

Thanks for the update.

 

I have tried with the solution which you have provided. But, still I can able to see the "Integration" button on the incident form. Please check the below snap If I am doing anything wrong.

 

Hi @Sravanthi Dhara, You need to correct line 5 in your script include from  Gliderecord to GlideRecord

Regards,

Sunil

 

Sravanthi Dhara
Tera Contributor

Hi Anil,

 

I have rectified the issue. In my glide record method, "r" was small case(Gliderecord). Hence that is the reason it was not working properly. Now it is working as expected. Thanks for the help. Very much appreciated😊.