get view name from list control omit new condition script

ggg
Giga Guru

I need to omit the NEW button from a List based on the view.

In one view I want the NEW button to display, in the other I do not.

in a Client Script you can use getView(); that does not work in this condition script.

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

you can use the approach of ACL;

open create ACL and in script section have this

answer = determineVisible();

function determineVisible(){  

var viewName = '';

var map = gs.action.getGlideURI().getMap();

if (map.get('sysparm_view') != null) {

 viewName= map.get('sysparm_view').toString();

if(viewName == 'self_service')

return true; // show new button

else if(viewName == 'xyz')

return false; // hide new button 

}

}

Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur

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

View solution in original post

10 REPLIES 10

Can you post a new question for this and tag me

as this is very old post it becomes difficult to track

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

ggg
Giga Guru

this works well.

you UNCHECK the Omit New Button checkbox

and

then add your script.

thanks!

Hi,

Can you mark answer as correct and helpful.

Regards

Ankur

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

Hi,

Can you mark my answer as correct and helpful.

Regards

Ankur

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

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

Can you mark my answer as correct and helpful.

Regards

Ankur

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