magander3
Enthusiast
Enthusiast

Problem reading MimeAttachement in vCO/vRO

Jump to solution

Hi,

i'm using vCO/vRO version 5.5.2 and i got a workflow that rung on a daily schedule (or would like it to do).

Problem is that once the MimeAttachement is read the first time it never actually reads it again even though we update values within the file.

If i edit the WF and select the file again it reads the new content.

How can i implement this to happen on a daily basis from the scheduled task or clear the vCO cache?

thanks.

0 Kudos
1 Solution

Accepted Solutions
iiliev
VMware Employee
VMware Employee

Another option (if keeping the mime attachment input parameter is desirable for eg. its nice file chooser) is not to use the input parameter directly but instantiate a new MimeAttachment object via scripting passing the name of the input parameter. For example, if your have input parameter called 'mime' of type MimeAttachment, in your scripting you should do something like the following:

var directory = ...; // somehow specify the directory where the file is located

var mime2 = new MimeAttachment(mime.name);

var content = mime2.content; // use the actual refreshed content

This way, every time the scheduled workflow is executed, a new MimeAttachment object will be instantiated with the current content of the file.

The problem is how to specify the full path to the file. MimeAttachment's name property returns only the file name part without the folder part, so if you select c:/some/path/file.txt in the MimeAttachment file chooser, then mime.name will return only the file name part file.txt. So you have somehow to find the folder part, for example use a separate input parameter/attribute/configuration, or by convention use a hard-coded location.

View solution in original post

0 Kudos
8 Replies
tschoergez
Leadership
Leadership

I think that's by design: The content of the file is stored at the time you schedule the workflow, and pick the file (so, only once).

You can try to change the logic, not using a mime attachement as input parameter, but use the FileReader object within javascript.

This always reads the actual content from the file whenever it's being executed, so it should also work in a scheduled workflow.

Regards,

Joerg

0 Kudos
iiliev
VMware Employee
VMware Employee

Another option (if keeping the mime attachment input parameter is desirable for eg. its nice file chooser) is not to use the input parameter directly but instantiate a new MimeAttachment object via scripting passing the name of the input parameter. For example, if your have input parameter called 'mime' of type MimeAttachment, in your scripting you should do something like the following:

var directory = ...; // somehow specify the directory where the file is located

var mime2 = new MimeAttachment(mime.name);

var content = mime2.content; // use the actual refreshed content

This way, every time the scheduled workflow is executed, a new MimeAttachment object will be instantiated with the current content of the file.

The problem is how to specify the full path to the file. MimeAttachment's name property returns only the file name part without the folder part, so if you select c:/some/path/file.txt in the MimeAttachment file chooser, then mime.name will return only the file name part file.txt. So you have somehow to find the folder part, for example use a separate input parameter/attribute/configuration, or by convention use a hard-coded location.

View solution in original post

0 Kudos
magander3
Enthusiast
Enthusiast

so when i try:


var file = "c:\\scripts\\vcoinput.csv";

System.log(file)

var mime2 = new MimeAttachment(file);

System.log(mime2)

I get the following:

[2015-04-13 18:26:11.454] [I] c:\scripts\vcoinput.csv

[2015-04-13 18:26:11.454] [I] Cannot create MimeAttachment : Permission denied on file 'c:\scripts\vcoinput.csv' , read not allowed

The user running the script got full control on the file.

i have also tried with the vmo.properties configuration com.vmware.js.allow-local-process=true

Any suggestion?

thanks

0 Kudos
magander3
Enthusiast
Enthusiast

thanks for suggestion. getting the same error as i describe below meaning the read permission error. Any idea?

thanks

0 Kudos
iiliev
VMware Employee
VMware Employee

For security reasons, file system access in JS is sandboxed. The admin has to explicitly grant access permissions (read/write/execute) for your directory/file in the file %vco-install-dir%\app-server\conf\js-io-rights.conf. In your case, you can add the following line that will grant read and execute permissions to folder c:\scripts

+rx C:/scripts/

and restart vCO server.

magander3
Enthusiast
Enthusiast

yeah, i recall this being a config setting so i added the config to vmo.properties and i don't get the read permission error but maybe it's better to add it to js-io-rights.conf?

Now it's just a matter of getting the code to read the file since System.log comes back empty when adding the .content stuff.

thanks

0 Kudos
tschoergez
Leadership
Leadership

you have to specify both, the vmo.properties parameter and the js-io-rights.conf.

And of course make sure that the file system permissions are good for the user the vRO service runs with.

magander3
Enthusiast
Enthusiast

interesting, i only got it in the js-io-rights.conf. now and it works.

0 Kudos