yuuvis® RAD Q&A

0 votes
by (120 points)

Hi OS-Team,

in your documentation of the BPM-API, there is a part where i can add a process file to a running process. See here.

Unfortunately, this script does not work. I get this error: "File element not found".

We try to add a file to the BPM-Process. The File is already uploaded to yuuvis and we select it on the form by id.
For adding the file we use the syntax from here

Our Scriptcode:

var dmsObjectId = $.variable("exchangedocumentid").value; // the id of the dms object to be added
$.log.info("Add Element: " + dmsObjectId);
var http;

if ($.file.get().length > 0) { // if any objects in the process file exist

http = $.http.put();

} else { // if not

http = $.http.post();

}

var response = http

.service('bpm')
.path('/api/bpm/process/'+$.process.id+'/file/'+dmsObjectId)
.param('processId', $.process.id)
.param('dmsObjectId', dmsObjectId)
.query('type', dmsObjectType)
.execute();

$.log.info(JSON.stringify(response));
$.done();

The Logs:
Add Element: 733E8FF0F2DA41C398668B87A4390123
{"status":"404","reason":"","data":{"key":"service.bpm.file.element.not.found","message":"File element not found."}}

The Element can be found by this ID.

Do you have any idea why there is this 404 error?

Jan

1 Answer

0 votes
by (2.0k points)

Hello Jan!

I am not sure what exactly the problems is, but I have 2 things I noticed, one of mich might be the cause of the problem.

First, you're mixing some stuff here in the http request.
You're using string concatenation for adding the process- and object-id to the request, but thenn still use the "param" function which is meant to replace placeholders in the path.
So as is, you could remove the two ".param" calls as they don't do anything currently.
Or you can change the .path call to:

.path('/api/bpm/process/{processId}/file/{dmsObjectId')

For the two .param calls to do anything.

Secondly, what is "dmsObjectType" defined as / are you sure it's defined somewhere? Your script doesn't include the definition of "dmsObjectType", so if you forgot to define it, then it will result in a call with the type "undefined" and there will be no object with the type "undefined" and the id of your object.

The second point, looking at the 404 response, is most likely the root cause, so I hope this will solve your problem.

Sincerely,
Yannick

Related questions

...