Hide Self-Service View for Incident

Jeck Manalo
Tera Guru

Hello Everyone,

 

Is there a way to hide the self-service view for Incident ?

 

I saw this Hide Incident self service view - ServiceNow Community - this work but unfortunately it will also hide all self-service other form section like request item demand etc.

 

Is there a way that I can hide self-service for Incident only ?

JeckManalo_0-1748917617086.png

 

I am done hiding self-service for incident in application module.

1 ACCEPTED SOLUTION

Chaitanya ILCR
Kilo Patron

Hi @Jeck Manalo ,

try this onload client script

function onLoad() {
    //Type appropriate comment here, and begin script below
    if (g_form.getViewName() == 'ess')
        switchView('', 'incident', '')
}

ChaitanyaILCR_0-1748930743367.png

extend this script if required 

example if you want to exclude admin users use g_user.hasRole() etc

function onLoad() {
    //Type appropriate comment here, and begin script below
    if (g_form.getViewName() == 'ess' && !g_user.hasRole('admin'))
        switchView('', 'incident', '')
}

 

I have tried the view rule to route from ess view to default only when form is opened in ess view but it's not working as expected 

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya

 

View solution in original post

12 REPLIES 12

Actually about workaround i think that already as an option to redirect them into default view when they are selecting self service view.

 

Using BR but I don't know if I written it correctly.

 

Table: UI View

When to run: before insert/update

 

code

 

(function executeRule(current, previous /*null when async*/) {
    // Check if the user has the ITIL role
    if (gs.hasRole('itil')) {
        // Hide the Self Service view for the Incident table
        if (current.getTableName() == 'incident' && current.view == 'Self Service') {
            current.setAbortAction(true);
        }
    }
})(current, previous);

 

 

Chaitanya ILCR
Kilo Patron

Hi @Jeck Manalo ,

try this onload client script

function onLoad() {
    //Type appropriate comment here, and begin script below
    if (g_form.getViewName() == 'ess')
        switchView('', 'incident', '')
}

ChaitanyaILCR_0-1748930743367.png

extend this script if required 

example if you want to exclude admin users use g_user.hasRole() etc

function onLoad() {
    //Type appropriate comment here, and begin script below
    if (g_form.getViewName() == 'ess' && !g_user.hasRole('admin'))
        switchView('', 'incident', '')
}

 

I have tried the view rule to route from ess view to default only when form is opened in ess view but it's not working as expected 

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya

 

Thank you this is working.