0

Choice field repeat the value of the previous day

There is a Choice field where there are several options. When creating a new record, i need the value of this Choice field to transfer to the next day. Please advise the formula

20 replies

null
    • Fred
    • 7 mths ago
    • Reported - view

    Just add the name of the field and make it equal to the same name field:

    let t := this;
    let newRec := (create Table2);
    newRec.(
        MultiChoice := t.MultiChoice;
        Country := t.Country
    )
    

    MultiChoice is a simple multiple choice field.

    Country is a dynamic choice field.

      • iliper LTD
      • iliper_LTD
      • 7 mths ago
      • Reported - view

       Hi
      I have a dynamic Choice with name "Category", and the table name is "dili Result". i create formula 
       

      let t := this;
      let newRec := (create 'Daily Result');
      newRec.(
      Category:= t.Category;
      )

      and registered it in the table settings - trigger on new Record. Didn't work 

      • Fred
      • 7 mths ago
      • Reported - view

      You didn't say it was in a trigger on new Record. 🙂

      You will have to put this in a button to create the new record and copy the data. The Trigger doesn't have a reference point for "this" so it can't copy anything.

      • iliper LTD
      • iliper_LTD
      • 7 mths ago
      • Reported - view

       I forgot to say about this, sorry)
      I created a button outside the table to create a new record and then in the table,  but it didn’t work.

      I'm probably doing something wrong?

      • iliper LTD
      • iliper_LTD
      • 7 mths ago
      • Reported - view

       I have a formula field in another table

      let c := number(Id);
      let bc := last((select 'CASH DESK' where number(Id) < c) order by number(Id));
      first(select 'CASH DESK' where Id = bc).'CLOSE 1'
      

      when I create a new day, it itself takes information from the required field, from the previous entry. I was thinking of doing something like this

    • Fred
    • 7 mths ago
    • Reported - view
     said:
    I created a button outside the table to create a new record and then in the table,  but it didn’t work.

     Create the button in the table that has the Category field, which I guess is Daily Result?

    Try not to do too many select statements in Ninox:

    let c := number(Id);
    let bc := last((select 'CASH DESK' where number(Id) < c) order by number(Id));
    first(select 'CASH DESK' where Id = bc).'CLOSE 1'
    

    You have a select statement in lines 2 and 3.

    From my reading of it you don't need the line 3 select since you are referring to the record you found in line 2. So you can rewrite line 3:

    let c := number(Id);
    let bc := last((select 'CASH DESK' where number(Id) < c) order by number(Id));
    bc.'CLOSE 1'
    
      • iliper LTD
      • iliper_LTD
      • 7 mths ago
      • Reported - view

       Hi

      there is a table "Daily result" with Choice Field  "Category"

      Recordin in this table created with this button 

      I need the record to be clean, it just needs to go through the value of the Choice  field

      This is so that you can track changes in client category, without going into the table.

    • Fred
    • 7 mths ago
    • Reported - view

    This is so that you can track changes in client category, without going into the table.

    Well then you just need to figure out which record you need to pull the data from. If you order 'Daily Result' by Date, do you need the last record? If so then you can change the code to:

    let t := last('Daily Result' order by Date);
    let newRec := (create 'Daily Result');
    newRec.(
    Category:= t.Category;
    )
    

    this would go in a button at the parent table of Daily Result.

    • Fred
    • 7 mths ago
    • Reported - view

    I forgot to add the part of linking it to the parent record.

    let t := this;
    let oldData := last('Daily Result' order by Date);
    let newRec := (create 'Daily Result');
    newRec.(
    ParentRecordFieldName := t;
    Category:= oldData.Category;
    )
    

    If you look at the Daily Result table you will see the new records there just not linked to the parent record.

    • Fred
    • 7 mths ago
    • Reported - view
     said:
    Fred I saw it, but didn’t understand how to do it ) Parent Record - what should I write there?

     You show a screenshot of a record that has the 'Daily Result' table in it. In the 'Daily Result' table there is a reference field name that points to this table put name of the reference field in Daily Result.

      • iliper LTD
      • iliper_LTD
      • 7 mths ago
      • Reported - view

      Fred 

      let t := this;
      let oldData := last('Daily Result' order by Date);
      let newRec := (create 'Daily Result');
      newRec.(
          Category := t;
          Category := oldData.Category
      )

      name of this Field is CATEGORY the name of the field, Choice Field, that should appear to be called that way

      • Fred
      • 7 mths ago
      • Reported - view

      iliper LTDForget for a second the category field, You want to also link the parent record to the new Daily Result record as well. If you look in the Daily Result table you will see the new records you have created they are just not linked to any records in the parent table.

      You sent me a sample DB, is the parent table Cashier? In the Daily Result table there is probably a reference field called Cashier. You might have renamed it. That is the name you put in place of ParentRecordFieldName.

      let t := this;
      let oldData := last('Daly result' order by Date);
      let newRec := (create 'Daly result');
      newRec.(
          Cashhier := t;
          Category := oldData.Category
      )
      
      • iliper LTD
      • iliper_LTD
      • 7 mths ago
      • Reported - view

       this is how they are connected

      • Fred
      • 7 mths ago
      • Reported - view

       

      let t := this;
      let oldData := last('Daly result' order by Date);
      let newRec := (create 'Daly result');
      newRec.(
          'LIST OF PLAYERS' := t;
          Category := oldData.Category
      )
      

      The button is in List of Players.

      • iliper LTD
      • iliper_LTD
      • 7 mths ago
      • Reported - view

      Works great, Thanks  

Content aside

  • Status Answered
  • 7 mths agoLast active
  • 20Replies
  • 79Views
  • 2 Following