0

I need help with "do as server" script

Hi,

I have button for duplicating the record to subtable and also the items from records. Before the button is worked with this script:

let b1 := "Major";
let b2 := "Minor";
let b3 := "Zrusit NEKLONOVAT !";
let result := dialog("Otazka", "Klonovanie rozpoctu! Zvacsit verziu", [b1, b2, b3]);
let toto := this;
if result != b3 then
let newr := duplicate(this);
if result = b1 then
newr.('Major Version' := 'Major Version' + 1)
else
newr.('Minor Version' := 'Minor Version' + 1)
end;
newr.('Stav Rozpocet' := 2);
newr.('Parent Rozpocty' := toto);
newr.('Nazvov suboru' := "");
for p in 'RozpocetPolozky-tab' do
let newp := duplicate(p);
newp.(Rozpocet := newr);
newp.('Pomocna relacia na Rozpocet' := newr);
for subp in p.'RozpocetPolozky-sub' do
let newsubp := duplicate(subp);
newsubp.('RozpocetPolozky-parent' := newp);
newsubp.('Pomocna relacia na Rozpocet' := newr)
end;
let xi := 0;
for xp in newr.PDF do
delete xp
end
end;
popupRecord(newr)
end

But when I put there "do as server", it´s stop working. So I changed the position of "do as server" , but it´s not working for me. It made a copy of record (child record) but the items from record just duplicate in parent record and not in child like I want. Please help, bellow I am sending you the script.

1. option

let b1 := "Major";
let b2 := "Minor";
let b3 := "Zrusit NEKLONOVAT !";
let result := dialog("Otazka", "Klonovanie rozpoctu! Zvacsit verziu", [b1, b2, b3]);
let toto := this;
if result != b3 then
let newr := duplicate(this);
if result = b1 then
newr.('Major Version' := 'Major Version' + 1)
else
newr.('Minor Version' := 'Minor Version' + 1)
end;
newr.('Stav Rozpocet' := 2);
newr.('Parent Rozpocty' := toto);
newr.('Nazvov suboru' := "");
log := log + text(newr) + "
";
do as server
let lastr := last((select Rozpocty)['Parent Rozpocty' = toto]);
log := log + "Rozpoty Parent ID: " + text(lastr) + "
";
let xRP := (select RozpocetPolozky)[Rozpocet = toto];
log := log + "Pocet poloziek pre Duplikovanie: " + cnt(xRP) + "
";
for p in xRP do
let xnewp := duplicate(p);
log := log + "newp ID: " + text(xnewp.Id) + "
";
xnewp.(Rozpocet := 0);
xnewp.(Rozpocet := lastr);
log := log + "Lastr opat: " + text(lastr) + "
";
xnewp.('Pomocna relacia na Rozpocet' := lastr);
for subp in p.'RozpocetPolozky-sub' do
let newsubp := duplicate(subp);
newsubp.('RozpocetPolozky-parent' := xnewp);
newsubp.('Pomocna relacia na Rozpocet' := lastr)
end;
let xi := 0;
for xp in newr.PDF do
delete xp
end
end
end;
"popupRecord(newr)"
end

 

2. option

let b1 := "Major";
let b2 := "Minor";
let b3 := "Zrusit NEKLONOVAT !";
let result := dialog("Otazka", "Klonovanie rozpoctu! Zvacsit verziu", [b1, b2, b3]);
do as server

let toto := this;
if result != b3 then
let newr := duplicate(this);
if result = b1 then
newr.('Major Version' := 'Major Version' + 1)
else
newr.('Minor Version' := 'Minor Version' + 1)
end;
newr.('Stav Rozpocet' := 2);
newr.('Parent Rozpocty' := toto);
newr.('Nazvov suboru' := "");
log := log + text(newr) + "
";
let lastr := last((select Rozpocty)['Parent Rozpocty' = toto]);
log := log + "Rozpoty Parent ID: " + text(lastr) + "
";
let xRP := (select RozpocetPolozky)[Rozpocet = toto];
log := log + "Pocet poloziek pre Duplikovanie: " + cnt(xRP) + "
";
for p in xRP do
let xnewp := duplicate(p);
log := log + "newp ID: " + text(xnewp.Id) + "
";
xnewp.(Rozpocet := 0);
xnewp.(Rozpocet := lastr);
log := log + "Lastr opat: " + text(lastr) + "
";
xnewp.('Pomocna relacia na Rozpocet' := lastr);
for subp in p.'RozpocetPolozky-sub' do
let newsubp := duplicate(subp);
newsubp.('RozpocetPolozky-parent' := xnewp);
newsubp.('Pomocna relacia na Rozpocet' := lastr)
end;
let xi := 0;
for xp in newr.PDF do
delete xp
end
end
end;
"popupRecord(newr)"
end

Thank you

Reply Oldest first
  • Oldest first
  • Newest first
  • Active threads
  • Popular
Like Follow
  • 2 yrs agoLast active
  • 617Views