<h2>Pre-filling an instance URL using deep links</h2><br/><div style="overflow-x:auto"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head><meta content="text/html; charset=UTF-8" /><meta name="copyright" content="(C) Copyright 2024" /><meta name="DC.rights.owner" content="(C) Copyright 2024" /><meta name="generator" content="DITA-OT" /><meta name="DC.type" content="task" /><meta name="DC.title" content="Pre-filling an instance URL using deep links" /><meta name="abstract" content="Run a script that includes the deep link generator code to create a URL that can be used to download a ServiceNow mobile app from the app store and pre-fill with the instance URL upon login." /><meta name="description" content="Run a script that includes the deep link generator code to create a URL that can be used to download a ServiceNow mobile app from the app store and pre-fill with the instance URL upon login." /><meta name="DC.relation" scheme="URI" content="../../../administer/tablet-mobile-ui/concept/deep-link-mobile.html" /><meta name="DC.relation" scheme="URI" content="../../../administer/tablet-mobile-ui/concept/mobile-config-navigation.html" /><meta name="DC.relation" scheme="URI" content="../../../administer/tablet-mobile-ui/reference/sg-setup-mobile-admin.html" /><meta name="DC.relation" scheme="URI" content="../../../administer/tablet-mobile-ui/concept/mobile-urls.html" /><meta name="DC.creator" content="Perry Saul" /><meta name="DC.creator" content="Phil Salzman" /><meta name="DC.creator" content="ServiceNow" /><meta name="DC.date.created" content="2023-11-02T12:25:13-10:00" /><meta name="DC.date.modified" content="2024-02-01" /><meta name="DC.format" content="XHTML" /><meta name="DC.identifier" content="mob-plat-config-deep-links" /><link rel="stylesheet" type="text/css" href="../../../CSS/commonltr.css" /><title>Pre-filling an instance URL using deep links</title></head><body id="mob-plat-config-deep-links"> <div class="breadcrumb"><a class="link" href="../../../administer/tablet-mobile-ui/concept/mobile-config-navigation.html" title="Access your instance from anywhere using the ServiceNow Now Mobile, ServiceNow Agent, and Mobile Onboarding apps on your mobile device.">Configure mobile experiences</a> > <a class="link" href="../../../administer/tablet-mobile-ui/reference/sg-setup-mobile-admin.html" title="Build and configure a mobile experience for any of the three ServiceNow mobile apps.">Building and configuring mobile apps</a> > <a class="link" href="../../../administer/tablet-mobile-ui/concept/mobile-urls.html" title="Create mobile URLs to direct users to areas, screens, and features within specified mobile apps. Using mobile deep linking, these re-directional links can be placed within emails, texts, and push notifications.">Mobile URLs</a> > </div> <h1 class="title topictitle1" id="ariaid-title1">Pre-filling an instance URL using deep links</h1> <div class="body taskbody"><p class="shortdesc">Run a script that includes the deep link generator code to create a URL that can be used to download a <span class="ph">ServiceNow®</span> mobile app from the app store and pre-fill with the instance URL upon login.</p> <div class="section prereq p"> <p class="p">Role required: admin</p> </div> <div class="section context" id="mob-plat-config-deep-links__context_zsq_fhy_hzb"> <p class="p">The following procedure is an example of how to use the <span class="keyword apiname">MobileDeepLinkGenerator</span> to create a deep link that pre-fills a <span class="ph">ServiceNow</span> instance URL when a user logs in to a <span class="ph">Mobile Agent</span> app.</p> </div> <ol class="ol steps"><li class="li step stepexpand"> <span class="ph cmd">Navigate to <span class="ph menucascade"><span class="ph uicontrol">All</span> > <span class="ph uicontrol">sys.scripts.do</span></span> to open the script generator.</span> </li><li class="li step stepexpand"> <span class="ph cmd">Paste your script that generates the deep link into the <span class="ph uicontrol">Run script</span> text box.</span> <div class="itemgroup info"> <p class="p">The following deep link script example generates a URL that you can share with users who want their instance information pre-filled for the <span class="ph">Mobile Agent</span> app:</p> <pre class="pre codeblock"><code>var deepLinkGenerator = new global.MobileDeepLinkGenerator(‘Agent’); var deepLinkGen = deepLinkGenerator.getPrefilllLink(true); gs.info(link);</code></pre> <div class="note"><span class="notetitle">Note:</span> Run the script on the instance that you want the deep link to pre-fill. For more information about how you can configure different options for deep links, see <a class="xref" href="../reference/deep-link-mobile-structure.html" title="Familiarize yourself with how to construct and use mobile deep links in any screen type within a mobile app.">Mobile deep link structure</a>.</div> <p class="p">For more information about the options available on the <span class="ph uicontrol">Run script</span> text box, see <a class="xref" href="https://developer.servicenow.com/blog.do?p=/post/training-scriptsbg/" target="_blank" rel="noopener noreferrer">Using Scripts—Background</a> in the <span class="ph">ServiceNow</span> Developer Blog.</p> </div> </li><li class="li step stepexpand"> <span class="ph cmd">After the script runs, copy the URL that it generates and paste it into a communication medium like an email or text message.</span> <div class="itemgroup info">Users can click on that link to be directed to the app stores where they can download the link and have the instance URL pre-populated on their device to log in. If a user already has the app downloaded, the URL detects it and skips directing them to the app stores.</div> </li></ol> </div> <div class="related-links"> <div class="familylinks"> <div class="parentlink"><strong>Parent Topic:</strong> <a class="link" href="../../../administer/tablet-mobile-ui/concept/deep-link-mobile.html" title="Mobile deep links are linking formats that direct users to specific content and locations within a mobile app. These links can be placed in email notifications, text messages, push notifications, launcher screens, and input form screens. You can also configure a mobile app login URL for multiple SSO identity providers.">Deep linking for mobile</a></div> </div> </div></body></html></div>