Issue with Request state while creating via SOAP API using Cart API
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-15-2023 12:27 AM
Hello All
We have an Requirement to Create Request via Integration , for which I have constructed an Scripted SOAP , in the Same logic I had Included logic to Created Approval for the Same Request and have created BR to Auto Approve that
Now the Issue is , when ever we create Request via third party , Request is getting created with
- Request stateClosed Rejected
- StageClosed Incomplete
- StateClosed Incomplete
and later it is updating state as - Work in progress and Request State to Approved
below is the Logic which I have used in Scripted SOAP
function order() {
// Build cart and place order
var cart = new Cart();
for (var j = 0; j < cat_array.length; j++) {
var item = cart.addItem(cat_array[j] + '');
// Set variables from the JSON variables input
var invars = new JSONParser().parse(request.variables);
for (var i in invars) {
cart.setVariable(item, i, invars[i]);
}
}
var cartGR = cart.getCart();
cartGR.requested_for = requestedForUser;
// Place the order
cartGR.update();
var rc = cart.placeOrder();
var approval_gr = new GlideRecord('sysapproval_approver');
approval_gr.initialize();
approval_gr.state = 'requested';
approval_gr.approver = 'df33656e1bbae110a440ffb7d34bcbc7';
approval_gr.sysapproval = rc.sys_id; //Current is record that requires approval
approval_gr.document_id = 'Request :' + '' + rc.sys_id;
approval_gr.insert();
// Setting the description value for Request Record
var gr = new GlideRecord('sc_request');
gr.addQuery('sys_id', rc.sys_id);
gr.query();
if (gr.next()) {
gr.description = 'Automation';
gr.opened_by = opendby;
gr.update();
}
var ritm = new GlideRecord('sc_req_item');
ritm.addQuery('request=' + rc.sys_id);
ritm.query();
while (ritm.next()) {
ritm.opened_by = opendby;
ritm.update();
}
}
Business rule to Auto Approve
var reqID='';
var gr = new GlideRecord('sc_request');
if(gr.get(current.sysapproval))
{
reqID = gr.getUniqueValue();
current.state='approved';
gr.request_state='in_process';
gr.stage = 'Requested';
gr.work_notes = 'Request has been Auto Approved';
gr.update();
current.update();
}
Expected Behavior when Request gets Created
Failure :
Can you please review and help to Make the Corrections if need
@Ankur Bawiskar @Anil Lande @jaheerhattiwale @Jaspal Singh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-15-2023 01:22 AM
@Ankur Bawiskar , can you please take a look?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-15-2023 01:29 AM
Hi,
Check the flow/workflow running on your catalog item.
There is possibility of flow/workflow setting it rejected.
Thanks
Anil Lande
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2024 09:37 AM
Yes your correct Workflow is getting Conflicted and moving the State to Rejected
now In order to Resolve this I have added timer before the user Approval Activity and this resolved the issue but we could see Approval history is getting Twice which wasn't got added before(that is before adding timer)
can you please help me in understanding why this is getting added

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2024 10:29 PM
Hi,
No Idea, looks like there are many configurations in your instance that need to be checked.
Is there any Flow used?
Thanks
Anil Lande