Story/Background:
One the very frequent questions is about control document. That is how to control its state, with workflows. Let’s suppose you have workflow on Sales Order. Now that workflow is operating fine, but you want to restrict users for invoicing sales order, unless order has been approved via Workflow.
In short handling/controlling state of Trade Document (SO, PO, SQ etc.); How that can be managed with your custom conditions:
Resolution:
Well, Microsoft has shipped all the control documents with application calls which is extended from a class named as InventType.
E.g. for sales Order the name of class is SalesTableType. Below is the signature of this class header
class SalesTableType extends InventType { .... }
Similarly for PO you would find another class named as PurchTableType and so on almost each Trade document has its own Type class.
All you need to do is to put your conditions in this class under certain methods, which are already being used to control state of Trade Documents.
Example:
Let’s suppose System Developer has been given task to control/restrict Invoicing of Sales Order, unless the workflow is approved.
Solution:
For sale order the name of class which is controlling its document state is SalesTableType. Moreover the method which is handling state of Invoicing Sales Order is named as canInvoiceBeUpdated. All you need to here, is embed you Custom logic here with the existing logic & it is highly recommended that put your logic at end existing code/ standard procedures.
Here goes the code how this will be handled.
boolean canInvoiceBeUpdated() { boolean ok = true; ok = this.mayInvoiceBeUpdated(); if (ok) { if (salesTable.SalesType != SalesType::ReturnItem) { if (!salesTable.canCustomerBeUpdated(DocumentStatus::Invoice)) { ok = false; } } } if (ok) { ok = this.checkSalesQty(DocumentStatus::Invoice, this.parmDefaultSalesLineEnumerable(), SalesCheckQtyCachKey::Invoice); } if (ok) { ok = salesTable.checkCreditCard(); } //<here should be your logic> //if(salesTable.YouField != StatusofWF::Approved) //{ //ok = false; //} //</end of your customized code your logic> return ok; }
Thank you for your time to read it. Stay connected for more!
*This post is locked for comments