User event not firing on create event - netsuite

I'm having a strange problem, where a user event, made to fire for sales orders on the Create event type, is not starting at all for some of them.
Trigger on: BEFORE SUBMIT FUNCTION
STATUS - Released
EVENT TYPE - Create
LOG LEVEL- Error
EXECUTE AS ROLE - Full Access
All access boxes are checked.
The only pattern I've found so far is that all failures are being created by a Script (Scheduled), which makes little sense to me...
Has anyone found a similar issue??

Do you want the scheduled script to trigger the user event script? Do you have the "All Roles" checkbox checked? I believe you need this to be checked for the UE script to be execute when the scheduled script creates a record.

You might want to check your scheduled script if it is error free. One possible reason why the user event script is not running is because the scheduled script has an error. Run your scheduled script first from the script debugger to see if there are errors.

Related

Email if a cron job succeeds on Cronitor

Is it possible to add a setting on Cronitor that sends an email once a cron job succeeds. Right now I only get email if a cron job fails.
This is what i have at the moment :
Alert preferences Failure tolerance Duration alerts
Alert notes
(X) Send alerts any time there is a problem
() Only send alerts if my job has consistently not run when expected...
I tried to email/contact support but now answer from Cronitor yet.
I'm one of the creators of Cronitor. I'm really sorry we somehow missed your support inquiry.
The answer is that, yes, this is possible but you cannot set this up without an API call. After the initial setup is complete (and the new alert rule is added) you can continue managing the monitor from the dashboard.
If you email support#cronitor.io again with specifics I can help you with adding this rule via the API.

Show Map/Reduce script error on a SuiteLet

I have created a Suitelet which runs a Map Reduce script when user Submits it.
I am able to show messages such as Completed, Failed or In Progress using task.checkStatus(taskId).
Is there anyway that I can also show the MR erros in UI, in case that M/R fails?
Probably I could use Custom Records to create the errors and then show them (too havy) or send the errors via email. But if there is a way I would prefer showing them directly to the user.
Any ideas, suggestions?
Thanks.
A couple of ways to do this:
Log the errors normally.
Periodically while the m/r is running run a search on the script logs filtering the results on the script and deployment.
Accumulate the errors and create a summarize phase in the m/r and email the results to the person who ran the m/r. Netsuiteā€™s example m/r has a hint about how to do that

Check whether cronjob has ran or not

I have one python script running in crontab, I want to check if it is running successfully or not? if not then send mail or another kind of notification. How do I notify based on Cron logs?
Things I already Tried:
All the Exception in python file I have already handled
Need: Notify user if Cron job is not running successfully?
In order to notify weather cron job running or not, you can set email id in cpanel 'cron jobs' page. so you will receive email once file get executed.
There are monitoring services specifically for cronjobs, doing exactly what you're asking for. I'm partial to WDT.io and here're the detailed instructions: https://cookbook.wdt.io/cron.html.

Triggering User Event after creating a record in SuiteScript

I could swear this worked a few versions back, but now it doesn't seem to.
My script creats a new Customer record, and I have a User Event (After Submit) deployed on the Customer record.
I've tried setting the record mode to be dynamic - even tried setting the sourcing to true, however, I can't seem to get the User Event to trigger after I create the record.
Here's a sample of what my script looks like, as you can see, it's quite simple:
var customerRecord = nlapiCreateRecord("customer", {recordmode: "dynamic"});
customerRecord.setFieldValue("companyname", "test company");
nlapiSubmitRecord(customerRecord, true, false);
From the NetSuite Help page titled What are User Event Scripts?:
User event scripts cannot be executed by other user event scripts. You
can, however, execute a user event script from a call within a
NetSuite scheduled script, a portlet script, or a Suitelet.
I am not sure if this is due to a recent release or not, but this could be why it is no longer working.
Is the script that is creating the Customer record a User Event script also? If yes, then a User Event script cannot trigger another User Event script. NetSuite does not allow this.
You are right, I am also facing the same problem.
After so many trials I find out that you cannot trigger user event from another user event. And 1 more thing, you can also not trigger any workflow attached to the record from user event.
You can not trigger a User Event Script from a user event script, but you can call a Suitelet within your User Event Script that you can use to trigger the other User Event Script to run.
This is shown here: https://videohub.oracle.com/media/SuiteScript+2.0+%26gtB+User+Event+Script+to+Trigger+another+User+Event+Script+using+Suitelet/1_vgt8ud6n

How to run a script on actual creation

I'm trying to find out how to run a script to edit a record before the it's actually called by the user. So far all events seem to be handled when there is some kind of interaction with the record.
This is to be able to automatically send emails with the customer's information upon creation.
Write into NS DB > Script updates user data and sends email > First view/edit is made.
Seems the previous admin managed using UE on beforeload, but that is not working anymore.
nlapiGetNewRecord().getId() --> returns an id not belonging to the record.
Any ideas how to trigger a script on creation?
Based on your requirement to send an e-mail on record creation, I don't see where the record editing takes place.
Though if you do want to edit the record just before it is created, you can use beforeSubmit(type) in a User Event script and have it run when type == "create".
Otherwise if no editing is needed, afterSubmit(type) in a User Event script and have it run when type == "create" should work just as well.
If I understand your requirements, the editing code(assuming based on what you are saying that you are trying to edit the record that is created) should be written in a beforeRecordSubmit and the email sending should be done in afterRecordSubmit. This way you know the data you want to enter is written to the database correctly (brs) and the email is only sent if the record commits in the database correctly (afs).

Resources