I have navigation arrows the go to the next or previous record. I want to hide the arrow on the right if I am on the last record, and hide the arrow on the left if I am on the first record (see attached). How do I script fir this.
Left button (Previous) Hide Object Calculation : Get(RecordNumber) = 1
Right button (Next) Hide Object Calculation : Get(RecordNumber) = Get(FoundCount)
Some Users prefer the button to look grayed out instead of hidden, in that case you would use conditional formatting instead of Hide Object when and you might would want to use.
Get(RecordNumber) ≤ 1 and Get(RecordNumber) ≥ Get(FoundCount) because of the buttons not being hide.
Thanks, that works well. I don't know how to grey out a Button Icon so I went with Hide.
"Grey-out" is an interface change with conditional formatting. That does not stop the button from functioning. The "Hide" is a good method that removes the 'clickablility' of the object. However from an interface design, within a button bar a single button hide can shift the remaining button(s).
See this thread for some challenges and replies on elegant way to "hide":
If you want the button to not hide, and the button is SVG, you can change the fill color with conditional formatting provide by @schamblee. If it's attached to a script, you have to make tests within the script to prevent "click-through". I often do this:
(both buttons) call a script and pass a parameter called 'prev' (for previous), or 'next':
If ( Get(ScriptParameter) = "prev" AND Get(RecordNumber) > 1 ) ... step(s) to go back as many records as desired ...Else If ( Get(ScriptParameter) = "next" AND Get(RecordNumber) < Get(FoundCount) ) ... step(s) to go forward ...Else Exit Script (true)End If
If ( Get(ScriptParameter) = "prev" AND Get(RecordNumber) > 1 )
... step(s) to go back as many records as desired ...
Else If ( Get(ScriptParameter) = "next" AND Get(RecordNumber) < Get(FoundCount) )
... step(s) to go forward ...
Exit Script (true)
This allows navigation "back" (previous) from any record but the first, or "forward" (next) from the records before the last one in the found set. (Use the conditional formatting to 'grey-out', as well!)
You can trap for no records in the Script Parameter if desired, so that "prev" or "next" are NOT passed if there would be no records. Then the script just exits.
Another way to manage these buttons with a single script with parameters:
Go To Record/Request/Page [ dialog: off ; Get (scriptParameter ) // using calculation option ]
first record: 1
previous: Max ( Get ( recordNumber ) - 1 ; 0 )
next: Min ( Get ( recordNumber ) + 1 ; Get ( foundCount )
last: get ( foundCount )
Retrieving data ...