This is a beginner but I haven't been able to figure it out.
This is a beginner but I haven't been able to figure it out.
This work for copy one record to another table, but need to copy all from Documents table to Control table.
let xResponse := dialog(" ADD Document -> ", "Do you want to ADD All Document To Control Document ?", ["Yes", "CANCEL"]);
if xResponse = "Yes" then
let me := this;
let newR := (create Control);
newR.(
'Documents_>' := me;
let nameDoc := me.'Name Document';
let coddoc := me.CodDOC;
let start := me.Start;
let finish := me.Finish;
newR.('Name Document' := nameDoc);
newR.(CodDOC := coddoc);
newR.('Plan 1 Editable' := start);
newR.('Plan 5 Editable' := finish);
last(popupRecord(newR));
'Protect Plan Dates' = true
)
end
4 replies
-
Take a look at this post. Give it a try and let us know if you have any further questions.
-
That is a good start. The best way to learn is to try.
Let us step through your code.
let me := this; let newR := (create Control); for s in select Documents do newR.( 'Documents_>' := me;
You start with creating a variable 'me' that stores the current record you are on. Then you create a variable 'newR' that stores the record Id of the newly created record in Control. Then you start a for loop that loops through the Documents table. For each instance in the loop it will modify the newly created record in Control with the data from only the current record through the me variable.
You are only creating 1 new record since the create command is outside of the for loop. Then you are modifying the new record with information only from the current record when it should be from the for loop.
So you need to start with your for loop then put the create code inside the loop and reference the loop variable to update fields in the newly created record.
So give it a try, but may I suggest you create a new button and remove all other code and just do something very simple like the create and the link to Documents. I would also suggest you modify your select to only do 2 or 3 records and not all of your records.
I'll post what I think would work, but try it first by yourself and come back if you have questions.
for s in (select Documents Id < 4) do let newR := (create Control); newR.( 'Documents_>' := s ) end
Content aside
- Status Answered
- 7 mths agoLast active
- 4Replies
- 60Views
-
2
Following