3

In NetSuite, have a Restlet script that calls a deployed map/reduce script but the map stage shows as Failed when looking at details of status page (the getInputData stage does run and shows as Complete).

However, if I do a "Save and Execute" from the deployment of the map/reduce script, it works fine (Map stage does run).

Note that:

  • There is no error on execution log of either the restlet or the map/reduce scripts.
  • Have 'N/task' in define section of restlet as well as task in function parameters.
  • The map/reduce script has the Map checkbox checked. The map/reduce script deployment is not scheduled and has default values for other fields.
  • Using NetSuite help "See the quick brown fox jump" sample map/reduce script
  • Using Sandbox account
  • Using a custom role to post to restlet

Below is call to create.task code snippet from my Restlet. Don't know what is wrong, any help is appreciated.

var mrTask = task.create({
  taskType: task.TaskType.MAP_REDUCE,
  scriptId: 'customscript_test',
  deploymentId: 'customdeploy_test'
});
var mrTaskId = mrTask.submit();
var taskStatus = task.checkStatus(mrTaskId);
log.debug('taskStatus', taskStatus);
quarks
  • 33,478
  • 73
  • 290
  • 513
  • Could you please add your Map stage code so we can see what you are trying to do on it? My bet is that it's a permissions issue, have you also tried going through the summary.mapSummary.errors.iterator() to see what the errors in the Map stage are? – Matias Mar 26 '18 at 14:20

2 Answers2

3

You also need Documents and Files -View permission along with SuiteScript - View and SuiteScript Scheduling - Full permissions to access the Map/Reduce script.

PyroAddict
  • 76
  • 4
  • Thank-you PyroAddict! Adding the additional Documents and Files -View permission along with the other permissions works! – happynetsuiter Mar 11 '19 at 16:13
  • Still have an issue when passing parameter to map/reduce script when calling from restlet. The parameter value does not get set whereas if I call map/reduce script via a suitelet the parameter value does get set. – happynetsuiter Mar 11 '19 at 17:49
  • Do you have the field created on the map reduce record you are trying to set? – PyroAddict Mar 15 '19 at 20:42
1

The help for MapReduceScriptTask.submit() does not mention this but the help for ScheduledScriptTask.submit() does:

Only administrators can run scheduled scripts. If a user event script calls ScheduledScriptTask.submit(), the user event script has to be deployed with admin permissions.

I did a test of posting to my restlet using Administrator role credentials and it works fine as opposed to using my other custom role. Maybe just like ScheduledScriptTask, the MapReduceScriptTask can only be called by Administrator role ? My custom role does have SuiteScript - View and SuiteScript Scheduling - Full permissions. Thought that would do the trick but apparently not.

Anyone have any further insight on this ?