Tuesday, June 1, 2010

How to setup custom message on workflow process

While working with workflow found that it's massage processing work dynamically on assignment but for ‘Reject’ and ‘Request change’ task it use static text as @SYS113435 and @SYS112540
To make dynamics massage for reject and request change task I have done following changes
on class SysWorkflowEventDispatcher. onWorkItemCreate()
In this method I have update following codes
stepInstruction = SysWorkflowHelper::getLocalizedLabelText(literalstr("@SYS110261"), user);
subject = _workItemContext.parmWorkItemType() == WorkflowWorkItemType::RequestChange ?
SysWorkflowHelper::getLocalizedLabelText(literalstr("@SYS113435"), user) :
SysWorkflowHelper::getLocalizedLabelText(literalstr("@SYS112540"), user);

With this one
//
stepInstruction= SysWorkflowEventDispatcher::My_getStepInstruction(workflowTable,_workItemContext.parmWorkItemType());
if(!stepInstruction)
stepInstruction = SysWorkflowHelper::getLocalizedLabelText(literalstr("@SYS110261"), user);
subject = _workItemContext.parmWorkItemType() == WorkflowWorkItemType::RequestChange ?
SysWorkflowHelper::getLocalizedLabelText(literalstr("Need More Info"), user) :
SysWorkflowHelper::getLocalizedLabelText(literalstr("Rejected"), user);
//


Here is the New function which I made to generate dynamics text for reject and request change

public static str My_getStepInstruction(SysWorkflowTable _WorkflowTable,WorkflowWorkItemType _WorkflowWorkItemType)
{
str ret;
PurchReqTable PurchReqTable;
str MergeValue;
SysDictField SysDictField;
WorkflowComment _comment ;

;
if(_WorkflowWorkItemType==WorkflowWorkItemType::Return)
_comment=SysWorkflowEventDispatcher::TSG_GetLastComment(_WorkflowTable,WorkflowTrackingType::Rejection);
else if (_WorkflowWorkItemType==WorkflowWorkItemType::RequestChange)
_comment=SysWorkflowEventDispatcher::TSG_GetLastComment(_WorkflowTable,WorkflowTrackingType::RequestChange);

changecompany(_WorkflowTable.ContextCompanyId)
{
switch (_WorkflowTable.ContextTableId)
{
Case PurchReqTable.TableId:
SysDictField=new SysDictField(_WorkflowTable.ContextTableId,fieldnum(PurchReqTable,PurchReqID));
PurchReqTable=PurchReqTable::findRecId(_workflowTable.ContextRecId);
MergeValue=SysDictField.label()+ ": "+ PurchReqTable.PurchReqId +"," +PurchReqTable.PurchReqName;
break;

}
}
if(MergeValue)
{
if(_WorkflowWorkItemType==WorkflowWorkItemType::Return)
ret=strfmt("%1 has been rejected by approver. Perform any required actions and choose resubmit to resume processing. Approver comment:- %2",MergeValue,_comment);
else
ret=strfmt("%1 has been returned to you to provide more information. Perform any required actions and choose resubmit to resume processing. Approver comment:- %2",MergeValue,_comment);
}
return ret;
}


public static WorkflowComment TSG_GetLastComment(SysWorkflowTable _WorkflowTable,WorkflowTrackingType _TrackingType)
{
WorkflowTrackingCommentTable WorkflowTrackingCommentTable;
WorkflowTrackingTable WorkflowTrackingTable;

;
select firstonly WorkflowTrackingCommentTable order by RecID desc
join WorkflowTrackingTable
where WorkflowTrackingCommentTable.TrackingId==WorkflowTrackingTable.TrackingId
join _WorkflowTable
where WorkflowTrackingTable.CorrelationId==_WorkflowTable.WorkflowCorrelationId
&& WorkflowTrackingTable.TrackingType==_TrackingType;

return WorkflowTrackingCommentTable.Comment;

}


Note: Method GetNotifictionSubject only work when user has select notification checkbox on workflow configuration

No comments: