Function parameters - which types are possible
I've found this old post
And not really any docs on the topic.
Any changes on this?
Being able to call a function with parameters record, records, arrays, JSON - without workarounds is requested.
Thx
Jesper
46 replies
- 
  Sean said: 
 Maybe something is getting crossed in translation, but yes, you can pass a table object or a record object as an argument to a user defined functionNo, it's not a NID (table) or RID (record) variable but just an Any variable. This is very different. Similarly, the Eval function returns a variable of type Any, not of type NID or RID. That's why you can't use the result as a normal Select. The Select function returns an NID type (try: debugValueInfo(select Customer) in console ) 
 The Record function returns an RID type (try: debugValueInfo(record(Customer,1)) in console ).
 And now try this in the console:var a :={table : select Customer, 
 rec : record(Customer,1)};
 debugValueInfo(a.table);
 When calling a function with a JSON parameter, Ninox transforms the NID into Any.
- 
  I discovered that it was possible to pass a record as a parameter to a function. To do so, you just have to put the name of the table instead of the data type (node : Customer). function myRecord(node : Customer) do var name := node.'First Name' + " " + node.'Last Name'; name end; myRecord(first(select Customer))I don't know what we'll be able to do with it yet, but I'm sure we'll find 
- 
  I toyed around with this...  ...and came to the facepalm realization that formatJSON and parseJSON will accomplish the same thing and is a little tidier. function myFunction(tbl : text) do let myTable := parseJSON(tbl); alert("Record count: " + count(myTable) + " Name1: " + item(myTable, 0).Name + " Name2: " + item(myTable, 1).Name) end; myFunction(formatJSON((select Vendor)[text(State) = "AR"].[{ Name: Name, Address: Address }])) Unfortunately, the data is readonly when used in a function this way. 
- 
  Hi, fairly new to Ninox and now in the process of "tidying" up a database which has become a bit untidy in terms of number of fields and duplication, this thread sort of fits with what I am trying to achieve but I can't seem to make it work my aim is to have a master table and 2 child tables (soon to add a third) and for the master to pull the data from the child tables. What I have ended up with is 3 functions which I would ideally like as a single function and the key is to pass the table name & required fields into the select statement. So what I have is this Formula P1 let t := this; 
 let SELFIL := (select table2 where 'order-id' = t.'Channel reference');
 SELFIL;
 SELFIL.'product-name'Formula P2 let t := this; 
 let SELFIL := (select table3 where 'Order Number' = t.'Channel reference');
 SELFIL;
 SELFIL.'Product Name'Formula Product Name if P1 = "" then P2 else P1 end Sorry if this is basic but I am not a coder Thanks in advance 
Content aside
- 
    3
    
      Likes
    
- 2 yrs agoLast active
- 46Replies
- 2124Views
- 
    10
    Following
    
