Sunday, February 10, 2019

SSS > Creating event using scheduled scripts fails with error INVALID_REF_KEY Invalid reference key [0]

- Creating a Calendar Event via scheduled script results in an error : Invalid reference key [0]. This error occurs as the owner of the event is not set explicitly by the system. Refer to issue : 124733

- To avoid the above error when creating an event via Scheduled Script, add the owner along with the organizer :

taskEmp = Get the value of employee/user you want to be the owner of the Event

var rec= nlapiCreateRecord('calendarevent');
rec.neweventRec.setFieldValue('organizer',taskEmp);
rec.setFieldValue('owner',taskEmp);

**Note - When creating a Calendar Event via User Event script the owner field is set automatically by the system as it knows who is creating it unlike Scheduled Scripts.

No comments:

Post a Comment