Background
The problem is that by default, only table fields are visible in the workflow designer and sometimes it is required to use business logic to drive the workflow.
The solution to this problem is to add custom parm methods to the workflow document class of the workflow in question. The example below is from one of my custom workflows. I have simplified the code a bit for this example.
If you are working with a standard workflow, you could add your own parm methods in a class extension of the workflow document class.
The parm methods must have three arguments. In the example below, the workflow is based on SalesTable (don't ask ne why). So the TableId and RecId passed to the parm method by the system is related to the current SalesTable record. You will have to modify this to find the related record in your workflow of course.
Note:
- Add methods to the workflow document class (class extending WorkflowDocument).
- The parm method must have three arguments: CompanyId, TableId and RecId.
- The method name must start with "parm".
Example
public class MyApprovalWorkflowDocument extends WorkflowDocument { public MyEnum parmHasCreditLine(CompanyId _companyId, TableId _tableId, RecId _recId) { SalesTable salesTable; MyEnum hasCreditLine; //custom base NoYes enum with //label which will be visible //in the workflow designer changeCompany(_companyId) { salesTable = SalesTable::findRecId(_recId); if (salesTable) { if (salesTable.type().myHasCreditLine()) { hasCreditLine = MyEnum::Yes; } else { hasCreditLine = MyEnum::No; } } } return hasCreditLine; } }
*This post is locked for comments