06-27-2018 09:03 AM
The API PUT call I am trying to make definitely works when I am using /api-explorer.html/ or Postman, but when using built-in task it gives me error when executing with status 400.
In Request mapping I have selected JSON Template and put ${myVar} in it. That produces the error. In an user task before I am displaying ${myVar} and if I copy-paste that value manually into JSON Template (when I modify the process), the process finishes fine. So there's something wrong with the format of variable JSON template expects. Key Value mapping is the same.
Here is my code for getting the myVar:
var temp = JSON.parse(execution.getVariable("oldVar"));
var temp1 = temp.formDefinition.fields[0].fields["1"][0].options;
var newOption = {"id": "option_" + temp1.length, "name": execution.getVariable("newProject")};
temp1.push(newOption);
temp.formDefinition.fields[0].fields["1"][0].options = temp1;
var temp2 = {};
temp2["formRepresentation"] = temp;
execution.setVariable("testVar", JSON.stringify(temp));
execution.setVariable("myVar", JSON.stringify(temp2));
oldVar from the GET call used previously. Script is used to add an entry to a drop-down list.
What is wrong with myVar?
07-03-2018 09:05 AM
Can you share your app? I'm not sure I understood what are you trying to do.
07-03-2018 02:05 PM
I have uploaded my app (check the post). The variable is called jeff. It is a result of a:
GET /enterprise/editor/form-models/{formId}
If you want for this app to work enter some valid formId (mine was 8009). This form had a drop down list. Using javascript, I add to the list of available options field value I have entered in the start form. I then display that modified js object in an user task, and try to do api call(note the format):
but it returns a http error. If I manually copy-paste, what was displayed in the user task, in api-explorer, postman or wherever, I get the result I expect, i.e. an updated list.
Already tried a plethora of header, mapping, variable name combinations, nothing worked.
07-04-2018 05:48 AM
Using a variable with JSON content in a JSON template will not work. The value will be converted to a string (with any needed escape clauses like \"). Thats why you're getting a 400 response.
What is your use case, maybe there is another way achieve what you are trying to do.
07-04-2018 11:36 AM
I supposed that's what was happening. I want some way to add to (and delete from) the dropdown list of some specific form.
Edit: Of course, without someone using app designer and changing the process. I want it to be done at runtime so It can be observed and be more accessible.
Explore our Alfresco products with the links below. Use labels to filter content by product module.