0

Script problem.

do as server
    let me := this;
    for i in select 'Task templates' do
        let new := (create Tasks);
        new.(
            void;
            Status := 1;
            'N1 Main Table' := me;
            'Assigned Date' := date(year(me.'Start date'), month(me.'Start date'), day(me.'Start date') + i.'Days until (from) start date');
            'Task Name' := i.'Task Templates';
            Phase := i.Phase;
            Supervisor := i.Employee
        )
    end
end

 

Copy

 

This script takes the data from the 'Task Template' Table and copies all the records to the 'Main Table', in '1N All Task'.
 Is there some way to only copy the last or last one included, not all records.

7 replies

null
    • Fred
    • 6 mths ago
    • Reported - view
     said:
     Is there some way to only copy the last or last one included, not all records.

    You only want to copy the last record in the Task Template table? Have you tried the last() command?

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

    Yes Fred but don't know where place the last() command

    • Fred
    • 6 mths ago
    • Reported - view

    If you only want the last record then you don't need a for loop. You can try this modification:

    do as server
        let me := this;
       let i := last(select 'Task templates');
            let new := (create Tasks);
            new.(
                Status := 1;
                'N1 Main Table' := me;
                'Assigned Date' := date(year(me.'Start date'), month(me.'Start date'), day(me.'Start date') + i.'Days until (from) start date');
                'Task Name' := i.'Task Templates';
                Phase := i.Phase;
                Supervisor := i.Employee
            )
    end
    
      • Rafael Sanchis
      • Rafael_Sanchis
      • 6 mths ago
      • Reported - view

       Fred in the line 3 Error: Table not Found 'Task Templates' 

      • Fred
      • 6 mths ago
      • Reported - view

      How did it work before since it using the same table reference.

      Just put the correct table name.

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

      Fred the same Name table.  'Task Templates'

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

      Fred Hi Fred, now work but need to delete the old formula and write it again. (The copy paste don't work) Thanks and sorry 

      do as server
          let me := this;
          let i := last(select 'Task Template');
          let new := (create 'Following Tasks');
          new.(
              void;
              Status := 1;
              'N1_Main Table' := me;
              'Date Assigned' := date(year(me.'Start date'), month(me.'Start date'), day(me.'Start date') + i.'Days until (from) start date');
              'Task Name' := i.'Task Templates';
              'Phase on Task' := i.'Phase on Task Template';
              Supervisor := i.N1_Staff
          )
      end

Content aside

  • Status Answered
  • 6 mths agoLast active
  • 7Replies
  • 70Views
  • 2 Following