- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-15-2016 03:46 AM
Hi,
I need help on the below scenario.
I am trying to create an incident with use of UI page( can't use a record producer), where i need a custom attachment button.
For the same, i am using the saveAttachment('incident','incident_sysId') method where we need to populate table name and sysid of the current record.
The problem which i am facing is that i need sys_id of the new record which i am going to create with UI page. But then, record is not yet created so i don't have sys_id with me to append in the saveattchment method. So i figured out a way how record producer works, it generates a new GUID everytime and create a record in attachment table with same table sys_id
And then when user submits the Record producer, it captures the same table sys_id and create new record in Incident table with same sys_id.
To replicate same behavior through UI page, we can use gs.generateGUID() method which gives unique key every time, and then once attachment is added, we can create a record with same new sysId, My concern is whether gs.generateGUID() will always give me unique key and it would never be as same as any of already created records in incident table because this could lead to a chaos in my case.
Please help in this case if you have any knowledge on it or a better way to implement the same scenario.
Thanks
Gaurav Bajaj
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-15-2016 04:45 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-15-2016 03:55 AM
Hi Gaurav,
I cannot speak to gs.generateGUID() because it's not documented anywhere. I'm curious where you got this from? Normally one uses the return result from a GlideRecord insert() method and holds on to that.
That being said, according to the docs - sys_ids (GUIDs) are NEVER reused.
Unique Record Identifier - ServiceNow Wiki
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-15-2016 04:39 AM
Hi Chuck,
Its pleasure to see a reply from you.
I got this method from glide system api
There is OOB method available..(search for gs.generateGUID() )
Scoped GlideSystem API Reference - ServiceNow Wiki
Thanks
Gaurav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-15-2016 04:46 AM
Thank you for the reference Gaurav. I somehow missed that in my search.
I hope that answers your question if GUIDs are unique everytime. The short answer is YES
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-15-2016 04:51 AM
Thanks Chuck
