0

Create new record with outside button

Hello everyone, there is a “daily result” table and a button that is not in this table. I need to program the button so that it creates a new record in the table “daily result”  and copies the value of the choice field "CHOICE" and open new record

7 replies

null
    • Fred
    • 1 mth ago
    • Reported - view

    Take a look at your hotel DB. Isn't there a button that creates records in other tables?

      • iliper LTD
      • iliper_LTD
      • 1 mth ago
      • Reported - view

       Thanks 

      let t := this;
      let newRes := (create 'Daily Result');
      newRes.(Date := t.Date);

      won't work, something is probably wrong

      • iliper LTD
      • iliper_LTD
      • 1 mth ago
      • Reported - view

       

      let t := this;
      let oldData := last('Daily Result' order by Date);
      let newRec := (create 'Daily Result');
      Date := t.Date + 1;
      newRec.('List of Customers' := t)

      this works well, but I can't copy the field "Choice" values, it is necessary that all values from the previous day are transferred to the new day

      • Fred
      • 1 mth ago
      • Reported - view

      I don't see the field 'Choice' in the code. If the choices in the two choice fields have the same choice numbers and text then you can try:

      newRec.(
          'List of Customers' := t;
          Choice := t.Choice
      )
      

      Or you can try text() around t.Choice if the choice numbers don't line up.

      • iliper LTD
      • iliper_LTD
      • 1 mth ago
      • Reported - view

       Hi

      let t := this;
      let oldData := last('Daily Result' order by Date);
      let newRec := (create 'Daily Result');
      Date := t.Date + 1;
      newRec.(
          'List of customers' := t;
         Choice := t.Choice
      )

      not the cat copies the 'Choice' field values

    • John_Halls
    • 1 mth ago
    • Reported - view

    Hi  Can you use the duplicate() function. Sub-tables are duplicated with the relationship intact.

    let t := this;
    let oldData := last('Daily Result' order by Date);
    let newRec := duplicate(oldData);
    newRec.Date := t.Date + 1
    

    Also, would 

    newRec.Date := today()
    

    be better as t.Date+1 might not bring you up-to-date if today is Monday and the last Daily Result was Friday. And then your code would be even shorter

    let oldData := last('Daily Result' order by Date);
    let newRec := duplicate(oldData);
    newRec.Date := today()
    

    Regards John

      • iliper LTD
      • iliper_LTD
      • 1 mth ago
      • Reported - view

       Thanks

      Both formulas transfer the value of the choice field. But the first formula when creating a date creates for the 29th, today is the 22nd

      Thanks for help

Content aside

  • Status Answered
  • 1 mth agoLast active
  • 7Replies
  • 48Views
  • 3 Following