- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
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:
What is the best approach for this use case:
- Record Producer
- Catalog Item
- or any other method?
How can we capture URL query parameters in ServiceNow and populate fields on form load?
How to handle multiple values for the same parameter (e.g., FIELD=value1 & FIELD=value2)?
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!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
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! 🙏
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
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
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago - last edited 3 weeks ago
Hello @RushikeshB24337
If you want the same results as the Incident form Related Search Results / Contextual Search, I would not use plain Zing search directly. Zing search can return different results because it may not apply the same Contextual Search configuration, search context, resource configuration, filters, KB permissions, user context, and ranking behavior used by the UI.
The supported approach is to use the Contextual Search REST API and pass/use the same Search Context that is configured for the Incident form. If the search context is not passed, the API will use the default search context, which may be different from the one used on the Incident form.
I am not aware of a supported public OOB server-side Script Include that guarantees the exact same result set as the Related Search Results UI. I would avoid calling internal/undocumented Contextual Search Script Includes because they may change during upgrades.
To troubleshoot the mismatch, compare these items between the UI and your API call:
Same Search Context
Same Search Resource / Knowledge source
Same input field, usually Short description
Same Incident table/context
Same user/session permissions
Same KB visibility, user criteria, language, domain, and active/published filters
Same result limit and ordering
Any contextual search filter configuration or scripted filter
So the best answer is: use the OOB Contextual Search REST API with the same Incident search context. Direct Zing search will not always match the Related Search Results UI.
Please mark this as Helpful if it helps.
If this addresses your question, please mark this response as Accepted Solution
or mark has helpful
if you find it helpful.
Thank you!
TejaswiniY
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
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! 🙏
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
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
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti