[Solved] Alfresco Javascript and counters.

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2007 09:21 AM
Hi all,
I am not sure if this is the correct place to post this question but I couldn't find anything more specific to writing scripts.
I have this piece of script I wrote. Without further delay here it is :
Fairly simple, any file dropped in the Space that executes this script creates some subdirectories and moves the file into this structure.
I also use a counter file which contains value 1 at start. So I first tried to increment the value by using
But what I actually get then is not "2" but "11".
So I added eval() brackets around the counter addition. But no joy… stil get 11 then 111 and so forth.
So my question is how do I add increase this value I get from the content in my recordFile using Alfresco Javascript.
(Also if anyone knows a better way to keep track of some sort of counter please tell me.)
I am not sure if this is the correct place to post this question but I couldn't find anything more specific to writing scripts.
I have this piece of script I wrote. Without further delay here it is :
var recordFile = companyhome.childByNamePath("counter.txt");if ( recordFile == null ) { recordFile = companyhome.createFile("counter.txt"); recordFile.content = "1";}if ( recordFile != null ) { var counter = recordFile.content; counter = eval(counter+1);}var rootbrief = companyhome.childByNamePath("Briefwisseling");rootbrief.createFolder("Dossier "+counter);var dossierfolder = rootbrief.childByNamePath("Dossier "+counter);dossierfolder.createFolder("Aanvraag");dossierfolder.createFolder("Antwoord");document.move(dossierfolder.childByNamePath("Aanvraag"));recordFile.content = counter;logger.log("Created dossier "+counter);
Fairly simple, any file dropped in the Space that executes this script creates some subdirectories and moves the file into this structure.
I also use a counter file which contains value 1 at start. So I first tried to increment the value by using
var counter = recordFile.content; counter = counter+1;
But what I actually get then is not "2" but "11".
So I added eval() brackets around the counter addition. But no joy… stil get 11 then 111 and so forth.
So my question is how do I add increase this value I get from the content in my recordFile using Alfresco Javascript.
(Also if anyone knows a better way to keep track of some sort of counter please tell me.)
Labels:
- Labels:
-
Archive
1 REPLY 1

Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-10-2007 09:37 AM
Ok I guess I was a bit early on the posting.
This does the trick just fine :
Good ol' c++
The question whether there is a better way to keep track of a number is still open for anyone interested.
This does the trick just fine :
var counter = recordFile.content; counter++;
Good ol' c++

The question whether there is a better way to keep track of a number is still open for anyone interested.
