0

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
Like Follow
12replies
-
The possible types for a function are :
- text
- number
- date
- datetime
- time
- timeinterval
- appointment
- boolean
- html
- color
- icon
- phone
- location
- file
- user
- any
with user type, you could call with single user or array of user :
function myFunction(myUser : user) do userName(myUser) end; myFunction(user())
or
function myFunction(myUsers : user) do join(for u in myUsers do userFullName(u) end, ", ") end; myFunction(users())
With the any type you can call with a JSON variable :
function myFunction(a : any) do capitalize(text(a.firsName)) + " " + upper(text(a.lastName)) end; myFunction({ firsName: "Jacques", lastName: "TUR" })
You can also call with array of JSON variable :
function myFunction(t : any) do "// recover the array from JSON array"; "// and return the array filtred and sorted"; var c := for i in t.table do i end; c[lastName like "T"] order by this.firstName end; "//call with array of JSON"; myFunction({ table: (select Customer).[{ firstName: 'First Name', lastName: 'Last Name' }] })
And, of course, call with table result :
function myFunction(t : any) do "// constructs an array of records identical to the one obtained with the Select function"; "// the ID number is gotten by keeping only the number part in order to call the Record function"; var c := for i in t.table do record(Customer,number(extractx(text(i), "\d.*"))) end; c.('First Name' + c.'Last Name') end; myFunction({ table: select Customer })