Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

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  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Ankur Bawiskar  please suggest

@Deepthi13 

I already suggested script above.

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