views:

370

answers:

3

MS Dynamics AX 2009:

I need to do this from the Purchase Order Screen, so I only have the Purchase Requisition number available from the PurchLines Table.

Your help would be really greatly appreciated as there is nothing yet on the net available (that I can find) and there are missing classes in the AX 2009 Tutorials.

All helpful answers will definitely get an upvote from me.

Edit: Purpose is to force the existing workflow to re-execute on the Purchase Requisition from "Submitted" stage when a button is clicked on the Purchase Order Screen.

+1  A: 

This will reset the workflow state and status fields in PurchReqTable, but it won't execute any workflow logic:

PurchReqTable::setWorkflowState(PurchReqTable::find(PurchLine.PurchReqId).RecId, PurchReqWorkflowState::Submitted);
Jay Hofacker
I would like to get the Workflow Status reset from complete to submitted so that the document can go through the existing workflow process again.
mm2010
+2  A: 

I found the answer (code) to submit it to the workflow again:

workflowCorrelationId = Workflow::activateFromWorkflowTemplate(workflowTemplateName,recId,note,NoYes::No,'userid');

mm2010
A: 

even i am in the process of acheving the same but getting stuck at soem point can you please send the complete code for this.

swift
//Some sample code copied from a project of mine workflowcorrelationid workflowcorrelationid; workflowconfigurationtable wcf; WorkflowTemplateName _workflowTemplateName = workflowtemplatestr("ProjPurchReqApproval");;wcf = Workflow::findWorkflowConfigToActivateForTemplate(_workflowTemplateName,recid,tableid);workflow::activateFromWorkflowConfigurationId(wcf.ConfigurationId ,recid,'Auto Create from Projects System',noYes::No,curuserid()); PurchReqTable::setWorkflowState(RecId, PurchReqWorkflowState::NotSubmitted); //::Submitted);
mm2010
@mm2010: can you please add the code to your answer: better formatting. Thanks.
Carlos Heuberger
@swift: this is not an answer, it's more like a question :-) it would be better as a comment to the above answer.
Carlos Heuberger