0

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

null
    • Fred
    • 7 mths ago
    • Reported - view

    Take a look at this post. Give it a try and let us know if you have any further questions.

      • Rafael Sanchis
      • Rafael_Sanchis
      • 7 mths ago
      • Reported - view

       

      I haven't been able to Resolve this 馃槳 I'm sorry but need some help. I know I should be able to Resolved it out but I blocked. 

      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);
              for s in select Documents do
          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))
          )
      end

      I have a Documents table with all Documents info, now need to transfer all Documents on Table Documents to Table Control. 

    • Fred
    • 7 mths ago
    • Reported - view

    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
    
      • Rafael Sanchis
      • Rafael_Sanchis
      • 7 mths ago
      • Reported - view

       

      Excelent explained,  I have transferred 752 Documents to Control Table without problems. 

      Again Appreciate your time 

Content aside

  • Status Answered
  • 7 mths agoLast active
  • 4Replies
  • 60Views
  • 2 Following