How to get current requested item?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-07-2016 10:04 AM
Hi,
Here what I am doing :
I am trying to request the listed from service catalog.On request one incident gets created and gets assigned to the authorized person for approval.Once the person approve the request there is one script attached that calls the requested item table.That request calls the all incident items from the requested table.On every request approval that script runs.I just want to know How to get that requested item that triggers the script.for examle :
Item1 ----> request -----> approval ---->script ----> output == item1
Item2 ----> request -----> approval ---->script ----> output == item2
Here is my script :
var requestedItem = new GlideRecord('sc_req_item');
requestedItem.addQuery('active', true);
requestedItem.query();
while (requestedItem.next()) {
gs.log("name:requestedItem:"+requestedItem.cat_item.name);
}
It returns all the requested item.
can someone please help me.
Thanks,
Vimal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-07-2016 10:12 AM
Hi Vimal
The query you are executing has no restriction.
You will loop into all the active requested items.
If you need just one than you need to provide the sys_id of the actual requested item adding a similar line of code
requestedItem.addQuery('sys_id', XXXXX);
Important also to understand from which table you are trying to execute the code.
I hope this will help
Cheers
R0bo
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-07-2016 10:16 AM
Hi,
Is there any way to get that sys_id using script.I have designed workflow to be execute on sc_req_item table.
Thanks,
Vimal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-07-2016 10:21 AM
Hi Vimal
If your script is embedded inside a workflow and the workflow is against a requested item than you can access the information of the actual requested items directly using
current.sys_id
So the code seems not necessary.
Cheers
R0bo
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-07-2016 10:23 AM
Thank You so much.
