cancel
Showing results for 
Search instead for 
Did you mean: 

Cannot trigger doc approval with query via service

08-11-2020 1:50 PM
DanielFe Explorer
1997 views 2 comments
SAP Managed Tags
Subscribe

Dear experts,
"Cannot trigger document approval with query via Service Layer and no matching record found when posting document for approval with condition “always”

I have enabled document ownership and EnableApprovalProcedureInDI.

I have created Approval Template for approval process.

As I remembered when creating document for approval via DI API, there is a child of Document object which handles the approval process something like this:

And I checked the metadata for Purchase Order entity in Service Layer and I found these:

So I tried to create Purchase Order with Document_ApprovalRequest.

First, I tried to set query for the approval. However, when I tried to POST the Purchase Order document, it went straight creating the PO without triggering the approval. Below is my payload for the PO:

Next I tried to remove the query and made the condition to “Always”. When I POST the Purchase Order, I got error no matching record found:

However, when I check, the alert for approving request shows up but the approval request remarks (Testing Approval from SL) was not there.

Is there any missing setting or fields that should be filled?

Thank you

Accepted Solutions (0)

Answers (2)

Answers (2)

tkammer
Explorer
0 Likes

This question seems to have been answered here:

https://answers.sap.com/questions/13087767/error-creating-document-when-it-is-subject-to-an-a.html

Summary: the "record not found" is because Service Layer tries to retrieve the created document and fails because it was added as a draft only. You can add the HTTP Header "Prefer: return-no-content" to prevent the error. Either way, according to the linked answer, the document should be created successfully as a draft.

Former Member
0 Likes

I have the same issue/question. I have no idea yet.