cancel
Showing results for 
Search instead for 
Did you mean: 

Javascript commands to get filename

vincent_roye
Champ in-the-making
Champ in-the-making
Hi,

I would like to create a script that will be triggered when a file is dropped in the repository. I will create a rule that is going to run the script at the right time.
I have installed the Javascript console to help me to create new scripts (it looks like the screenshot). I would like to know how to "simulate" a file that has just been dropped in and how to retrieve its name and store it in a variable.

Each time a file will be dropped in, an aspect will be attributed to it. In my script I would like to change the value of the property of an aspect. This is the next step but if someone could give me a few indications about how to get the freshly dropped filename it would be great.

Thanks,

Vincent
2 REPLIES 2

rjohnson
Star Contributor
Star Contributor
When your script runs it will have an object called document.

For example document name is document.name or document.properties["cm:name"]

To simulate this in JS Console, navigate to your document in share, click on it to load document details and then select "Use in javascript console".


var number = document.name.replace(".pdf","");
document.properties["sc:number"]=number;
document.save();