cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

How to create a new folder and open the same using javascript from triggers?

Highlighted
Guest

How to create a new folder and open the same using javascript from triggers?

My intention is to create a new folder when a field is checked in an Item type using triggers.

I found difficulty in writing javascript to do the same as it does not support ActiveX to access the file base.

Node js can be used but it does not seem to work with PTC

11 REPLIES 11

Re: How to create a new folder and open the same using javascript from triggers?

Hello,

can you please let us know your business case. Otherwise it would be difficult for us to answer.

Are you asking about our Integrity Trigger capabilities?

Volker

Re: How to create a new folder and open the same using javascript from triggers?

Hello Volker,

The actual requirement is that, we have a common shared folder where we store large documents which cannot be a part of attachment for a item type.

For example, I create an item type "Bug" with the Item ID 81234, there is an option called "Attach large files". If that option is checked, I want a trigger to automatically create a folder by the name "ID_81234" and open the same as soon as the user creates the item type "Bug".

To achieve this, I am in need to create and open folders using JavaScript for triggers.

Re: How to create a new folder and open the same using javascript from triggers?

Hello Sujith,

this explains a bit more.

What you exactly mean by "open the same".

Open in what?

What I have understood is that you are going to crerate an issue and you plan to automate to create a corresponding project (or folder) in Integrity Source.

Usually, you create a sandbox to upload some data into Integrity Source.

Do you consider to use a local sandbox?

Re: How to create a new folder and open the same using javascript from triggers?

Hello Volker,

I do not want to create a source project and this is not at all related to Integrity Source. All I need a physical folder to be created in a computer which is shared by all. It should just be a normal local folder in a Windows operated system.

Re: How to create a new folder and open the same using javascript from triggers?

Hello Sujith,

understand. To my knowledge you cant include any custom code right into triggers to execute local commands.

Triggers are on server, not local.

The only chance I see is to create a custom button (bat file, or java) - behind it you can perform any local operation.

Re: How to create a new folder and open the same using javascript from triggers?

Hello Volker,

That is right. Now is there a possibility that I can run a batch file upon success of a trigger?

Thanks

Re: How to create a new folder and open the same using javascript from triggers?

Hello Sujith,

a trigger runs on server, not on client. No, you cant run any local post action in Integrity Standard.

Assuming your shared drive is on another server, you may develop a listener which catches the item creation events ...

Not sure if this is an option for you.

Re: How to create a new folder and open the same using javascript from triggers?

You can use Java objects within the JavaScript trigger to do file IO e.g.

var propsFile = new java.io.File(propsFileName);

// Make missing directories

propsFile.getParentFile().mkdirs();

var tempOS = new java.io.FileOutputStream(propsFileName, true);

tempOS.close();

// Check that there is write access to the file

if( ! propsFile.canWrite() ){

  abortTrigger("ERROR:  Cannot access file: " + propsFileName);

}

Re: How to create a new folder and open the same using javascript from triggers?

Hello Jason,

Thank you for the response. For now my requirement does not include file IO operations. It is just simple folder creation and access.

Can I use mkdirs() or any similar functions to create a folder through trigger?

Thanks

Announcements