the Name of the record to be populated to the name of the file in the Image field when submitted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2025 07:31 AM
When I create a new user record, I upload a file to the Image field, upon upload or upon submit, the name of the user record should be the name of the image I've uploaded. However, we will strip the file type from the name. (example1.png = example1)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2025 06:30 AM - edited 05-22-2025 06:34 AM
Hello @Community Alums
Fetch an attachment name from a target record (using its sys_id).
Update the user_name field in the Users table (sys_user) with the name of that attachment.
Use Business Rule (server-side) and Client Script to achieve this.
Attachments in ServiceNow are stored in the sys_attachment table.
Each attachment is linked to a record (target record) via the table_sys_id.
Using a Business Rule, you can fetch attachments related to a record.
You can then update a field like user_name on the sys_user table using a script.
You can trim or split you attachment file name according you requirement.
if anything else please let me know
If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
Thank You

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2025 05:02 AM
I tried ,but thing is servicenow stores image name as image in the attachment table if filed type is image.
ex:image name ex01 but in servicenow attachment table stores as image(if we upload any image by using image type filed ,servicenow stores as image)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2025 05:50 AM
Yes but if you attach as attachment then you get the name of it , not on image type field that is the alternate way for it
If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
Thank You
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2025 05:53 AM - edited 05-23-2025 05:53 AM
Hello, try this in Business Rule
var attGR = new GlideRecord('sys_attachment');
attGR.addQuery('table_name', 'sys_user');
attGR.addQuery('table_sys_id', current.sys_id);
attGR.orderByDesc('sys_created_on');
attGR.query();
if (attGR.next()) {
var oldFileName = attGR.file_name.toString();
var extension = oldFileName.substring(oldFileName.lastIndexOf('.'));
var newFileName = current.user_name + extension;
attGR.file_name = newFileName;
attGR.update();
}