Hello everyone,
I have a catch-22 situation here and I'm looking for any ideas or approaches that I may be missing.
Scenario:
When a Sales Order is reverted from Pending Fulfillment to Pending Approval as a result of a user editing the sales order who lacks the Approve Sales Order permission - in other words when they edit the order it reverts it back to Pending Approval. In this scenario the NetSuite application "changes" the Status field value and you can only pick up this change in an AfterSubmit context, even worse you need to hit the DB for a fresh read of the field to catch the change (i.e. nlapiGetFieldValue() will return the original, unchanged value)
In this scenario I need my workflow to evaluate it's transitions and transition back to a "Pending Approval" state.
Problem:
There are actions in my Pending Approval State that update fields on the sales order, of course this means the WF must transition on BeforeSubmit. But it can't because it will only pick up the Status change in AfterSubmit.
So I'm stuck!
NetSuite has provided a mechanism to handle similar situations with defined event types. For example the APPROVE event allows your workflow to run in a BeforeSubmit context and thus supports changing fields on the record. There is no "Unaproved" event, there is "REJECTED" which sounds promising but is not related to the sales order transitioning from approved the pending approval.
Simple Question:
How can a workflow transition on a sales order changing to Pending Approval and update fields on the sales order?
Things I've Tried:
I tried to use nlapiTriggerWorkflow() in a UE but quickly learned that it needed to be AfterSubmit to pick up the Status change. Of course when you trigger a workflow from a script it will run in the context of the script (i.e. AfterSubmit) and this doesn't work.
Other Possible Solutions I've come up with: [LIST=1]
[*]Running the workflow in a scheduled mode, I've never used a scheduled workflow but I have the feeling that when executed in scheduled context you can write to the record. This solution is unacceptable because we need near realtime response to the status change to Pending Approval, we can't wait for the scheduled execution to fire.
[/LIST] Any suggestions will be greatly appreciated and eagerly explored!
-Steve
PS: Just noticed I'm a "Junior Member" - what's it take?!