0

eval(uating)

I'm trying to make a selection from a known table, filtered and ordered by fields whose names are stored in other fields (or variables).

I can make it work with [eval(…)] as the filter, but then cannot get an 'order by' (using another indirection) clause working. I've tried to put the entire select string in the eval(), but it's not right. I've narrowed it done to this not working:-

let chans := eval("(select channels)", this);

 

Ninox doesn't complain and fetches the correct number of records from the channels table, but when I loop through the records (for chan in chans do etc.), fields referenced as e.g. chan.Name are blank, whereas if I make the selection directly without eval(), the correct value of chan.Name can be had.

So Ninox is selecting the correct records, but then their fields' data cannot be accessed. Anyone any ideas how to circumvent this or suggest any other method to be able to 'order by' a field whose name is held in another field/variable?

1 reply

null
    • UKenGB
    • 1 yr ago
    • Reported - view

    Got it. This works:-

    let ordby := "short Name";
    let theFilter := selexprec.filter;
    let chans := ((select channels)[eval(theFilter, this)] order by eval("'" + ordby + "'", this));
    

    I tried this before but it didn't work as I'd forgotten to add the ' either side of the orby field. Probably would be ok with a single word field name, but have to allow for spaces.

    The above is not final, but proof of concept that both the […] filter and the order by can use eval() - individually, but not all combined into a single string and then eval("string").

    Still puzzled though as to what Ninox is doing when the actual select is part of the eval as it does seem to be getting the correct records, but not able to access them which is odd.

Content aside

  • Status Answered
  • 1 yr agoLast active
  • 1Replies
  • 106Views
  • 1 Following