If an item is updated using a Map/Reduce script, d...
# suitescript
w
If an item is updated using a Map/Reduce script, does it fire the afterSubmit User Events on that item? I thought it should, but seem to not be firing...
m
yes it should. if you're using record.submit fields it will come through as xedit and record.load/save it should be regular edit. Are you running on a create or edit?
w
edit
The M/R is loading, updating, and saving the item record
m
and your userevent is deployed to that record and has no special context filtering or event type filtering?
w
let me check
Event type is empty
Context is all but Web App and Web Store
b
script audience?
w
all roles/ all employees
run as admin
b
those are the normal things
if your user event triggers for normal contexts, it should trigger for your map/reduce
w
yeah, must be something else blocking
b
what does your map/reduce code look like
w
It's a csv import tool to update item prices because the native csv import tool overwrites the form
nothing like reinventing the wheel when a simple checkbox on csv import to not overwrite the form would fix the issue
the request is in enhancement hell
b
is it good enough to handle errors
w
yeah
the items are updating, it's just not firing the aftersubmit
b
so far nothing you have described sounds wrong
w
yeah at least I know I'm not crazy and the user event should be firing
b
user events triggers on map reduce scripts
so basically one of the things you have told us so far is wrong
w
I'll deep dive it tomorrow to see what I find
b
my personal guess is that its not handling errors properly
seeing the item update is not enough to determine if an error occurred
after submit scripts trigger after the item has saved, an error in one would still leave prices updated
e
is the deployment set to testing or released?
w
released
e
if the checkboxes deployed and after submit are checked, guess you'll need to look into errors as battk mentioned
w
yeah, tomorrow's project 🙂
b
error handling in this case should look like Logging Errors, though you probably need to do more than log in a real script
w
OK, I found that the User Event is indeed firing, but stops because in afterSubmit(scriptContext), scriptContext.newRecord is not returning what I'm expecting. When a pricing change is made in the UI, comparing the newRecord fields to the oldRecord fields returns a difference in the "pricingchange" field. When the pricing change is made by M/R, no fields return a difference, hence my thought that the UE script was not firing. The system notes are different as well when the item record is updated via UI versus M/R. Will I get better results if I use record.load() instead of using scriptContext.newRecord?
b
you can use dynamic mode
or be extra lazy and manually set the field
w
I am using dynamic mode, and I had to set the "pricingchange" field to true. Then it worked as expected.