Announcements
Hi All,
I have created a dialog and added one parameter " Auto submit workflow". if Auto submit workflow is enabled yes and run the dialog then it will check each PO , which having staus = open order, approval status = Draft and PO lines, unit price should not be 0.
If the above condition is matched then the respective PO should be auto submit.
I wrote the below code for testing purpose
static void AutoSubmitWorkFlow(Args _args)
{
RecId recId;
recId = PurchTable::find("PO-0007929").RecId;
Workflow::activateFromWorkflowType(workFlowTypeStr(PurchTableTemplate), recId,"auto submit to workflow", false, curUserid());
info("done");
}
It successfully executed but not submitted the PO = PO-0007929
Kindly let me know, if i missed any thing?
Please give me more shed on this.
thanks!
Hi @rp@n,
I would recommend to use the standard code used for submitting PO into workflow. If you review the code hidden behind submit button, you will find the answer.
Stay safe.
Hi all,
I have wrote the below code for PO auto submit workflow
static void POAutoSubmitworkflow(Args _args) { WorkflowVersionTable workflowVersionTable; PurchTable _purchTable; VersioningPurchaseOrder versioningPurchaseOrder; boolean Draft = true; _purchTable = PurchTable::find("PO-0006371"); workflowVersionTable = Workflow::findWorkflowConfigToActivateForType( workFlowTypeStr(PurchTableTemplate), _purchTable.RecId, _purchTable.TableId); if (_purchTable.RecId && workflowVersionTable.RecId && _purchTable.DocumentState == VersioningDocumentState::Draft) { // for auto workflow submission... Workflow::activateFromWorkflowType( workFlowTypeStr(PurchTableTemplate), _purchTable.RecId, "Auto submit to workflow", false, curUserid()); ttsBegin; purchTable::setWorkflowState(_purchTable.RecId, VersioningDocumentState::InReview); ttsCommit; info("PO submitted to workflow"); } else { Draft = false; } }
PurchTable - setWorkflowState method -
public static void setWorkflowState(RecId _purchRecId, VersioningDocumentState _documentState) { PurchTable purchTable; ttsbegin; purchTable = PurchTable::findRecId(_purchRecId,true); purchTable.DocumentState = _documentState; switch (_documentState) { case VersioningDocumentState::InReview: purchTable.DocumentState = VersioningDocumentState::InReview; break; default: break; } purchTable.update(); ttscommit; }
While update the Inreview status in Purch Table, I got the below error
I have debugged the issue and found the below error coming from
this.getDocumentState method -
Why it is taking "InReview" status? ***
In PurchTable i checked, it is showing Document state = "Draft status"
Kindly give me the solution please.
waiting for the response.
Can any one please provide me the code .
Thanks in advance!
Please give me more shed on this
Hi Ludwig,
Yes, when I submitted manually the workflow PO, its successfully submitted. And goes to next level approval.
No error.
Is my code is correct? Needs to add something?
Please give me more shed on this
Hi @rp@n, Does the workflow end without error if you remove your code adjustment? Wonder if there is a general problem with this workflow. Best regards, Ludwig
Error i not able to find. In notification I saw...
What is the error you get?
I have checked in notification, the workflow stopped with error
Kindly let me know, how will solve this?
Please give me more shed on this.
thanks!
André Arnaud de Cal...
294,135
Super User 2025 Season 1
Martin Dráb
232,871
Most Valuable Professional
nmaenpaa
101,158
Moderator