Client script not working to auto populate the requestor field on form load
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
You could do this with one line:
g_form.setValue('requestor_name', g_user.userID);
but note that the field/variable name 'requestor_name' must be exactly correct (case-sensitive) and since g_user.userID returns a sys_id, this field/variable must be a reference type to the sys_user table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Exactly, adding to what @Brad Bowman said, that’s usually the main issue.
Most of the time when a field doesn’t populate on form load, it’s either a case-sensitive field name or a type mismatch. Since g_user.userID returns a sys_id, requestor_name needs to be a reference field pointing to the sys_user table.
Also, make sure the script is set as onLoad, is active, and is running on the correct form type (regular form vs. catalog item). With all that in place, the one-line approach you mentioned should work perfectly.
If you found this useful, please mark it as Helpful and Accepted.
Sarabpreet Singh