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 add parameters in mobile deep link and generate a url for mobile app login .

govi1
Giga Contributor

Hi All,

i want to provide a mobile deep-link so that user can click on it redirect to the incident page through now a mobile app.

Once the user has been redirected I want to auto-populate a couple of fields on the form by passing parameters in the URL.

I have generated a mobile deep link URL by executing the below script in background script.

var deepLinkGenerator = new global.MobileDeepLinkGenerator("request");
var link = deepLinkGenerator.getScreenLink("a75df1920f2033001befa68ca8767e50", uiParams);

Now for above script inaddition to it i am trying to add couple of paramerts in url and generate url .
but i am unsuccesfull.

i have tried like this :

var uiParams = {
"340439b9db10d490b6f887f43a961929": "Meeting Room",
//i am replaced the sys id of meeting room record and field name //


var deepLinkGenerator = new global.MobileDeepLinkGenerator("request");

var link = deepLinkGenerator.getScreenLink("4cd7936cdb2dc410b952413b3a9619e7", uiParams);
gs.print(link);
//Replaced sysid of applet created for mobile application )

kinldy check and assist me if ai am doing something wrong here .Below is the screen shot of error

find_real_file.png

Regards,
Govardhan


 

4 REPLIES 4

Fu
ServiceNow Employee
ServiceNow Employee

Hi Govardham,

 

Not sure if you pasted the entire script. If yes, then please check your syntax.

Your uiParams isn't closed correctly. If should look like:

 

var uiParams = {
 "340439b9db10d490b6f887f43a961929": "Meeting Room"}

 

For more information, please read our developer doc.

https://developer.servicenow.com/dev.do#!/reference/api/newyork/server_legacy/MobileDeepLinkGenerato...

Stephie Soo
Mega Guru

Hi, any updates to this? Am also seeking info on why mine doesn't auto populate the fields i want even with correct syntax. Not sure if my uiParams field_name_sys_id was indicated correctly. Have tried the sys_id of my ui parameters and well as data parameters and ensured they are connected backend. Is it because i use "Mobile Web" screen type and not "Input Form"?

Hi Stephie, I wanted to check if you were able to get it working. I have a similar requirement to auto-populate fields, and I'm also using a Mobile web screen type. I would really appreciate any input you can provide.

Thank you!

Hi sp32,

 

haha you asked at the right timing. I managed to find a way which is 

1. create onload catalog client script to populate based on URL

function getParameterValue(name) {
var url = top.location.href;
var value = new URLSearchParams(url).get(name);
if (value) {
return value;
}
if (!value) {
return value;
}
}

2. create a mobile web screen with url populated with pre-defined values eg. https://instancename.service-now.com/portal?id=sc_cat_item&sys_id=xxxxxxxxxxxxxxxxxxxxxxxxxxx&sysparm_category=xxxxxxxxxxxxxxxxxxxxxxxxxx&catalog_id=-1&variable1=sysid&variable2=ABCD 

Variable 1 is a referenced field

Variable 2 is a text field

3. Generate the qr code

// Create DeepLink for App
var deepLinkGenerator = new global.MobileDeepLinkGenerator("Agent");
// Generate DeepLink to chosen screen
var link = deepLinkGenerator.getScreenLink("sysidOfcreatedMobileWebScreen");

gs.info(link);

 

Basically the auto-population will be done by pre-defined URLs 🙂

Hope this helps!