I can't get start a Workflow via Web Script.
I created the file workflow.get.js:
var nodeId = args.nodeid; //fdadc86f-d996-472d-8267-850a63573b02
var workflowName = args.w; //jbpm$wf:adhoc
var document = search.findNode("workspace://SpacesStore/" + nodeId);
var workflowAction = actions.create("start-workflow");
workflowAction.parameters.workflowName = workflowName;
workflowAction.parameters["bpm:workflowDescription"] = "Please edit: " + document.name;
workflowAction.parameters["bpm:assignees"] = [people.getPerson("admin"), people.getPerson("admin")];
var futureDate = new Date();
futureDate.setDate(futureDate.getDate() + 7);
workflowAction.parameters["bpm:workflowDueDate"] = futureDate;
workflowAction.execute(document);
workflow.get.desc.xml
<webscript>
<shortname>Start Workflow</shortname>
<description>Testando Start Workflow</description>
<url>/workflow?nodeid={idfile}&&w={namewf}</url>
<format default="html">argument</format>
<authentication>admin</authentication>
<transaction>required</transaction>
</webscript>
and workflow.get.html.ftl
The ${args.w} started!
when I click http://localhost:8080/alfresco/service/workflow?nodeId=fdadc86f-d996-472d-8267-850a63573b02&w=jbpm$wf:adhoc return the error
06190076 Wrapped Exception (with status template): 06190474 Failed to execute script '/triggerworkflow.get.js (in repository store workspace://SpacesStore/Company Home/Data Dictionary/Web Scripts)': 06190473 Can't find method org.alfresco.repo.jscript.ScriptAction.execute(org.mozilla.javascript.Undefined). (in repository store workspace://SpacesStore/Company Home/Data Dictionary/Web Scripts)#11)
Exception: org.alfresco.error.AlfrescoRuntimeException - 08200041 TypeError: Cannot read property "name" from null
(workspace://SpacesStore/Company Home/Data Dictionary/Web Scripts Extensions/Workflow/workflow.get.js#7)
org.alfresco.repo.jscript.RhinoScriptProcessor.executeScriptImpl(RhinoScriptProcessor.java:469)
Exception: org.alfresco.scripts.ScriptException - 08200042 Failed to execute script '/Workflow/workflow.get.js
(in repository store workspace://SpacesStore/Company Home/Data Dictionary/Web Scripts Extensions)': 08200041 TypeError: Cannot read
property "name" from null (workspace://SpacesStore/Company Home/Data Dictionary/Web Scripts Extensions/Workflow/workflow.get.js#7)
org.alfresco.repo.jscript.RhinoScriptProcessor.execute(RhinoScriptProcessor.java:183)
Exception: org.springframework.extensions.webscripts.WebScriptException - 08200035 Wrapped Exception (with status template):
08200042 Failed to execute script '/Workflow/workflow.get.js (in repository store workspace://SpacesStore/Company Home/Data Dictionary/Web Scripts Extensions)'
: 08200041 TypeError: Cannot read property "name" from null (workspace://SpacesStore/Company Home/Data Dictionary/Web Scripts Extensions/Workflow/
workflow.get.js#7)
org.springframework.extensions.webscripts.AbstractWebScript.createStatusException(AbstractWebScript.java:742)
Anybody help me?
Your problem is you're calling arguments one thing in one place, and a different thing in another:
var nodeId = args.nodeid; //fdadc86f-d996-472d-8267-850a63573b02
var workflowName = args.w; //jbpm$wf:adhoc
vs
<url>/workflow?nodeid={idfile}&&w={namewf}</url>
You need to get those to agree! I'd suggest, given the URL you seem to already be using from the client, changing your webscript descriptor URL to match what you use, to:
<url>/workflow?nodeid={nodeid}&w={w}</url>
You should also add logic to check that the node given really exists - search.findNode can return null so you should check that before continuing (eg and give a 404 if not found)
Also, you could use utils.getNodeFromString(String) if you'd rather
Please try to start your workflow using this code,
replace your code of workflow.get.js with this code and change all the properties according to your requirement.
function startWorkflow()
{
var workflowAction = workflow.getDefinitionByName("activiti$test_wf");
var package= workflow.createPackage();
var wfparams = new Array();
wfparams["model_prefix:req_props_name"] = value2;
wfparams["bpm:assignee"] = people.getPerson("ADMIN");
workflowAction.startWorkflow(package, wfparams);
}
}
startWorkflow();
Related
I'm new to protractor using javascript, I created a simple script that calls data from another js file.
I have a file called jsobjectdemo.js that contains
<pre>
this.productnames = element.all(by.tagName("app-card"));
this.cartblock = element(by.css("h4 a"));
this.addcartbutton = element(by.css("button[class='btn btn-info']"));
</pre>
And another file called jscalldemo.js
var cart = require('./jsobjectdemo.js');
function addCart(productname){
cart.productnames.each(function(item){
cart.cartblock.getText().then(function(text){
if (text==productname){
cart.addcartbutton.click();
}
})
})
}
When i ran the script, it returns an error
Message:
Failed: Cannot read property 'cartblock' of undefined
Stack:
TypeError: Cannot read property 'cartblock' of undefined
at D:\Trainings\Protractor\protractor-workspace\Protractor\jscalldemo.js:8:14
Const loc = {
productnames = element.all(by.tagName("app-card")), cartblock = element(by.css("h4 a")), addcartbutton = element(by.css("button[class='btn btn-info']"))
}
exports.cart = loc;
Change your jsobjectdemo.js to the above.
And in your jscalldemo.js
Const cart = require('./jsobjectdemo.js').cart;
Now you can use cart.cartblock in jscalldemo.js
I have discovered 'localStorage' with this post recently and I am using it to keep an user logged in even if he refresh the web page.
when I only had to save the name of the user, I had no errors, but then, I added a 'grd' variable to save and I got this error:
[Vue warn]: Error in created hook: "ReferenceError: grd is not defined"
This is how I fetch the data when the page loads :
var name = localStorage.getItem(name);
var grade = localStorage.getItem(grd);
if (name !== null){
this.user = name;
}
if (grade !== null){
this.userGrade = grade;
}
and this is how I save the data :
localStorage.setItem(name, '');
localStorage.setItem(grd, '');
What should I change/add to clear the Reference error?
I am using vue.js in this project
You can resolve the reference error by adding quotes to the variables grd and name like so:
var name = localStorage.getItem('name');
var grade = localStorage.getItem('grd');
The referenceces are key values and must be passed as a string.
I parsed a CSV file to JSON then added my own headers for other strange reasons. So I have data that looks like this:
in my js file I have
console.log(jsonData.theData[0].symbol);
and I get:
admin.js:46 Uncaught TypeError: Cannot read property '0' of undefined
It looks like 0 is defined to me, however when I just type in the browser console the same command in the js file I get good results.
I have tried
JSON.stringify(jsonData.theData[0])
with the same error resulting.
Any idea why this isnt working?
js file below:
var jsonData = {};
var theData = [];
document.getElementById("fileToRead").addEventListener("change",function() {
var input = document.getElementById("fileToRead");
for(var i = 0; i < input.files.length; i++){
var files = input.files[i];
Papa.parse(files, {
header:false,
dynamictyping:true,
complete:function(results){
var input = results.data;
input.forEach(function(input){
jsonData.theData = theData;
var singleEntry = {
"symbol" : input[0],
"date" : input[1],
"open" : input[2],
"high" : input[3],
"low" : input[4],
"close" : input[5],
"volume" : input[6]
}
jsonData.theData.push(singleEntry);
})
//console.log (jsonData);
// document.getElementById("editor").innerHTML = JSON.stringify(jsonData);
} // End Complete - Callback
}); // End PapaParse
} // End for loop
console.log(jsonData);
});
edit.................
I added some console.logs to it and received this....
Click on the little i icon. Its a race condition, your object is not getting loaded in time for your console.log(jsonData.theData[0].symbol);. Inspector is loading it for you after the fact
When you call your
console.log(jsonData.theData[0].symbol);
Are you sure that your jsonData is loaded ?
Edit (after JS code updated)
In your JS code, there is no console.log(jsonData.theData[0].symbol);... We can't see and understand your mistake.
Anyway,
as I said, even if your console.log(jsonData); is made at the end of the loop, it could be empty anyway because you load your data asynchronously
source
Since file parsing is asynchronous, don't forget a callback.
So your jsonData could be empty (so, not loaded)
first of all i am using a bit modified version of the standard html/js code offered from swagger-ui.
Changes are rather simple, instead of using only a single SwaggerUI element like:
window.swaggerUi = new SwaggerUi({
....
window.swaggerUi.load();
we iterate over them and create lots of swaggerUI elements:
function addSwaggerUI(url, dom_id, host){
window[dom_id] = new SwaggerUi({
....
window[domId].load();
this is our iteration:
var services = [{SERVICE_SPECS}];
var doc_container = document.getElementById('service-doc-container');
var index = 0;
services.forEach(function(serviceSpec) {
var swaggerNode = document.createElement('div');
swaggerNode.id = "swagger-ui-container-" + index;
swaggerNode.className = "swagger-ui-wrap";
var messageNode = document.createElement('div');
messageNode.id = "message-bar-" + index;
messageNode.className = "swagger-ui-wrap";
doc_container.appendChild(swaggerNode);
doc_container.appendChild(messageNode);
log("adding service documentation for " + serviceSpec);
addServiceDocumentation(serviceSpec, swaggerNode.id, "{SERVICE_HOST}");
index++;
});
This worked quiet well until we started using securityDefinitions oAuth:
"securityDefinitions": {
"OauthSecurity": {
"type": "oauth2",
"authorizationUrl": "http://localhost/oauth/dialog",
"flow": "implicit",
"scopes":{
"write:sessions":"kill sessions",
"read:sessions":"get sessions"
}
}
Now i get on each swaggerUI this error:
index.js:24 Uncaught TypeError: Cannot read property 'api' of undefined
Original swaggercode:https://github.com/swagger-api/swagger-ui/tree/master/dist see index.html
Can someone help to fix this?
(Alternative solution: Anyone know of another way to add multiple web apis from different json files on one html page? )
UPDATE:
So i looked at the generated page from swagger.petstore.io and found something called 'authorzie-wrapper'it is possible that this element is missing at my code.
I have the following ColdFusion function:
component {
url._cf_nodebug=true;
url.returnformat = "json";
url.queryformat = "column";
remote function Read(StateID) {
local.result = {};
local.result.MSG = "";
// local.result.QRY = QueryNew();
local.svc = new query();
local.svc.addParam(value=arguments.StateID,cfsqltype="cf_sql_integer");
local.svc.setSQL("SELECT *
FROM State WHERE StateID = ?");
local.svc.setName = "qry";
local.obj = local.svc.execute();
local.result.QRY = local.obj.getResult();
return local.result;
}
}
And when I test it from test.cfm, it works correctly:
<cfset qry = CreateObject("component","ajaxEnabled").Read(154)>
So I think the problem is how I'm passing my parameters into the $.ajax method.
When I call it, I get: parsererror: SyntaxError: Unexpected token <
;(function($, window, undefined) {
var document = window.document;
$('#States').on('click','a',function() {
var local = {};
local.data = {};
local.data.StateID = $(this).data('stateid');
local.dataType = 'json';
local.context = $(this)[0];
local.Promise = $.ajax('ajaxEnabled.cfc',local);
local.Promise.fail(function(A,B,C) {
console.log(B + ': ' + C);
});
});
})(jQuery, window);
I can see in the console that local.data.StateID = 153, which is what I want.
Here's the link to the page. And here's the link to test.cfm.
You're specifying the CFC in your AJAX call, but not which method to call. So CF is interpretting the request as one to see the API docs for that CFC, and that's what it's returning to the browser. So the AJAX call is receiving mark-up, not JSON.
Also, in future: when you say you get an error and you're dealing with multiple systems (eg: CF and JS), make sure to say which system is giving you the error. This saves us having to guess.
The problem has nothing to do with your JavaScript code itself... it has to do with what you are doing server side. If you use your browser tools, you will see this response:
<br> <br>
Unsupported Operation. Check application log for more details.
<br> <br>
The parser error is for the returned data, not your code.
The URL in this case was http://www.phillipsenn.com/CFIDE/componentutils/cfcexplorer.cfc?method=getcfcinhtml&name=Matrix.CRUD.jqm.ajaxEnabled.ajaxEnabled&path=/Matrix/CRUD/jqm/ajaxEnabled/ajaxEnabled.cfc