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 03:29 AM
if you are hard-coding the URL in some variable then it's difficult.
you can use onSubmit client script and form an URL and include the catalog variable values in the URL as url parameter and then redirect to task form.
On task table you can write client script to get values from url and set those in fields
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 05:35 AM
hi ankur, i wrote the below script in URL type field there user will click the URL, and wrote the above client script onload on sc task table. actually user nees link here like this to click, kindly suggest
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2023 05:50 AM
so when user is clicking what's happening?
what's not working?
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 05:52 AM
it is redirecting to task form i am getting only "hi" alert no other line of the code
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;
}
}
}