Built something you're proud of? Tell the story. A quick G2 review of App Engine or Build Agent helps other developers see what's possible on ServiceNow. Share your experience.

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

@Deepthi13 

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.

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

@Ankur Bawiskar  please suggest

@Deepthi13 

I already suggested script above.

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