SutieScript RESTlet 'Missing a required argument: MapReduceScriptTask.scriptId' - mapreduce

I have a RESTlet that I am working to use to call a Map Reduce Script. However, I am getting the following error:
SSS_MISSING_REQD_ARGUMENT, message:task.submit: Missing a required argument: MapReduceScriptTask.scriptId
Here is the code for this particular Function:
function bulkUpdate( request ) {
// Call Map/Reduce Script
var mapReduceScriptTask = task.create({
taskType: task.TaskType.MAP_REDUCE,
scriptID : 'customscript_transaction_bulk_update',
deploymentId : 'customdeploy_transaction_bulk_update',
params : {
"custscript_requestbody" : request['recList']
}
});
var mapReduceScriptTaskId = mapReduceScriptTask.submit();
var taskStatus = task.checkStatus({
taskID : mapReduceScriptTaskId
});
I tried the numeric id as well as the string, and with no luck.
Any help is appreciated.

scriptID : 'customscript_transaction_bulk_update',
vs
scriptId : 'customscript_transaction_bulk_update',

Related

unitary testing in doGet(request) - Google Apps Script

I'm developing a simple google Script and publishing it as a web app.
The starting of my method is as follows:
function doGet(request) {
var start = request.parameters.start;
var end = request.parameters.end;
if (isNaN(Number(start)))
return generateError (3, start);
if (isNaN(Number(end)))
return generateError (4, end);
/*
* ...
* lot of irrelevant stuff for current question
* ...
*/
}
I want to add some basic unitary testing. I have it ready for secondary functions, but I'm not sure how to do it with the doGet (request) function.
At the present moment I'm using the following method:
function testDoGet(){
var queryString = "?start=1&end=5";
var url = ScriptApp.getService().getUrl() + queryString;
var options =
{
"method" : "GET",
"followRedirects" : true,
"muteHttpExceptions": true
};
Logger.log(url);
var result = UrlFetchApp.fetch(url, options);
Logger.log(result);
But this does not allow me to debug, and also it requires that the code has been published (but is not executing the latest code), I would be interested in validate parameters received (for example)
Is there any way so we can simulate this?
I guess you can just call it directly and provide the parameters as an actual HTTP call would do, e.g.
function testDoGet() {
var requestMock = {
parameters: {
start: 1,
end: 5
}
};
Logger.log(requestMock);
var result = doGet(requestMock);
Logger.log(result);
}

Worklight XSL transformation after getting response

I am novice to Worklight. I was trying XSL transformation using:
transformation : { type : "xslFile", xslFile : "filtered.xsl",
}
But for some reason if adapter fails to get response(status code != 200). Then it dumps the whole XSL in "errors".
So is it possible to do transformation of the response only if status code == 200?
Thanks in advance.
There are two ways you can solve this issue
1) in the adapter JavaScript you can check the returned status code
function getStoriesFiltered() {
var input = {
method : 'get',
returnedContentType : 'xml',
path : 'rss/edition.rss',
transformation : {
type : 'xslFile',
xslFile : 'filtered.xsl'
}
};
var response = WL.Server.invokeHttp(input);
if (response.statusCode !== 200) {
return {'statusCode' : 'something went wrong'};
}
return response;
}
Or you can check it in the adapter xsl with a <xsl:if> element depending on what is returned from your backend.

Need help to use node-soap module

I have to make a server to update some device.
They asked me to use node.js and the device send a soap request.
I need to check the parameters to verify the version. So I decided to use the node-soap module. (The WSDL file I use is a local file)
But I can't find how to recover the value of those parameters.
I read the node-soap spec, but I couldn't find how to do that. :/
Here is my code (I didn't do much yet because I'm stuck because of this) :
var myService = {
ActiaProxyAPI: { //MyService
ActiaProxyAPI: { //MyPort
GetData: function(args) { //MyFunction
if (args.i-uiType == "11") {
var ID = args.i-pcIdentifiant;
var reg=new RegExp("[ $]+", "g"); //parse the string (actually works)
var tableau=ID.split(reg);
console.log(tableau[4] );
}
return {
name: args.o-poData
};
}
}
}
};
var xml = require('fs').readFileSync('./wsdl/ActiaProxyAPI.wsdl', 'utf8'),
server = http.createServer(function(request,response) {
response.end("404: Not Found: "+request.url);
});
server.listen(8080);
soap.listen(server, '/wsdl', myService, xml);
I've found how to retrieve the arguments' value : instead of args.i-uiType I used args["i-uiType"] , and instead of name: args.o-poData :
'tns:GetDataResponse': {'o-poData': result}
Well I hope this can help other people, because it works for me !

How to route after calling commit()

I am struggling a little with what to do after I call commit(). I want to determine how to route the user, depending on commit() being successful or if the server returns an error.
I read somewhere that if there is an error on the server then it can return a status code of >400 and errors as follows:
{ 'errors' : [ { 'errorCode' : [ 'duplicate-user' ] } ] }
On the client-side I have the following:
App.UsersController = Ember.ObjectController.extend({
createUser : function () {
'use strict';
var user = App.User.createRecord({
firstName : $("#firstName").val(),
lastName : $("#lastName").val(),
primaryEmailAddress : $("#primaryEmailAddress").val(),
password : $("#password").val()
}),
commitObserver = Ember.Object.extend({
removeObservers : function (sender) {
sender.removeObserver('isError', this, 'error');
sender.removeObserver('isValid', this, 'success');
},
error : function (sender, key, value) {
this.removeObservers(sender);
App.Router.router.transitionTo('duplicateuser');
},
success : function (sender, key, value) {
this.removeObservers(sender);
App.Router.router.transitionTo('usercreated');
}
});
user.get('transaction').commit();
user.addObserver('isError', commitObserver.create(), 'error');
user.addObserver('isValid', commitObserver.create(), 'success');
}
});
(Note: I am not using 'Ember.TextField' in my HTML hence the use of jQuery)
I have a few questions:
Is this the correct/best approach for handling commit()?
I've found I have to remove both observers as isValid is called after isError - is this to be expected?
How/can I access the server response as I want to be able to make a routing decision based on the error code?
The only way I can reference the router is through App.Router.router - is there a cleaner way?
If there is an error, do I need to do anything to remove the record from the store so it doesn't re-committed in the future?
From within a controller, you can do this:
this.get('target').transitionTo('another.route')
or, you can send an event to the current route and transition from there:
this.get('target').send('eventName');
or if you need to pass a model:
this.get('target').send('eventName', this.get('content'));
Simply use controller.transitionToRoute("your.route");
See this link for the source code...

'concurrency' error from service when trying to save a second task

I'm trying to save two tasks to the same user story. The first request always succeeds, but the second service request always gets this message back in the response:
Concurrency conflict: [Object has been modified since being read for
update in this context] - ConcurrencyConflictException : Modified
since read on update : Object Class : com.f4tech.slm.domain.UserStory
: ObjectID :
I am using the JavaScript SDK to create the task. I do this twice:
Rally.data.ModelFactory.getModel({
type : 'Task',
success : function(task) {
var record = Ext.create(task, {
Name : taskName,
State : 'Defined',
TaskIndex : 1,
WorkProduct : workProductId,
Owner : userIdsTeam[owner],
SyncDevelopmentTasktoAccuRev : accuSync,
Estimate: hours,
TargetDeployment: targetDeployment,
context: {
project:'/project/' + currentProjectId,
projectScopeDown: true
},
});
record.save({
callback : afterSaveNewTaskCallback
});
}
});
Is there anything I can do to get rid of this error and successfully save two tasks?
In addition to Kyle's answer, you can also use the Rally.data.BulkRecordUpdater to have the creates/updates queued for you. http://developer.rallydev.com/apps/2.0p5/doc/#!/api/Rally.data.BulkRecordUpdater
Since your tasks are both attached to the same underlying user story the creates are both trying to lock on it to set the association and that's why the second one fails. You'll need to chain the callbacks together:
Rally.data.ModelFactory.getModel({
type : 'Task',
success : function(taskModel) {
//Create first task
var task1 = Ext.create(taskModel, {
//...fields...
});
task1.save({
callback: function() {
//Create second task
var task2 = Ext.create(taskModel, {
//...fields...
});
task2.save({
callback: afterSaveNewTaskCallback
});
}
});
}
});