Problem with a script that works writing a file

83 views
Skip to first unread message

Fabio Palma

unread,
Sep 7, 2017, 10:43:33 AM9/7/17
to mementodatabase
Hi,
I created a script to extract a customized csv file from many libraries and it works great; these libraries are shared in my team and I need that those users can produce the file from their PC, but when they launch the script the file is not generated.
The path is generic and the target folder exists, I think that may be a problem with authorization to write files.
Can somebody help me, please?
Thanks in advance.

Bill Crews

unread,
Sep 7, 2017, 10:48:39 AM9/7/17
to mementodatabase
I haven't personally done this, but there is a shield icon in the top bar in the script edit card that provides authorization options for the script, and some of them, as I recall, are read, write, etc for files. Try setting those.

Fabio Palma

unread,
Sep 7, 2017, 11:28:39 AM9/7/17
to mementodatabase
Unfortunately that windows do not appears on the devices of the other team users, both for the desktop version and the android version... 

Antonio P

unread,
Jan 23, 2018, 3:16:35 AM1/23/18
to mementodatabase
Hola, podrias mostrarme tu script para exportar a csv, no tengo ni idea de java y me gustaria intentar adaptarlo para mis bibliotecas.
Gracias de antemano

Fabio Palma

unread,
Mar 10, 2018, 7:32:43 AM3/10/18
to mementodatabase
Scusami per il ritardo

var termine = arg("Fino a tutto il");
var entries = lib().entries();
var nofi = lib().title+"_"+moment().format('DD-MM-YYYY - H-mm');
var nomefile = "C:/Memento/Schede_inviate/"+nofi+".csv";
var line = "data; iniz_per; iniz_att; fine_att; cod_att; matr_1; operat_1; matr_2; operat_2; matr_3; operat_3; matr_4; operat_4; targa; turno; abitato; comune; ISTAT; lat; long; indirizzo; matricola/impianto; lettura; foto; cdc; percorr; durata; tot; mp; ma; mpe; missione; note"
;
for (var i = 0; i < entries.length; i++){
f = file(nomefile);
var data_ter = entries[i].field("Data");
var vali = entries[i].field("Validazione Caposquadra");
if (data_ter <= termine && vali == 'OK') {
var data = moment(entries[i].field("Data")).format('DD/MM/YYYY');
var iper = moment(entries[i].field("Inizio percorrenza")).format('H:mm');
var iatt = moment(entries[i].field("Inizio attività")).format('H:mm');
var fatt = moment(entries[i].field("Fine attività")).format('H:mm');
var codatt = entries[i].field("Codice attività")[0].field("Codice");
var opem1 = entries[i].field("Operatori")[0].field("Matricola");
var open1 = entries[i].field("Operatori")[0].field("Cognome")+" "+entries[i].field("Operatori")[0].field("Nome");
if (entries[i].field("Operatori")[1] != null){
var opem2 = entries[i].field("Operatori")[1].field("Matricola");
var open2 = entries[i].field("Operatori")[1].field("Cognome")+" "+entries[i].field("Operatori")[1].field("Nome");
}
else {
var opem2 = "";
var open2 = "";
}
if (entries[i].field("Operatori")[2] != null){
var opem3 = entries[i].field("Operatori")[2].field("Matricola");
var open3 = entries[i].field("Operatori")[2].field("Cognome")+" "+entries[i].field("Operatori")[2].field("Nome");
}
else {
var opem3 = "";
var open3 = "";
}
if (entries[i].field("Operatori")[3] != null){
var opem2 = entries[i].field("Operatori")[3].field("Matricola");
var open2 = entries[i].field("Operatori")[3].field("Cognome")+" "+entries[i].field("Operatori")[3].field("Nome");
}
else {
var opem4 = "";
var open4 = "";
}
var auto = entries[i].field("Automezzo")[0].field("Targa");
var turno = entries[i].field("Turno");
var abit = entries[i].field("Abitato")[0].field("Abitato");
var comune = entries[i].field("Abitato")[0].field("Comune");
var ISTAT = entries[i].field("Abitato")[0].field("Codice ISTAT");
if (entries[i].field("Posizione")!= null){
var lat = entries[i].field("Posizione").lat;
var lng = +entries[i].field("Posizione").lng;
}
else {
var lat = "";
var lng = "";
}
var ind = entries[i].field("Indirizzo").replace("\n", ' - ');
var indi = ind.replace("\n", ' - ')
var matric = entries[i].field("Matricola");
if (entries[i].field("Lettura")!= null){
var lett = entries[i].field("Lettura");
}
else {
var lett = "";
}
var note = entries[i].field("Note");
var foto = entries[i].field("Immagine");
var cdc = entries[i].field("CdC");
var perco = entries[i].field("Percorrenza");
var dura = entries[i].field("Durata");
var tot = entries[i].field("Totale");
var mp = entries[i].field("M_P");
var ma = entries[i].field("M_A");
var mpe = entries[i].field("M_PE");
var miss = entries[i].field("Missione");
var line = line+"\n"+data+"; "+iper+"; "+iatt+"; "+fatt+"; "+codatt+"; "+opem1+"; "+open1+"; "+opem2+"; "+open2+"; "+opem3+"; "+open3+"; "+opem4+"; "+open4+"; "+auto+"; "+turno+"; "+abit+"; "+comune+"; "+ISTAT+"; "+lat+"; "+lng+"; "+indi+"; "+matric+"; "+lett+"; "+foto+"; "+cdc+"; "+perco+"; "+dura+"; "+tot+"; "+mp+"; "+ma+"; "+mpe+"; "+miss+"; '"+note+"'";
entries[i].set("Validazione Caposquadra", 'Inviata');
}
}
f.writeLine(line);
f.close();
Reply all
Reply to author
Forward
0 new messages