diff --git a/Client Scripts/Get URL Parameters/readme.md b/Client Scripts/Get URL Parameters/readme.md new file mode 100644 index 0000000000..534ca0ae7e --- /dev/null +++ b/Client Scripts/Get URL Parameters/readme.md @@ -0,0 +1,5 @@ +# Get URL Parameters in Global,Scoped Application for Record & Catalog Item + +Many times there is a need to grab parameters from URL. This could be required at table form load or catalog item load and either in Global scope or custom scope application when redirection happened. Given script will help you in achieving this: + +[Click here for the script](script.js) diff --git a/Client Scripts/Get URL Parameters/script.js b/Client Scripts/Get URL Parameters/script.js new file mode 100644 index 0000000000..f7f492fe5e --- /dev/null +++ b/Client Scripts/Get URL Parameters/script.js @@ -0,0 +1,15 @@ +function onLoad() { +//Type appropriate comment here, and begin script below + +if(window == null){ // For Service Portal +var url = top.location.href; +var value = new URLSearchParams(url).get('sysparm_id'); //provide the parameter name +console.log(value); +} +else{ //For Native UI +var glideURL = new GlideURL(); +glideURL.setFromCurrent(); +var id = glideURL.getParam("sysparm_id"); // provide the parameter name +console.log(id); +} +}