Auto create records in sub-table
I have a table: "TRAINING". Inside that table, I have a sub-table: "TOPICS"
I know that it's possible to have a button, creating let's say 10 records in the sub-table when clicked (every training plan I make needs the same basic initial topics - to be tailored afterward)
Any good button-coding-ideas in here ?-)
Thanks, John.
10 replies
-
John,
let me := this;
for i from 0 to 10 do
let p := (create TOPICS);
p.(TRAINING := me)
endSteven
-
Thanks a lot, Steven - and now I just realize that my question was not very clear - the real need I have, is actually to create let's say these 10 records, but with individual predefined content in the "Name" field of each record.
I have done something a bit like this in the past, but in that case the value creation was based on the values of a dropdown field:
let me := this;
let counter := 1;
for i from 1 to 35 do
let new := (create ASSESS);
new.('SP-solution' := me);
new.(WPQCDK := counter);
counter := counter + 1
endthis time I don't have a drop-down field, but would like to have the content put directly in the "creation code" - if that makes sense ? or perhaps I could make a dropdown and combine that with a "let do" function field (I'm confusing myself now )
J-)
-
"Switch Do" function of course
-
John,
we can make an array for this.
let me := this;
let arr := [code1,code2,code3,code4,code5,code6,code7,code8,code9,code10]
for i from 0 to 10 do
let p := (create TOPICS);
p.(TRAINING := me;
'creation code' := item(arr,i)
endSteven
-
Oops, 'creation code' should be Name
-
You can also leave the counter-part in jour example and use the i.
new.(WPQCDK := i);
-
Thanks Steven.
I'll have a play with it this weekend.
Have a nice one
J-)
-
Tested and found another fault, this works:
let me := this;
let arr := ["code1", "code2", "code3", "code4", "code5", "code6", "code7", "code8", "code9", "code10"];
for i from 0 to 10 do
let p := (create TOPICS);
p.(TRAINING := me;
Name := item(arr,i)
)end
Steven
-
May I suggest a slight variation? The advantage is that, if the set of named topics changes, one must just update the vector, without needing to also separately update the number of elements.
let me := this;
let arr := ["code1", "code2", "code3", "code4", "code5", "code6", "code7", "code8", "code9", "code10"];
for n in arr do
(create TOPICS).(
TRAINING := me;
Name := n
)
end
-
Thanks guys, very much appreciated !!
Work like a clock !! - but what if I would like to set the value of the dropdown field: "Category", in the TOPICS record at the same time - could that be written in the same piece of code?
Outcome like:
Category Name
1 "Code1"
2 "Code2"
etc.
Have tried some stuff myself - didn't work out well :)
Content aside
- 3 yrs agoLast active
- 10Replies
- 655Views