Get sysparm value from URL in a list control

Goran WitchDoc
ServiceNow Employee
ServiceNow Employee

I have a list control for that I want to customize so if a specific sysparm(sysparm_nonew) appears in the url, I want to hide the new button.

But I can't find how get get the sysparm_nonew from the url. I tried "gs.action.getGlideURI().getMap().get('sysparm_nonew')" but will only return null no matter if I got sysparm_nonew=true eller not in the URL.

Any ideas?

//Göran

23 REPLIES 23

Any ideas ctomasi, pradeepksharma, abhinay, snowdev ?



//Göran


swati38
Tera Expert

Hi Goran,



How about this(client script)


var gURL = new GlideURL();


  gURL.setFromCurrent();


  var triggerConflictDetection = gURL.getParam("sysparm_userpref_module");// you can use your required   sysparm



Regards,


Swati


Well, it's server side script and I need to put it in the list control field "omit new condition".



//Göran


Hello Göran,



I actually found an OOB List Control record in place for User Role [sys_user_has_role] which has an "omit new condition" which does similar thing by hiding New button given a specific view parameter.



Omit new condition:


RP.getParameterValue("sysparm_view") == "viewname";



That may be present in your instance:


https://YOURINSTANCE.service-now.com/nav_to.do?uri=sys_ui_list_control.do?sys_id=68f948890a0a0bc800e...



This concept you can potentially use in your scenario, either by passing along your own sysparm_parameter with a value or may consider spinning up a UI view for your list and disable "New" based on that (where "view rules" can also come handy).



I hope this helps.



Best regards,


Andras


Just one addition to my post above,


based on my observation the "omit new condition" field, even if it evaluates to true, only hides the UI action in case the button's condition field contains the proper condition checks, for example:   !RP.getListControl().isOmitNewButton()



On incident table for example omit new condition did not work with a New button, where its condition field checked for !RP.getListControl().isOmitNewButtonWithoutChecks() which resulted in not hiding that new button even if List Control's "Omit new condition" evaluated to true, only when "Omit new button checkbox" was ticked.