Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Approval Template using a Terms Based on User Query not working via DI (SAP B1 8.82 PL04)

Hello,
I have designed an Approval Template using a Terms Based on User Query. If I create an order in SBO the approval template with the user query works fine. But when I create a sales order via the DI API, in which the conditions are met to activate the approval template, the user query is not executed.
If I use a approval template with one of the standard approval procedures , the DI API works fine.
Can the DI API activate the approval template that I have built, when it is used with a User Query? 
Here is the source code that I'm using:
SAPbobsCOM.
Documents oOrderSales = (SAPbobsCOM.Documents)pConn.Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oOrders);
oOrderSales.CardCode = "AB12333"
oOrderSales.DocDueDate = "2012-02-02";
oOrderSales.ShipToCode ="ABC";
oOrderSales.SalesPersonCode = 2;
oOrderSales.Lines.ItemCode = "IT123";
oOrderSales.Lines.ShipDate = "2012-02-02";
oOrderSales.Lines.Quantity = 10;
oOrderSales.Lines.DiscountPercent = 5;
oOrderSales.Lines.Add();
oOrderSales.GetApprovalTemplates();
oOrderSales.Document_ApprovalRequests.Remarks = "Some Remarks for approval";
if (oOrderSales.Add() != 0)
{
     int errCode = -1;                 
     string errMsg = "";
          pConn.Company.GetLastError(out errCode,out errMsg);                  
     throw new Exception("Error: " + errCode + "Message: " + errMsg);
}
else
{
          ObjectKey = pConn.Company.GetNewObjectKey();
          DocType = pConn.Company.GetNewObjectType();
  }
And the User Query that is validating the order total value against a value in the database:
select
CASE when CONVERT(DECIMAL(18,6),$[ORDR.DocTotal])-CONVERT(DECIMAL(18,6),$[ORDR.VatSum])<isnull((SELECT Value FROM [Database].[dbo].[Tid_Config] where [ConfigID] = 'ORSA'),0)
then
      'true'
else
      'false'
end
I also have other user query validations to do like the order items quantity being greater than 10, but this was the first test I needed to do.
  
Please any help is greatly appreciated.

ConfigApproval.jpg (83786 B)
Former Member

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question