How to set URL on URL field type and pass value to other URL

Deepthi13
Tera Expert

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;

        }

    }

}

7 REPLIES 7

Ankur Bawiskar
Tera Patron
Tera Patron

@Deepthi13 

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

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

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 MicrosoftTeams-image (1).pngMicrosoftTeams-image.png

@Deepthi13 

so when user is clicking what's happening?

what's not working?

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

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;

        }

    }

}