Set Field [Parent::gRecordSet ; If ( (gRecordset + 1 ) * 10 - 9 > Count ( child::foreignkey ) ; gRecordset ; gRecordset + 1 ) ]
you can use any field from child in place of foreignkey as long as it is never empty.
To calculate an integer you're on the right track. Divide the record number by 10 and use Ceiling (recordNumber/10) which rounds up to the next integer and truncates all the decimals.
You might use a Value List based on that number field for your portal filter and the whole thing is fully automated no matter how the list grows and shrinks.
the calculation works on the way up ie when I have the portal populated with 9 records I get Result 1 19 result 2 29 result 3
but when I reduce the records back down to 19 and 9 gRecordSet stays on result 3!
I was thinking that the fact I will be adding a + and - button to view the portals (like the demo you posted from yesterday) would it be better to just set the gRecordSet from buttons with the relevant calculation
Apoligies my inexperience interpreted the calculation wrong. I was putting the calculation in gRecordSet
I created another field called gPortalSet and put the calculation in it!
I works up until 20 ie 1-10 =1 11-20 =2 21-30 =2 it might be something with the Child::field Im using will playaround with it
Yes, I was thinking in terms of the + and - buttons that I used in the demo file that I shared in the other thread. You can also use Case and limit values so that values less than zero are not allowed either.
Here's code that works as an update to the script in that file:
Set Field [Parent::gRecordSet ;
Case ( (gRecordset + Get ( ScriptParameter ) ) * 10 - 9 > Count ( child::foreignkey ) ; gRecordset ;
(gRecordset + Get ( ScriptParameter ) ) * 10 - 9 < 1 ; gRecordSet ;
gRecordset + 1
) // Case
] // this bracket is part of your script step, don't type it into the calculation
The + button passes a parameter of 1 and the - button passes -1.
Hi Phil Im having no luck
Am I right in thinking the above calculation goes into gRecordSet Calculation field - the last bracket
and as a script in both buttons passing the 2 relevant parameters
Open my demo file, open the only script in it for editing. What I just posted would be used in place of the set field step found in that script, but with the field names defined in it instead of yours.
And yes, this is a script performed when you click either button so long as you use the parameters that I have specified.
The minus button not behaving as it should. it keeps incrementing UP + by 1
The plus button behaving properly
Thanks for your patience
Then I would guess that it is not passing -1 as the parameter.
Tried all my knowledge will allow
I deleted the -1 Parameter on the minus script to see how the script would behave. it still adds 1!
Will do a bit of searching on why parameter not passing.
Are you clicking the button while in FileMaker Pro or tapping the button on an iOS device?
Only using on Filemaker pro 12
If you had advanced, I'd suggest using the script debugger and data viewer while stepping though the script.
Since you don't, I'd suggest adding a show custom dialog step temporarily. Set it to show the value of Get ( ScriptParameter ) and the value of key fields and the expressions in your script steps and see if anything pops up with the wrong value.
As you know I'm only getting to grips with FM so I could only get the script parameters and fields to popup!
parameters are showing in the message box as 1 for + button and -1 as -minus button!
Not sure if what I've noticed has any impact in working out the fault but I set the records to 26 and gRecordSet to 1
I clicked PLUS Button until it stopped at 3 then clicked Minus Button which incremented up twice before it stopped at 5