Skip to content

Commit 151b556

Browse files
authored
Create README.md
1 parent 065c442 commit 151b556

File tree

1 file changed

+17
-0
lines changed
  • Client-Side Components/Catalog Client Script/Auto-populate field from URL

1 file changed

+17
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
This piece of code is designed for an usecase where you might want to populate a field value that you're passing as a query in the URL which redirects to a catalog item.
2+
In this case, a custom field 'u_date' is chosen as an example to be shown:
3+
4+
1. You open a catalog item record via a URL that carries a date in the query string.
5+
Example:
6+
https://your-instance.service-now.com/your_form.do?sysparm_u_date=2025-10-31
7+
-(This URL includes a parameter named sysparm_u_date with the value 2025-10-31.)
8+
9+
10+
2. The catalog client script reads the page URL and extracts that specific parameter which returns the value "2025-10-31".
11+
12+
3. If the parameter is present, the script populates the form field.
13+
Calling g_form.setValue('u_date', '2025-10-31') sets the date field on the form to 31 October 2025.
14+
15+
16+
Result:
17+
The date field in the form is prefilled from the URL

0 commit comments

Comments
 (0)