Show your MR code...
# suitescript
a
Show your MR code...
k
define([“N/record”, “N/search”, “N/format”], function(record, search, format) { function AssignCase(context){ if (context.type !== context.UserEventType.CREATE) { log.debug(‘ignore because not create’); return; }
this if statement keeps getting hit
function createCase(case_data) { log.debug(“create case”, “creating case”); log.debug(“case data”, case_data); var title = case_data.title; log.debug(“title”, title); var account_id = case_data.account; log.debug(“account”, account_id); var new_case = record.create({ type: record.Type.SUPPORT_CASE, isDynamic: true }); new_case.setValue({ fieldId: “company”, value: account_id }); new_case.setValue({ fieldId: “title”, value: title }); new_case.setValue({ fieldId: “status”, value: 1 }); var recordId = new_case.save({ignoreMandatoryFields: true}); if(recordId != null){ updateAccount(account_id); } log.debug(‘new case id: ’, recordId); }
even though this is the code that is being run to create the case
e
What entry point is
AssignCase
wired to?
w
I don’t think there is a ‘CREATE’ execution context on map/reduce.
e
I think that's in the UE
k
Hi @erictgrubaugh
here is the script I have to respond to the creation of a case
case assignment
does anything look awry to you?
e
I assume you are not seeing
log.debug('context', context);
Have you checked for any errors in your
summarize
stage?
You could certainly be encountering an error in your save before this particular
afterSubmit
is being called
e.g. other scripts/workflows on the Case record, bad case data in the first place, etc
k
In my map reduce script however the case is being properly saved
but then in the following assignment script
e
by default, M/R is going to swallow any error silently. you can either wrap your
save()
call in a
try..catch
or you can iterate over the
errors
list in the
summarize
phase
k
okay that makes sense
I will add some better logging and get back to you after some debugging, thanks
e
yeah if an error occurs during
afterSubmit
, the record is still going to be saved to the database
k
So my initial script is creating cases fine, however the UserEvent script is not picking up the Create event
{“type”“delete”,“newRecord”{“id”“1582”,“type”“supportcase”,“isDynamic”false,“fields”{“message
its type is being identified as a delete