Sorry for the cross posting but the case is halfwa...
# suitescript
m
Sorry for the cross posting but the case is halfway among Suiteflow and Suitescript and maybe here there's somebody that could help. I'm having trouble understanding how the "set field value" action and the "After Record submit" actually work in Workflows related to User Event Scripts. I have this situation: • there is a User Event Script from Italian Accounting Bundle that, if a checkbox is flagged, calculates a new document number • I wrote a 3-way matching Workflow on Purchase Order and Vendor Bill. To perform its checks, it needs to act on a "After Record Submit" trigger because it needs to compare lines based on a Saved Search. When the condition is met, it sets two fields: one of them is the checkbox mentioned earlier. • According to the Netsuite documentation, Workflow Actions in "After Record Submit" are executed after the User Event scripts in "After Submit". Since the Netsuite documentation also states that a "Set Field Value" action, when placed in a After Record Submit, causes the record to be saved again when the workflow completes, I expected the following sequence of events: 1. the User Event is triggered a first time in "after submit" but, since the checkbox is not flagged, it doesn't perform any actions. 2. the Worklow runs after the User Event, performs its checks, and sets the checkbox using the "Set Field Value" action 3. The User Event, triggered by the save operation caused by "Set Field Value", acts a second time and populates the new document number. What I obtain instead: • the checkbox is flagged • the document number is empty It seems that, depsite the documentation, the "Set Field Value" in workflows behaves like record.submitFields method in Suitescript and it does not trigger any User Event. It's worth noting that the same action is perfomed on the same workflow on a button press, and there it works like a charm. Could anybody help me understand what is happening and how to solve this issue? Thanks in advance.
m
I think it’s because a user event cannot trigger another user event. The set field action is considered a user event so it Cannot trigger the second firing of the user event script
this 1
m
Ok. Maybe the same action behaves differently depending on the trigger it is attached to. The button press is probably seen as a "Client" trigger so it does not have the user event limitation
Thanks. I haven't considered that option.
m
Yes I believe the button click is considered a different context or trigger Usually in these cases one of the user events is best done with a scheduled script or workflow
This overcomes the limitation
Also as side note it seems like you are using script to do document numbering maybe? Just my two cents but messing with the numbering of transactions via script or WF has always ended in disaster for me. I try to avoid it whenever possible
m
Here I am, with some answers. 1. I had some more tests. Despite our early hypothesis, the strange behaviour does not depend on the type of trigger I use in Workflow. I replaced the "Set Field Value" with a custom workflow action that performs a setValue and a save, and it works. So the workflow action do actually trigger User Event. I think I'll open a case to Netsuite for the "Set Field" not triggering the User Event.
2. It is not my choice to have a user Event doing the numbering stuff. It is the official bundle for Italian Accounting (NExIL) that implements the numbering in that way. And, as a matter of fact, it does it pretty well. The Italian Accounting has stringent requirements regarding numbering and it may require multiple numbering sequences for the same document type within the same subsidiary. As a result, the native Netsuite numbering solution is unable to meet all of our requirements.
s
It's been my experience that, despite the clear implication in the docs, setting a field in a WF does not trigger UE scripts. I created a WF Action script to set the field instead, and that works.
Please update us if you open a ticket.