0

Duplicate a sub-table while omitting fields.

I have a table that I duplicate using a button and a script for which I received help on this forum. This table has a sub-table which is also duplicated. But I would like certain fields in this sub-table not to be copied. For example, I have "quote #" for which I have entered the following code: 'quote #' := null. But this only works for the first row of the sub-table. The others keep their data. Is there any way of making each line change? A kind of loop, like in filemaker?
Thank you.

9 replies

null
    • Fred
    • 1 mth ago
    • Reported - view

    Can you post your code for the button?

    • pascalp
    • 1 mth ago
    • Reported - view

    Sure:

    let newRecord := duplicate(this);
    popupRecord(newRecord);
    newRecord('Request date' := today());
    newRecord.('Due on' := null);
    newRecord.('Proposal date' := null);
    newRecord.(Suppliers := 0);
    newRecord.('Quote lines' 'quotes #':= null)

    (Quote lines being the sub-table)

    I searched for loop in the Ninox documentation, but I didn't get any results.

      • Fred
      • 1 mth ago
      • Reported - view

       

      newRecord.('Quote lines' 'quotes #':= null)
      

      doesn't give you and error?

      It should read:

      newRecord.('Quote lines'.'quotes #':= null)
      

      That should set 'quotes #' to null in all related records in 'Quote lines'.

      • pascalp
      • 1 mth ago
      • Reported - view

       I forgot the dot when I copied here, but it's correct in my script. And no, it only replaces the first line.

      • Ninox partner
      • RoSoft_Steven.1
      • 1 mth ago
      • Reported - view

       

      Very strange only the first  'Quote lines' value is replaced by null.
      I tested 's suggested code and it works on my end. I'm using private cloud version.
      Maybe it has a different result on a native IOS version? Which one are you using?

      As for the loop, you can also use:

      for i in newRecord.'Quote lines' do
      i.('quotes #' := null)
      end

      But as I said Fred's version should also work.

      • pascalp
      • 1 mth ago
      • Reported - view

       It works. Thank you. 

      • Fred
      • 1 mth ago
      • Reported - view

      I just tried it on my iPad and:

      newRecord.('Quote lines'.'quotes #':= null)
      

      or something similar, works for me fine. I'm on v3.13.6 and test in iCloud and local DB.

      I have to say that writing code on the iPad takes me back to the old days of Ninox and those are not good memories. The iPad, and guessing iOS as well, does not allow auto completion, even while using the browser version.

      • pascalp
      • 1 mth ago
      • Reported - view

       Unfortunately, my Mac has broken down and all I have left is the iPad.

      • Fred
      • 1 mth ago
      • Reported - view

      Sorry to hear. If you got an answer please mark the post Answered when you have a moment.

Content aside

  • Status Answered
  • 1 mth agoLast active
  • 9Replies
  • 35Views
  • 3 Following