g_form.getUniqueValue() always returns same value in service catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2024 09:31 AM
I am adding an attachment to the SC item and I can see the sys id in the attachment table, and it does not match the sys_id that I am getting using 'g_form.getUniqueValue()'.
How do I get the actual id of the SC request ?
If I create the service catalog request 10 times, I always get the same sysid
The following code actually returns the sysid of the Record Producer in Service Portal, but I need sysid of the record ?
var sysid = g_form.getUniqueValue();

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2024 09:58 AM
With a record producer the record that is created is not actually created until the producer script is done. If you need to get the sys_id before the end of the producer script then you need to use the "current.setNewGuid()" method and then do a current.getValue("sys_id") to get the sys_id.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2024 10:08 AM
But I need sysid in Client Script, How can I use these methods in Client Side ?.
My reqt is to validate the validate the file type I am uploading in sys_attachment table. If type is valid then record will be submitted else system stops record submission.
In Record Producer, Catalog Client Script, I have written following code:
function onSubmit()
{
var ga = new GlideAjax('NGRPPortalUtilAjax'); // Call Script Incliude
var Sysid = g_form.getUniqueValue(); // sysid of the record
ga.addParam('sysparm_name', 'validateAttachment'); // call function
ga.addParam('sysparm_table_sys_id', Sysid);
ga.getXML(ValidateAttachment); // callback function
}
function ValidateAttachment(response)
{
var answerFromXML= response.responseXML.documentElement.getAttribute("answer");
var result = JSON.parse(answerFromXML);
alert(result);
if(result=='true')
{
alert('Valid Insert' + result);
}
else
{
alert("Please upload valid form
return false;
}
}
In Script Include, I need to the file I have uploaded in attachment table based on table_sys_id. If fiel type is ".jpg", return true. If file type is not ".jpg", returns false. But the problem here is how I can get table_sys_id ?