Accessing the To-Be sys_id on a Catalog Item
In light of a series (1 | 2) of recent Community threads asking how to get the sys_id of the current catalog item before it gets submitted, I wanted to capture the process here, just in case those Community posts disappear. So this post is effectively just a keep-safe.
Note – I am literally copy and pasting from a Community user named Nick Parsons. Thank you Nick for describing how to do this.
I have tested the second one; you simply just pop this into a catalog client script.
Get an array of attachments
You can get an array of attachments in a catalog client script by inspecting the angular scope like so:
var $scope = this.angular.element("#sc_cat_item").scope();
var attachmentSysIds = $scope.attachments.map(function(attachmentDetails) {
return attachmentDetails.sys_id;
});
// Result is an array of sys_attachment sys_ids:
// ["5cf0d22453b9121036a838f0a0490e55", ...]Get the sys_id of the to be record
You can get the sys_id of the record that’s about to be generated by also looking at the angular scope, but at different properties:
var $scope = this.angular.element("#sc_cat_item").scope();
var toBeTableName = $scope.data._attachmentTable;
var toBeSysId = $scope.data._generatedItemGUID;
// Result is the record the Record Producer is going to create, for Catalog Items, this is the `sc_cart_item` record:
// toBeTableName = incident
// toBeSysId = 2943522053f9121036a838f0a0490e78
// You can query the sys_attachment table's `table_name` and `table_sys_id` fields that match the above to find the attachments uploaded. Update 10/29/2025
According to ServiceNow documentation, this line of code can get you the sys_id immediately after the page is submitted
RP.getParameterValue('sysparm_id')
The page also suggests that you can use current.FIELD to get the current value – unsure if this applies to sys_id though.