- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-06-2020 03:49 AM
Hi,
I have a requirement to pass the current object from html to processing script.
Here is my code snippet:
HTML:
<g:evaluate var="jvar_taskobj" jelly="true" object="true">
var base_table_name = RP.getWindowProperties().get('sysId');
var gr = new GlideRecord("wm_task");
gr.addQuery('sys_id',base_table_name);
gr.query();
gr.next();
gr;
</g:evaluate>
Processing script:
if ('false' == cancelled) {
var clone = new SMTask().cloneTask(taskobj);
(new StateFlow().processFlow(taskobj, '41dfa2e0d7630100fceaa6859e61035d', 'manual'));
gs.addInfoMessage(gs.getMessage("Cloned from {0}", task_number));
response.sendRedirect("wm_task.do?sys_id=" + clone);
}
How can I pass the current object in the above code "taskobj" is not working.
Thanks
Kevin
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-07-2020 02:59 AM
Hi,
I am referring to the <g:evaluate> tag
I could find in both the g:evaluate tags you are doing query of same table "wm_task" with same sys_id using RP.getWindowProperties().get('sysId')
I could see already hidden element "task_id" which stores the sys_id at the top.
So no need of new hidden element.
you can use that directly in processing script
Try this
if ('false' == cancelled) {
gs.info('Inside sysid is: ' + task_id);
var gr = new GlideRecord('wm_task');
gr.get(task_id);
var clone = new SMTask().cloneTask(gr);
(new StateFlow().processFlow(gr, '41dfa2e0d7630100fceaa6859e61035d', 'manual'));
gs.addInfoMessage(gs.getMessage("Cloned from {0}", task_number));
response.sendRedirect("wm_task.do?sys_id=" + clone);
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-06-2020 03:53 AM
Hi,
not sure if you could pass object but values from current object you can send
you can send the current record sys_id and then query if required in processing script
1) you need to store the sys_id in hidden html element
2) then access it in processing script
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-06-2020 03:56 AM
Hi Ankur,
I tried the hidden html element to pass the sys_id.
However, the "SMTask" script include is not accepting the sys_id, its taking the object.
Thanks
Kevin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-06-2020 03:59 AM
Hi,
you can send the current record sys_id and then query if required in processing script
Then send that glide record object
1) you need to store the sys_id in hidden html element
2) then access it in processing script
Updated HTML:
<g:evaluate var="jvar_taskobj" jelly="true" object="true">
var base_table_name = RP.getWindowProperties().get('sysId');
var gr = new GlideRecord("wm_task");
gr.addQuery('sys_id',base_table_name);
gr.query();
gr.next();
gr;
</g:evaluate>
<input type="hidden" id="hidden_sys_id" value="${jvar_taskobj.sys_id}"></input>
Processing Script:
if ('false' == cancelled) {
var sysid = hidden_sys_id;
var gr = new GlideRecord('wm_task');
gr.get(sysid);
var clone = new SMTask().cloneTask(gr);
(new StateFlow().processFlow(taskobj, '41dfa2e0d7630100fceaa6859e61035d', 'manual'));
gs.addInfoMessage(gs.getMessage("Cloned from {0}", task_number));
response.sendRedirect("wm_task.do?sys_id=" + clone);
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-06-2020 04:07 AM
Hi Ankur,
It didn't work.