- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks 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
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago - last edited 3 weeks 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
3 weeks ago
Glad to help.
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
Hi @Rizzo007
There is a OOTB Business Rule "Company Projection" (sys_id: 51c4e266c611228500ae2d6661f276de).
This BR auto-populates incident.company from the caller's company on insert/update.
Check in your system, whether this BR is deactivated.
refer: KB0760508 Unable to Assign User to Caller Field on Incidents
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti