Hide Create Security Incident UI Action if it has been already created from the current incident

anas_m
Tera Contributor

Hi ServiceNow Community,

 

I'm trying to hide "Create Security Incident" UI Action if it has been already created before from the current incident. For information the record of the Security Incident is visible in the Related list. Could you please help ?

 

Many Thanks

1 ACCEPTED SOLUTION

John Dahl
Tera Guru

That should be fairly easy to do. First, check the related list to determine how the relationship is established. Then create a script include with a function that checks that relationship where the parent is the current record. make sure the SI function returns the value you expect.

Assuming that the records are on the security_incident table and are related through a parent field, the SI function might look something like:


function hasSecurityIncidents( current ){

  return new global.GlideQuery.parse( 'security_incident', 'parent=' + current.getUniqueValue() ).count() > 0;

}

 

while the condition field on the UI Action might look something like:

 

!(new MyScriptInclude().hasSecurityIncidents( current ));

 

View solution in original post

1 REPLY 1

John Dahl
Tera Guru

That should be fairly easy to do. First, check the related list to determine how the relationship is established. Then create a script include with a function that checks that relationship where the parent is the current record. make sure the SI function returns the value you expect.

Assuming that the records are on the security_incident table and are related through a parent field, the SI function might look something like:


function hasSecurityIncidents( current ){

  return new global.GlideQuery.parse( 'security_incident', 'parent=' + current.getUniqueValue() ).count() > 0;

}

 

while the condition field on the UI Action might look something like:

 

!(new MyScriptInclude().hasSecurityIncidents( current ));