How to auto-populate ServiceNow form fields using URL query parameters

RushikeshB24337
Tera Contributor

Hi Team,

I have a requirement where an external system redirects users to ServiceNow for ticket creation.

Requirement:

  • User clicks a link from an external system
  • ServiceNow form opens
  • Some fields should be automatically populated based on URL query parameters

Example:

Details:

  • Query parameters contain multiple field values
  • Some parameters are repeated (same key with multiple values)
  • These values need to be mapped to ServiceNow form fields such as:
    • Text fields
    • Dropdown fields
    • Multi-value fields (checkbox/list collector)

Questions:

  1. What is the best approach for this use case:

    • Record Producer
    • Catalog Item
    • or any other method?
  2. How can we capture URL query parameters in ServiceNow and populate fields on form load?

  3. How to handle multiple values for the same parameter (e.g., FIELD=value1 & FIELD=value2)?

  4. What is the recommended implementation approach:

    • Client Script (onLoad)
    • UI Script
    • or any out-of-box feature?

Expected Outcome:

When user opens the ServiceNow form via URL, fields should be pre-populated automatically so the user can review and submit the form.


Any guidance or best practices would be really helpful.

Thanks in advance!

3 ACCEPTED SOLUTIONS

Ankur Bawiskar
Tera Patron

@RushikeshB24337 

Approach

1) you can take them to record producer link in portal

2) then use onLoad catalog client script to grab the values from URL parameters and then set in record producer variables

3) then map those record producer variables to target fields of ticket table

some links for help

Extracting URL Parameters in ServiceNow Using Client Scripts 

3 Ways to Populate Values in ServiceNow via the URL 

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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

View solution in original post

yashkamde
Mega Sage

Hello @RushikeshB24337 ,

 

You can use Record Producer + On Load Client Script :

Script :

function onLoad() {
    var field1 = g_form.getParameter('FIELD1');
    if (field1) {
        g_form.setValue('field1_variable', field1);
    }

    if (field2) {
        g_form.setValue('field2_variable', field2);
    }
}

 

Then Use this script in record producer form for mapping the fields :

(function producerScript(current, producer) {
    current.short_description = producer.field1_variable;
    current.category = producer.field2_variable;
})(current, producer);

 

If my response helped mark as helpful and accept the solution.

View solution in original post

Tanushree Maiti
Tera Patron

Hi @RushikeshB24337 ,

 

For this requirement , we did a scripted Rest API and passed the parameter via url to populate the value in other end  (that was a mobile app, by their scripting, they did populate the fields at their end).

 

You can refer these links:

3 Ways to Populate Values in ServiceNow via the URL

https://servicenowguru.com/service-now-general-knowledge/populating-default-values-url-module/

https://www.youtube.com/watch?v=QHMQEis8nno

KB0778369 URL paramters do not get populated to the incident form 

https://www.servicenow.com/community/developer-forum/scripted-rest-api-dynamic-url/m-p/3391575

https://www.servicenow.com/community/developer-forum/is-there-any-way-to-populate-fields-using-url/m...

 

Please Accept the solution if it assisted you with your question & Mark this response as Helpful.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti

View solution in original post

In this video , we will see how can we pass parameters to create a new record with pre-filled values. ---------------------------------------------------------------------------------------------------- 00:00 - Use case 00:35 - Pass one parameter 01:38 - Passing two parameters ...
5 REPLIES 5

RushikeshB24337
Tera Contributor

Hello @Tanushree Maiti  @yashkamde  @Ankur Bawiskar  @Yaramala Thanks for helping