Enhancement: Manual User Entry When User Is Not Found in sys_user
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Requirement: In the Record Producer, we have a Reference field that references the User [sys_user] table. Currently, the field only allows users who exist in the User table to be selected. The requirement is to support users who are not available in the User [sys_user] table. Expected Behavior: The reference field should continue to display matching users from the User [sys_user] table. If the required user is not found, the dropdown should provide an "Other" option. When the user selects "Other", an additional text field should become visible. The user can then manually enter the name of the external/non-ServiceNow user in this text field. The manually entered value should be stored along with the Record Producer submission.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hello @manthenamah,
Don't try to make the reference variable itself accept free text, reference fields only ever store a valid sys_id from the referenced table, so a manually typed name can never live in that field. What you build instead is a reference variable plus a companion checkbox and a single line text variable, toggled with a Catalog UI Policy, and then handled in the Record Producer's own script. Here's the setup:
- Keep the existing Reference variable pointed at User [sys_user] exactly as it is, don't touch its reference qualifier.
- Add a Checkbox variable, something like "User not listed" or "Other", right below it.
- Add a Single Line Text variable, e.g. "External/Non-ServiceNow User Name", and set it to not visible by default.
- Build a Catalog UI Policy on the record producer (Related Links > Catalog UI Policies, these live on the record producer form just like on a catalog item) with a condition of checkbox is true, and a UI Policy Action that makes the text variable visible (and mandatory if you want to force it) while making the reference variable not mandatory.
- Optionally reverse it the other way too: when the checkbox is false, make the reference variable mandatory again, so submitters can't leave both blank.
The part people usually miss is the storage side. Because a reference field can only hold a sys_id, you need a separate field on the target table for the manually entered name, a string field like u_external_user_name works fine. Populate it from the Record Producer's Script field, where "producer" gives you access to the variables and "current" is the GlideRecord about to be inserted:
if (producer.u_not_listed == 'true') {
current.u_external_user_name = producer.u_external_user_name;
// leave the reference field blank, or point it at a placeholder/generic user if your process needs one
} else {
current.caller_id = producer.caller_id;
}A couple of things worth checking before you ship this:
- If your reference variable and the text variable both live in a Variable Set shared across multiple catalog items, remember variable sets can't auto map to a field, that only works for variables defined directly on the record producer, so you'll still need the Script field logic above.
- If the target table field is genuinely a reference to sys_user (like caller_id on incident), decide up front what downstream processes expect there, a blank reference plus a populated text field is usually the safer default over pointing it at a dummy user record.
- Make sure any reports, notifications, or business rules downstream that read caller_id or requested_for are updated to also check the new text field, otherwise the manually entered submissions will look empty in those views.
Thank you,
Vikram Karety
Octigo Solutions INC