Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

we want to hide form action of create incident from form context menu of SIR form

Siva_Prasad
Tera Contributor

we want to hide form action of create incident from form context menu of SIR form after one incident is created from the security incident ?Is there any solution for this?

 

18 REPLIES 18

var Check_incident_exists = Class.create();
Check_incident_exists.prototype = {
    initialize: function() {
    },
    incidentExists: function(securityIncidentSysId) {
        var inc = new GlideRecord('sn_si_incident'); // Check in the sn_si_incident table
        inc.addQuery('parent', securityIncidentSysId);
        inc.query();
     
       if (inc.hasNext()) {
            return false; // if related incident exists
        }
            return true; // if no related incident exists
    },
   
    type: 'Check_incident_exists'
};
I have created this script inlcude and called it from ui action but it is not working 
Is there any error in the script?
 

@Siva_Prasad 

if you are populating INC in parent field of sn_si_incident then no script include required

current.active == true && new sn_sm.SMConfiguration().hasRole(current, "basic") && current.parent == ''

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Siva_Prasad 

Hope you are doing good.

Did my reply answer your question?

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Ravi Gaurav
Giga Sage
Giga Sage

Hi @Siva_Prasad 

 

If your SIR record directly stores the linked incident reference (like u_related_incident):

// Show only if no related incident exists
return !current.u_related_incident;

 

This is cleaner and more efficient.

--------------------------------------------------------------------------------------------------------------------------


If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!

Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI

 YouTube: https://www.youtube.com/@learnservicenowwithravi
 LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/