
Button to copy field entries from one field to another (running through entire table)
I have decided it will be better for some data in my system to sit within a subtable. As a result, I would like to copy the entries for certain fields into the new (identically named) fields within the new subtable.
I once found the code for a button that enabled me to do this for my whole workflow before, but can't find it again now...can anyone help please?
__
Master Database is called 'Workflow' (originally based upon the Ninox Project Management' template, but now in no way resembling it.
New Subtable is called 'Bike'
Fields to be copied over (and then deleted from the main table once successful):
Bike /Item
Main Colour
Serial #
Items Received
OTHER / Additional / Excluded (missing) Parts
The code I have (below) successfully performs this, but only for the single entry open when the button is triggered. I need it to run through all 926 records in the database. What have I done wrong?
let key := this;
let a := 'Bike / Item';
let b := 'Main Colour (Bike / Item)';
let c := 'Serial #';
let d := 'Items Received';
let e := 'OTHER / Additional / Excluded (missing) Parts';
let t := (create Bike);
Bike.('Bike Primary Key' := t.Id);
t.(Workflow := key);
t.('Bike / Item' := a);
t.('Main Colour' := b);
t.('Serial #' := c);
t.('Items Received' := d);
t.('OTHER / Additional / Excluded (missing) Parts' := e)
-
Hi Anna....
if this function runs successfully on a buttonclick in one entry, then you can easily paste this code into an loop
for p in select Workflow do
p.(
YOUR CODE
)
end
For every entry in Table Workflow it will perform the code within the brackets. in your example:
for p in select Workflow do
p.(
let key := this;
let a := 'Bike / Item';
let b := 'Main Colour (Bike / Item)';
let c := 'Serial #';
let d := 'Items Received';
let e := 'OTHER / Additional / Excluded (missing) Parts';
let t := (create Bike);
Bike.('Bike Primary Key' := t.Id);
t.(Workflow := key);
t.('Bike / Item' := a);
t.('Main Colour' := b);
t.('Serial #' := c);
t.('Items Received' := d);
t.('OTHER / Additional / Excluded (missing) Parts' := e)
)
end
-
Thanks everyone, I have created this, and it works!
for i in select Workflow do
let a := i.'Bike / Item';
let b := i.'Main Colour (Bike / Item)';
let c := i.'Serial #';
let d := i.'Items Received';
let e := i.'OTHER / Additional / Excluded (missing) Parts';
let f := i.'Workflow Id';
let i := (create Bike);
i.('Bike / Item' := a);
i.('Main Colour' := b);
i.('Serial #' := c);
i.('Items Received' := d);
i.('OTHER / Additional / Excluded (missing) Parts' := e);
i.(Workflow := f)
end