I needed to show the final approver from GP Workflow 2.0 on a PO. You know, an Approved By box with a name or user ID below. This company was using PO approval, NOT requisition approval. Microsoft support said the tables couldn’t be joined in a way to make it work.
Ok, Plan B. I know that David Musgrave has shown how to execute SQL using VBA in Report Writer. David and I went back and forth with this a little, but it looked like more work than what should be required for the request so I set it aside.
Plan C. I came back to this with a different approach. I wrote an update trigger on the WF30100 workflow table. When this table is updated with a final approval (workflow action 10) the ‘Confirm With’ field in POP10100 is filled with the approver’s ID. Confirm With is located under the expansion button next to the Vendor ID. This field is easily added to both regular and Word Templates PO’s
It’s only an insert trigger since a new record is inserted for each change in workflow. Also, the domain is truncated from the user approval, so instead of Approved By showing ibg\mpolino it just shows mpolino.
This seems to work as designed in limited testing. It returns the last, final approver. If a PO is final approved and then recalled or changed it goes through the approval process again. This will show the most recent final approver. Since a PO can’t be printed or emailed if it it’s in an unapproved state, this should work just fine. The SQL to create the trigger is below.
Keep in mind, this is for PO’s that go through approval, not requisitions. This would need to be modified if requisition approval needed to be shown on the PO.
Create Trigger
[dbo].[Update_PO_With_Approver]
on [dbo].[WF30100]
for Insert as
Update POP10100
Set Confirm1=(Select substring(workflow_History_User,charindex(‘\’,Workflow_History_User)+1,20) as FinalApprover
FROM WF30100 INNER JOIN
WFI10002 ON WF30100.WorkflowInstanceID = WFI10002.WorkflowInstanceID RIGHT OUTER JOIN
POP10100 ON WFI10002.WfBusObjKey = POP10100.PONUMBER
Where workflow_action=10 and
wf30100.Workflow_Completion_Date in(Selectmax(Workflow_Completion_Date)from WF30100
Where workflow_action=10 ))
The post Weekly Dynamic: Trigger to Show Workflow 2.0 Final Approver on PO appeared first on DynamicAccounting.net.