RE: Custom Workflow getting error 'Field location must be filled'
Thanks to all. Problem fixed after workflow code changes . As I told that this code got from blogs but its good for learning.
Now I face another issue. Once I submitted the form for approval its run fine but when I get notification that request is approved or reject based on approval action same time submit button again back and it force me to again submit if I want to see view history. After submitted same workflow started again (means now two;1 is pending and other is completed).
I don't know where I should change code.
CustWFSubitManger code:
public static void main(Args _args)
{
CustTable CustTable;
CustWFSubmitManager submitManger;
recId _recId = _args.record().RecId;
WorkflowCorrelationId _workflowCorrelationId;
WorkflowTypeName _workflowTypeName = workFlowTypeStr("CustWF");
WorkflowComment note="";
WorkflowSubmitDialog workflowSubmitDialog;
submitManger= new CustWFSubmitManager();
workflowSubmitDialog = WorkflowSubmitDialog::construct(_args.caller().getActiveworkflowConfiguration());
workflowSubmitDialog.run();
if(workflowSubmitDialog.parmIsClosedOK())
{
custTable = _args.record();
note = workflowSubmitDialog.parmWorkflowComment();
try
{
ttsBegin;
_workflowCorrelationId = Workflow::activateFromWorkflowType(_workflowTypeName,CustTable.RecId, note, NoYes::No);
CustTable.CustApprovalWorkflowState = CustApprovalWorkflowState::Submitted;
CustTable.update();
ttsCommit;
info("Submitted to workflow");
}
catch(Exception::Error)
{
error("error");
}
}
_args.caller().updateWorkFlowControls();
}
CustomerApprovalREsubmitActionManager code:
public static void main(Args _args)
{
RecId recId;
TableId tableId;
CustTable custTable;
WorkflowWorkItemTable workItem;
WorkflowWorkItemActionDialog workflowWorkItemActionDialog;
recId = _args.record().RecId;
tableId = _args.record().TableId;
custTable = _args.record();
workItem = _args.caller().getActiveWorkflowWorkItem();
if(workItem.RecId > 0)
{
try
{
workflowWorkItemActionDialog = WorkflowWorkItemActionDialog::construct(workItem,WorkflowWorkItemActionType::Resubmit, new MenuFunction(_args.menuItemName(),_args.menuItemType()));
workflowWorkItemActionDialog.run();
if(workflowWorkItemActionDialog.parmIsClosedOK())
{
if(custTable.CustApprovalWorkflowState ==CustApprovalWorkflowState::ChangeRequest)
{
workItem = _args.caller().getActiveWorkflowWorkItem();
WorkflowWorkItemActionManager::dispatchWorkItemAction(workItem,workflowWorkItemActionDialog.parmWorkflowComment(),workflowWorkItemActionDialog.parmTargetUser(),WorkflowWorkItemActionType::Resubmit,_args.menuItemName(),false);
custTable.CustApprovalWorkflowState = CustApprovalWorkflowState::ChangeRequest;
ttsBegin;
custTable.dataSource().write();
ttsCommit;
}
else
{
throw Exception::Error;
}
}
}
catch(Exception::Error)
{
throw error(strFmt("Error"));
}
}
_args.caller().updateWorkflowControls();
}