SmartConnect & GP Workflow

From time to time, I’ve run into scenarios with client integrations in SmartConnect where I needed to disable and re-enable a Workflow in Dynamics GP. I’ve often felt like I was missing something, because sometimes it didn’t seem to work as I expected. Recently, I had a funny experience and finally figured something out that I had been missing all these years.

Background

The scenario at a client was an integration with a CIS system that passes over customer refunds. The integration creates or edits vendor records and then creates a Payables Transaction Entry for an “invoice” to pay that is the refund.

This client has Vendor Approval Workflow enabled, which needed to be temporarily disabled for this import. If there is a Vendor Approval workflow enabled when trying to edit an existing vendor via eConnect, it fails, it is not possible as long as the workflow is enabled.

I used a fairly standard map setup in SmartConnect:

  • A pre-map task to disable workflow temporarily, without any condition **
  • Regular map functionality in between to create vendors and transactions
  • Post-document tasks to set the workflow_status value on the vendor to 9 (“ignore workflow”)
  • Post-map tasks on both failure and success to re-enable workflow again

This seemed to work fine until one day the client sent me a note: “Something odd is happening with our Vendor Approval Workflow, it only seems to be active on Thursdays”. Oh no.

** This was the issue!

Short version of the what happened

At this client, refunds typically get sent over on Wednesdays, so on Wednesday evenings, there is data and the map runs as expected. However, the SmartConnect map runs every day in case there are one-offs that occur. The map would run on days without data, the pre-map task would disable the workflow, and with no data to process, none of the subsequent tasks were triggered.

Including the ones that re-enable the Workflow.

DOH.

Light bulb moment

This is the part I should have known all along. I have used SmartConnect for a long time. It never occurred to me that after the pre-map tasks, if the map itself has no data, that the post map tasks would never fire. I kid you not, that never occurred to me.

How did I fix this? I had to factor in a condition on my query to disable the workflow, to check if there is data to integrate instead of just disabling it. Here is an example of the code on the pre-map task now.

UPDATE	WF
SET	WF.ACTIVE = 0
FROM	WF100002 WF	
WHERE	WF.Workflow_Type_Name = 'Vendor Approval'
	AND EXISTS(SELECT 1 FROM <my data source> WHERE <condition>)

My integration is based on records of a certain status type that are “not integrated” so checking for those records would return an empty result set back on this query if no data existed to import, therefore the disabling of this workflow type would not happen. On days where there is data, it would disable and continue on its merry way, then conclude successfully or not with a task to re-enable it, without that needing to be conditional.

I felt kind of dumb once I realized what I was missing but now the client’s Vendor Workflow works every day of the week. 😂

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top