Is there a way to listen to live field updates to ...
# suitescript
y
Is there a way to listen to live field updates to the lead times on inventory items? Regardless of the context (i.e. if a user kicks it off, or some other automated process makes the change to the lead time)? I imagine I would need to write up a client script that hooks onto an after submit event, and in the deployment select all execution contexts. From what I understood however, there is one case that might not be covered by doing that, which is when a user event fires for a record and saves changes there. ie, if an afterSubmit user event script loads, then changes and saves an item record, then a new user event would not be fired. If so, what is the best alternative for listening to real-time updates on stored fields, that can catch all changes regardless of source?
c
Just an FYI that you can get around the UE not firing other UEs by using a workflow action or having the UE call a suitelet that does the work and saves. User Event is what you want as your "listening" real-time event. The issue is that not all actions in NetSuite cause the script to kick off. There's a lot of bulk processing that happens and those typically do not fire a UE. From my experience, its not documented (well at least) and you have to just try the process and see if your event fires. Otherwise, your option is to have some kind of scheduled process that looks for changes.
🥳 1
y
Thanks so much @creece!! In terms of the workflow action that you mentioned above, (and sorry to ask, I'm super new to the whole NetSuite world), is that something that I could say set up once, and then that could possibly provide the workaround that would be able to capture any and all changes? I guess I'm hoping for a catch-all type of fix, but that's sounding less and less possible 😞 maybe the UE calling a suitelet type of thing might also be a good option...maybe I could use that to check for any records that have changed? How I would I'm not sure just yet, but as an idea...otherwise the schedule is basically our fall back plan as well, which I suppose we could do relatively easily...
c
What you should do is create an empty UE script that just logs out the context and do your processes and see if your script is firing for those processes. If not, then you cannot get this data real time as there's no active hook into it. If you can't get your data real-time, then the next best thing is some kinda scheduled event that does some system notes parsing or however you want to keep track of changes. The "workaround" is for when YOU are coding. Its just a way to get a UE to call another UE if needed.
y
Thank you! That actually sounds like a good idea 🙂 I'll give that a try and see how I go. Really appreciate it!