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! 🙏

View solution in original post

yashkamde
Tera 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

5 REPLIES 5

RushikeshB24337
Tera Contributor

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