Concatenation of Name field of the user belonging to specific department without affecting users
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-29-2025 10:25 PM
I have written a business rule on sys_user table
before query
condition: Department.name=='XYZ'
var firstName = g_form.getValue('first_name');
var lastName = g_form.getValue('last_name');
var Name = firstName + ' ' + lastName;
g_form.setValue('Name', Name);
But the condition is returning null value when business rule is ran
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-30-2025 07:51 AM
Hi @ark257,
The issue you’re running into is because g_form is only available on the client side (forms, UI Policies, client scripts, etc.). A Business Rule runs on the server side, so g_form.getValue() will always return null there.
If your goal is to set the name field on the sys_user table based on first_name and last_name, you should switch to a before insert/update Business Rule and use the current object instead of g_form.
For example:
// Business Rule on sys_user
// When: before insert OR before update
if (current.department.name == 'XYZ') {
var firstName = current.first_name.toString();
var lastName = current.last_name.toString();
current.name = firstName + ' ' + lastName;
}
A couple of things to keep in mind:
- current.<field> is the right way to access field values in server-side scripts.
- The name field on sys_user is normally system-controlled, so confirm it’s okay to override in your instance.
Docs that might help:
Thanks & Regards,
Muhammad Iftikhar
If my response helped, please mark it as the accepted solution so others can benefit as well.
Muhammad Iftikhar
If my response helped, please mark it as the accepted solution so others can benefit as well.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-30-2025 04:32 PM
Hi @M Iftikhar I tried runing the script but it stii not changing the name format. FYI i am trying to concatenate as lastname + firstname
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-30-2025 09:16 AM
Your question is not clear.
what's your business requirement?
Seems you want Name field to be populated with Concatenation value o First Name + Last Name
If yes then do this
1) before insert/update business rule
current.name = current.first_name + ' ' + current.last_name;
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-30-2025 04:32 PM
Hi @Ankur Bawiskar I tried runing the script but it stii not changing the name format. FYI i am trying to concatenate as lastname + firstname