Default company value for requested_for on incident table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
Hi,
Im fairly new to ServiceNow please bear with me.
Was wondering if this is standard behaviour, but when we create incidents on behalf of our customers using the 'requested_for' field, the company field does not default correctly.
Its defaulting the company using the person thats creating the incident
Do i need to create some sort of business rule to default the company of the requested_for field
regards,
Rizzo
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
Hi @Rizzo007
Yes, this is expected behavior in many ServiceNow instances. By default, the Company field may populate based on the logged-in user (the person creating the incident) rather than the "requested_for" user.
If your requirement is to populate the Company from the "requested_for" field, then you can achieve this using an "onChange Client Script" on the "requested_for" field.
Example:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || !newValue) {
return;
}
g_form.getReference('requested_for', function(user) {
if (user.company) {
g_form.setValue('company', user.company);
}
});
}This will automatically update the Company field based on the selected "requested_for" user.
Also, before creating new logic, check whether there are any existing Business Rules, Client Scripts, UI Policies, or Dictionary defaults already setting the Company field.
Hope this helps.
Regards,
VaniMadhuri
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago - last edited an hour ago
Hi @Rizzo007 ,
On the Incident table, this is usually expected behavior depending on which field you are using.
For Incident, the standard OOB user field is Caller [caller_id]. The Caller is the person on behalf of whom the incident is being reported. The person creating the ticket is tracked separately by Opened by / Created by.
So if you are creating an incident for a customer, the recommended OOB approach is usually:
Caller = customer / affected user
Opened by / Created by = agent creating the incident
Company = caller’s company
If you are using a field called requested_for on Incident, check whether that is a custom field or a field added by your implementation. Requested for is common on Request/RITM/catalog processes, but it is not normally the primary OOB Incident requester field. OOB Incident logic typically looks at Caller, not requested_for.
That is why the company may be defaulting from the logged-in user or creator instead of the requested_for user.
If your process must use requested_for on Incident, then yes, you should add logic to populate Company from requested_for.company.
I recommend doing it server-side with a before Business Rule so it works from the form, Workspace, imports, integrations, record producers, and API inserts.
Example Business Rule:
Table: Incident [incident]
When: before
Insert: true
Update: true
Condition: Requested for is not empty and Requested for changes
Script:
(function executeRule(current, previous) {
if (current.requested_for.nil()) {
return;
}
if (current.operation() == 'update' && !current.requested_for.changes()) {
return;
}
var user = current.requested_for.getRefRecord();
if (user && user.isValidRecord() && !user.company.nil()) {
current.company = user.company.toString();
} else {
current.company = '';
}
})(current, previous);
If you also want the Company field to update immediately on the form before saving, add an onChange Client Script on requested_for as well.
Example Client Script:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue == oldValue) {
return;
}
if (!newValue) {
g_form.clearValue('company');
return;
}
g_form.getReference('requested_for', function(user) {
if (user && user.company) {
g_form.setValue('company', user.company);
} else {
g_form.clearValue('company');
}
});
}
The client script is only for the user experience on the form. The Business Rule is the important part because it enforces the value at save time.
One caution: if agents are allowed to manually select a different Company, then do not overwrite Company every time. In that case, only set Company when it is empty, or only when requested_for changes. If Company should always follow requested_for, then overwriting it is fine.
Also, if you are working with external customers through CSM, check whether the correct field should be Company, Account, Contact, or Caller depending on your data model. For standard ITSM Incident, using Caller [caller_id] instead of requested_for may avoid the need for custom logic altogether.
Thank you,
Vikram Karety
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
requested_for is not an out of the box field on incident table
share some screenshots
how are you creating incidents?
is that a custom field?
💡 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
57m ago
Hi Ankur,
You are right. The field is actually 'caller_id', seems the field has been renamed hence the confusion
Thanks
Rizzo
