How to set URL on URL field type and pass value to other URL
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2023 02:00 AM - edited 03-06-2023 04:51 AM
HI team, i am not getting alert(myparm); in below script please guide
function onLoad() {
alert("hi");
//Use the 'getParameterValue' function below to get the parameter values from the URL
var myparm =getParmVal('sysparm_id');
alert(myparm);
// if (user) {
// g_form.setValue('short_description', user);
// }
function getParmVal(name) {
var url = document.URL.parseQuery();
alert("1" + JSON.stringify(url));
if (url[name]) {
return decodeURI(url[name]);
} else {
return;
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2023 05:55 AM
try this
function onLoad() {
var myparm = getParameterValue('sysparm_id');
alert(myparm);
}
function getParameterValue(name) {
var url = top.location.href;
var value = new URLSearchParams(url).get(name);
if (value) {
return value;
}
if (!value) {
var gUrl = new GlideURL();
gUrl.setFromCurrent();
value = gUrl.getParam("sysparm_id");
return value;
}
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2023 08:06 AM
@Ankur Bawiskar please suggest
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2023 07:47 PM
I already suggested script above.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader