There are times when you want to add a new type of participant other than security role participants and user group participants, this post describes the steps to take and achieve this requirement.
This is the final output
Let's find out how did it work.
This is how each type of participant exists in AOT so a new Workflow Participant Assignment Provider needs to be created in order to see it in the Type of participant list as for this example 'Vendor invoice approval provider' is being added.
Created a new Workflow Participant Assignment Provider with the following properties.
Available For All Workflow Templates = No [Just want to have this new Participant type vendor invoice approval workflow]
Added new workflow type and link it with VendInvoiceApprovalJournalTemplate which is the workflow type name for Vendor tax invoice approval journal workflow
Each provider has a Provider class and here is an example of the class used for above created participant provider
classFF_VendInvoiceWFParticipantProviderExpend extendsWorkflowParticipantProvider_Expend
{
conststr owner = 'OWNER';
publicWorkflowParticipantExpenDocumentType documentType()
{
returnWorkflowParticipantExpenDocumentType::VendInvoice;
}
publicWorkflowParticipantTokenList getParticipantTokens()
{
WorkflowParticipantTokenList tokenList = WorkflowParticipantTokenList::construct();
tokenList = super();
tokenList.add(owner, '@SYS77709');
return tokenList;
}
/// <summary>
/// Resolves the vendor invoice line dimensions to a list of users
/// </summary>
/// <param name="_context">
/// An instance of the <c>WorkflowContext</c> class
/// </param>
/// <param name="_participantTokenName">
/// The participant token that is selected for a role-based assignment.
/// </param>
/// <returns>
/// An instance of the <c>WorkflowUserList</c> class that contains the enabled users from the token
/// </returns>
/// <exception cref="M:Exception::Error">
/// Participant token does not exist
/// </exception>
publicWorkflowUserList resolve(WorkflowContext _context, WorkflowParticipantToken _participantTokenName)
{
LedgerJournalTable ledgerJournalTable = this.getLedgerJournalTableFromContext(_context);
WorkflowUserList userList = WorkflowUserList::construct();
if (_participantTokenName == owner)
{
userList.add(DirPersonUserEx::worker2UserId(LedgerJournalTable::findRecId(_context.parmRecId()).FF_Originator));
}
return userList;
}
/// <summary>
/// Gets the <c>LedgerJournalTable</c> record from the workflow context.
/// </summary>
/// <param name = "_context">The workflow context.</param>
/// <returns>A <c>LedgerJournalTable</c> record.</returns>
privateLedgerJournalTable getLedgerJournalTableFromContext(WorkflowContext _context)
{
LedgerJournalTable ledgerJournalTable;
if (_context.parmTableId() == tableNum(LedgerJournalTable))
{
ledgerJournalTable = LedgerJournalTable::findRecId(_context.parmRecId());
}
elseif (_context.parmTableId() == tableNum(LedgerJournalTable))
{
ledgerJournalTable = LedgerJournalTrans::findRecId(_context.parmRecId(), false).ledgerJournalTable();
}
return ledgerJournalTable;
}
/// <summary>
/// Validates that the <c>WorkFlowContext</c> has the expected tables.
/// </summary>
/// <param name = "_context">The workflow context.</param>
/// <returns>true if the expected tables are found; otherwise, false.</returns>
privateboolean doesContextHaveExpectedTable(WorkflowContext _context)
{
return _context.parmTableId() == tableNum(LedgerJournalTable) || _context.parmTableId() == tableNum(LedgerJournalTrans);
}
publicstaticFF_VendInvoiceWFParticipantProviderExpend construct()
{
returnnewFF_VendInvoiceWFParticipantProviderExpend();
}
}