How to complete my Java script to rename file in new version if exist

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Active Member II

How to complete my Java script to rename file in new version if exist

Hi !

I have a rules set like this :

If name file start with "BondeCommande" so execute MyJavaScript-toRename.js

MyJavaScript-toRename.js =

var numero =  document.properties["alah:BDC-SEDIT-propriete"];
var tiers =  document.properties["alah:BDC-SEDIT-LibelleTiers"];
var libelle =  document.properties["alah:BDC-SEDIT-ObjetCommande"];
document.name = "BC" + "_" + libelle + "_" + tiers + "_" + numero + ".pdf";
document.save()

It work good.

But if a new file come in the same folder, i have an error "already exist".

I need your help to complete my JS to add condition if exist so replace in a new version 1.1.

Can you help me ? 

Please don't ask to me to use webscript, i'm so far to understand this...

Thank you  !