- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi,
I need to create a field of type String on the incident table that will be read only.
After the user create an incident, this field needs to be auto populate with the sys id of the incident but it should be a barcode that can be scanned. the scanning will return the sys id of the incident
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
there is no direct way available for this
How to Generate and Embed a QR Code in a Document Template in ServiceNow
there is also a paid store app for this
💡 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 || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
This can usually be handled with a Business Rule that runs after insert. The rule can copy the record’s sys_id into a read-only string field and then use a barcode font or barcode image generator to display it in scannable form.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
@Alon Grod , I don't think if that is possible to do. This functionality is usually used in Mobile Agent apps to scan and populate the fields.
Regards,
Nayan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi,
Yes, this is completely possible in ServiceNow. Below is a simple and supported step-by-step approach.
Step 1: Create a read-only field
Table: incident
Field type: String
Field name: u_incident_barcode
Length: 32
Mark the field as Read-only
This field will store the Incident sys_id.
Step 2: Auto-populate the field after Incident creation
Create an After Insert Business Rule on the Incident table.
(function executeRule(current, previous) {
if (!current.u_incident_barcode) {
current.u_incident_barcode = current.sys_id;
current.update();
}
})(current, previous);This ensures the field is populated only once, immediately after the record is created.
Step 3: Render the value as a barcode
Create a UI Macro to display the stored sys_id as a Code-128 barcode.
<jelly>
<img src="https://bwipjs-api.metafloor.com/?bcid=code128&text=${current.u_incident_barcode}&scale=3&height=10" />
</jelly>Code-128 is recommended because it supports alphanumeric values and works with most barcode scanners.
Step 4: Display it on the Incident form
Create a UI Formatter referencing the UI Macro
Add the formatter to the Incident form layout
Result
Incident is created
The read-only field is populated with the Incident sys_id
A scannable barcode is displayed on the form
Scanning the barcode returns the sys_id
This approach follows best practices on the ServiceNow platform.
Hope this helps.
Regards,
Aswin
