I have got the Workflow task of creating 4 Approvals based on amounts.
For Ex: SalesTable Total Amount ( Get all line amounts total)
If Sales Total Amount < 1000 - Get one approval
Sales Total Amount < 2500 - Get 2 approval
Sales Total Amount >25000 - 50000 - Get 3 approvals
Sales Total Amount >50000 - Get 4 approvals
I created one approval Task and configured in Workflow, by creating conditional approval using same Approval class. The issue is with the code of Approval Complete Event - Changed the table Workflow field to approval.
Issue : Even the amount is 2600, which needs 3 approvals, but when it pass through first approval the Table workflow field is getting Approved through code.
Resolved : The issue is resolved by creating Automated Task event, And written below code in "Executed " method .
public void execute(WorkflowElementEventArgs _workflowElementEventArgs)
{
SalesTable salesTable;
WorkflowTrackingStatusTable workflowTrackingStatusTable;
salesTable = SalesTable::findRecId(_workflowElementEventArgs.parmWorkflowContext().parmRecId());
if(salesTable)
{
//workflowTrackingStatusTable = WorkflowTrackingStatusTable::findByCorrelation(_workflowElementEventArgs.parmWorkflowContext().parmWorkflowCorrelationId());
// if(workflowTrackingStatusTable.TrackingStatus == WorkflowTrackingStatus::Completed)
{
ttsBegin;
salesTable.selectForUpdate(true);
salesTable.SalesCreditNoterWorkFlowStatus = SalesReturnOrderWorkFlowStatus::Approved;
salesTable.update();
ttsCommit;
}
}
info("automated task is executed");
}
Configured the Automated Task in Workflow before End...
So The flow comes from any of the approval needs to go from Automated Task and the workflow gets approved
Below code to get Total Line amount for a sales order :
For Ex: SalesTable Total Amount ( Get all line amounts total)
If Sales Total Amount < 1000 - Get one approval
Sales Total Amount < 2500 - Get 2 approval
Sales Total Amount >25000 - 50000 - Get 3 approvals
Sales Total Amount >50000 - Get 4 approvals
I created one approval Task and configured in Workflow, by creating conditional approval using same Approval class. The issue is with the code of Approval Complete Event - Changed the table Workflow field to approval.
Issue : Even the amount is 2600, which needs 3 approvals, but when it pass through first approval the Table workflow field is getting Approved through code.
Resolved : The issue is resolved by creating Automated Task event, And written below code in "Executed " method .
public void execute(WorkflowElementEventArgs _workflowElementEventArgs)
{
SalesTable salesTable;
WorkflowTrackingStatusTable workflowTrackingStatusTable;
salesTable = SalesTable::findRecId(_workflowElementEventArgs.parmWorkflowContext().parmRecId());
if(salesTable)
{
//workflowTrackingStatusTable = WorkflowTrackingStatusTable::findByCorrelation(_workflowElementEventArgs.parmWorkflowContext().parmWorkflowCorrelationId());
// if(workflowTrackingStatusTable.TrackingStatus == WorkflowTrackingStatus::Completed)
{
ttsBegin;
salesTable.selectForUpdate(true);
salesTable.SalesCreditNoterWorkFlowStatus = SalesReturnOrderWorkFlowStatus::Approved;
salesTable.update();
ttsCommit;
}
}
info("automated task is executed");
}
Configured the Automated Task in Workflow before End...
So The flow comes from any of the approval needs to go from Automated Task and the workflow gets approved
Below code to get Total Line amount for a sales order :
SalesTotals salesTotals;
SalesTable salestblUpd;
salestblUpd = SalesTable::find(Custinvoicejour.SalesId);
if(salestblUpd)
{
salesTotals = SalesTotals::construct(salestblUpd, SalesUpdate::All);
salesTotals.calc();
salestblUpd.selectForUpdate(true);
ttsBegin;
salestblUpd.SalesCreditLineTotalAmount = salesTotals.totalAmount();
salestblUpd.update();
ttsCommit;
}
No comments:
Post a Comment