- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-03-2017 07:32 AM
So I'm creating some of the backing fields for an order-able catalog item that'll go through a workflow. I'm trying to create the first step that generates/holds the request information.
One field that I need is an auto-incrementing value inside a certain table that simply tracks the Request ID and who ordered it.
Request Table
Header 1 | Header 2 |
---|---|
Request ID | Requested By |
So when a user wants to order an item, a record gets created in this table with the sys_id of who ordered it an it then increments the request ID by 1.
i.e:
- Will orders a new item,
- A new row is created in Request Table
- Request ID gets incremented by 1
- Requested By becomes the sys_id of the current user.
I then need to grab the new Request ID to insert it into a workflow payload (for a soap call).
Is there a way to do this in a workflow? My guess is that it needs to be done in a Run Script block, but I'm not sure on how to write it.
Here's what I have of the script so far,
/*
This script generates and stores the Request and Order/Instance numbers for the payload and the rest of the workflow.
*/
var workflow.scratchpad.requestNumber;
var workflow.scratchpad.orderNumber;
var workflow.scratchpad.instanceNumber;
var numbering = new GlideRecord('u_request_instance');
numbering.initialize();
numbering.u_requested_by = current.request.opened_by;
numbering.insert();
//I then need to grab that new request_id value from the u_request_instance table.
Solved! Go to Solution.
- Labels:
-
Best Practices
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-03-2017 08:08 AM
Hi William,
var numbering = new GlideRecord('u_request_instance');
numbering.initialize();
numbering.u_requested_by = current.request.opened_by;
var sys_id = numbering.insert();
if(numbering.get(sys_id )) {
var request_id = numbering.request_id;
}
// request_id should hold your request id value
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-05-2017 04:03 AM
Hey everyone! I'm still moving towards testing out the solutions and will hopefully have a working one by the end of the day today.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-17-2017 05:53 AM
Letting everyone know that I'm still looking into it, just got caught up on some other issues! I'll update it as soon as I implement it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-17-2017 08:04 AM
Thank you for updating William, I appreciate your accountability 🙂