I have a custom record which has a child field that is linked to an event.
These records are created using a date range so say for example I need to create records from 7/1 thru 7/7. The end result would be 7 records, each with their own attached event. The custom records also contain a group code which allows me to keep them together for editing purposes.
My struggle is that I want to delete a group of these based on editing a record. Say for example I edit the record on 7/3. I want to be able to say delete this record and all futre records linked by group code.
I have written the script and added it to the form using a client side button on the form. This works fine while logged in as an administrator.
Problem is if I am not logged in as administrator, I get a permission error when it tries to delete the attached event. (not fond of NS Limited Calendar Permissions).
What I am looking for is either a method to run either the nlapiDeleteRecord('calendarevent',st_eventID) call as an administrator or the entire script as an administrator.
I know I can run as administrator if I deploy this as a user event script. But If I deploy as a user event, how would I trigger it, right now the user clicks the button on the form.
I am still learning NetSuite Scripting and there may be a good way to approach this, but I am at a block. Any assistance would be appreciated.
Here is the snippet of code that actually deletes the records.
for ( var i = 0; i < searchRecords.length; i++ ) { var current_ST_Record = searchRecords[i]; var st_record = current_ST_Record.getId( ); var st_eventID = current_ST_Record.getValue(st_columns[3]); message = 'Deleting Record: ' + st_record + ' ----> EventID: ' + st_eventID; window.status = message; nlapiDetachRecord('customrecord_support_crew', st_record, 'calendarevent', st_eventID, {'field' : 'custrecord_support_event'}) nlapiDeleteRecord('calendarevent',st_eventID); //permission error nlapiDeleteRecord('customrecord_support_crew', st_record); }