- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-03-2016 03:52 PM
Hello,
I am trying to mimic an incident form through a custom UI page and one of the requirements is that I receive a sys_id on the page load before the form is actually inserted into the database. A standard incident form follows this behavior where it will provide you a sys_id before it is truly written to the database. For those that are curious, I need the sys_id in order to create attachments on the record either before or after it is written to the table.
I have tried many approaches.... but my attempts have led me into using gr.newRecord() in the Jelly code in order to generate the sys_id without updating the database.
Current Jelly code looks like this :
<g:evaluate var="jvar_grSysId" object="true" copyToPhase2="true">
var gr = new GlideRecord('u_glodocs_work_order');
gr.newRecord();
gr.sys_id;
</g:evaluate>
This is great for getting a sys_id; however, it doesn't allow me to use the gr object anywhere else.
I have tried passing the gr object to the client script or processing script, but have been unsuccessful. From what I understand about Jelly... once the Jelly parser has finished, it does NOT pass objects from Jelly Code to Client Scripts (which makes sense, because that would essentially allow server side code to be used on client script context). I have also been unable to figure out how to pass the Jelly gr object to a process script or how to keep it alive in some type of namespace.
So the problem I am having, is how do I get a sys_id without creating a record AND more importantly, how do I update this sys_id when I am ready to save the information placed by the user on the UI page.
Attached is code that I have tried, but I have been getting errors due to conflicting sys_ids.
Processing Script that is giving two different sys_id's
var blah = new GlideRecord('incident'); blah.initialize(); blah.sys_id = application_sys_id; //app_sys_id passed in from form. blah.short_description = "This is a test inc from UI page cdekTest"; blah.update(); |
I also tried updating through a client script... and while it allowed me to update the record, and keep the sys_id.... it would write an informational message to the window that an error occurred.
Any help is appreciated on this.
Thanks,
~Constantine
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-03-2016 11:05 PM
Hi Constantine,
Solution Provided by Berny should work for you but if still you need to generate sys_id earliest (before insert) then you could make use of setNewGuid() method
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-06-2017 12:51 PM
Hi Constantine,
I do have a same requirement. I got a help from your code posted but it is giving me 'not authorized' message whenever I press the OK button.
Please let me know if you have any suggestions on that.
Thanks,
Paromita