User interface automation
I use Ninox on iPad and am trying to implement some user interface automation to create a switchboard of buttons for single click user access to different database activities. Generally this has been straightforward, but I have run into two problems that I can't resolve.
1. Trying to use the printRecord function gives the message "Function is not defined: printRecord(rid,string) at...", even though using openPrintLayout with exactly the same recordId and layoutName works perfectly. Is this a bug or is the printRecord function not implemented on the iPad version for some reason?
2. I want one of the buttons to open a form at a new record. I feel sure this must be possible using the openRecord(recordId) function, but cannot work out how to obtain the ID for a new record. This is probably me being obtuse, but if somebody could point me in the right direction, I would be very grateful.
Many thanks for your help,
John
16 replies
-
Hi John,
for New Record creation use this code:
let myD := this;
let myP := (create ’Table Name');
openRecord(myP)
Nick
-
...and for printing have you tried:
printRecord(recordId, "myPrintlayoutName")
e.g. printRecord(this, "Print")
Nick
-
Hi Nick,
Thanks for coming to my rescue once again (ie https://ninoxdb.de/en/forum/technical-help-5ab8fe445fe2b42b7dd39ee7/single-page-formatted-print-of-all-records-in-a-table-5bbeea6025979e54233efaea?post&)!
Your solution for my New Record problem works perfectly of course (although without the first line, which appears unnecessary). As i thought, I was being slightly obtuse, having got hung up on following the syntax shown for the openRecord example in the manual, not realising I did not need to use the record function as I already had the required recordID from the create function.
With regard to the printRecord problem, yes - that is exactly what I have tried. For me, using the iPad version,
openPrintLayout(record('My Table Name', 1), "My Layout Name")
works perfectly whilstprintRecord(record('My Table Name', 1), "My Layout Name")
produces the 'Function is not defined' error. Have you successfully used the printRecord function and, if so, was this on the iPad version of Ninox?Once again, many thanks for your help,
John
-
Hi John,
this works using the iPad (tested),
printRecord(this, "My Layout Name")
Nick
-
Hi Nick,
I have investigated a bit further and find that
printRecord(this, "My Layout Name")
does indeed work as you say, but thatprintRecord(record('My Table Name', 1), "My Layout Name")
, which is the syntax specified in the manual, does not. Are you able to confirm this observation? If so, I can only assume it is a bug, although I cannot find any bug reporting facility on the Ninox website. Do you know how I go about it - another forum message?In my case, where I have created a dummy table containing 1 record and no data fields (apart from Id obviously) to host the switchboard form, I cannot use the
this
syntax as I am trying to print a different table from the one where the button and its code reside. So can you think of any other way to circumvent this problem? If not, I will use theopenPrintLayout
function for now, which works and gets me very close to what I was trying to achieve, until theprintRecord
function is fixed.As ever, thanks for your help,
John
-
John, you are right! The function
printRecord(record('My Table Name', 1), "My Layout Name")
produces an error.
Maybe someone from the support puts this to Bugs category.
Nick
-
Thanks Nick - I'll report this on the Ideas & Suggestions section of the forum.
-
printRecord(this, "My Layout Name")
The code snippet in the manual seems to need an update.
Best regards, Alex
-
Hi Alex,
I am not sure what you are trying to say. We have already confirmed that the 'this' syntax does indeed work but that it is unsuitable in my case, which requires the syntax given in the manual (see posts #5 & #6 in this thread). Since you talk about changing the manual, are you suggesting that the manual code is wrong and that
printRecord(record('My Table Name', 1), "My Layout Name")
is deliberately designed not to work? This seems most unlikely and I can see no reason for it, especially asopenPrintLayout(record('My Table Name', 1), "My Layout Name")
works perfectly (see post #4). Therefore, I still consider this to be a bug which requires fixing.John
-
You should be able to use a for loop with 'this' to do what you want to do. I haven't tested it.
This is the example support gives:
for i in select table where fieldA = "AB" do
printRecord(this,"name")
end
-
I didn't get it to work using 'this', but I did get it to work like this:
for i in select Table do
printRecord(i, "name")
end -
Thanks for the tip - I'll give it a go. But I still think it would be preferable to fix the printRecord function so that it worked properly.
John
-
It looks like printRecord requires a nid.
OpenPrintLayout, openRecord, and popupRecord all works with both rid and nid.
-
So I guess a workaround for the original issue would look something like this:
let myP := (create Table);
for i in (select Table)[Id = myP.Id] do
printRecord(i, "name")
end -
The for loop is kindof ugly. This puts it in one line:
let myP := (create Table);
printRecord(first((select Table)[Id = myP.Id]) , "name")
-
lol. This works.
let myP := (create Table2);
printRecord(myP.Id, "name")
Content aside
- 6 yrs agoLast active
- 16Replies
- 6723Views