This topic is locked
[SOLVED]

Count records on Client Before event

2/26/2024 9:05:54 AM
PHPRunner Tips and Tricks
F
Fabio74 author

Hi,
I have a custom button that runs a certain query.
I need to count certain records and send a confirmation message based on the count to the user before running the query.
If I'm not mistaken you can't query client side, so how can I perform this check?
Thanks in advance.

D
druck281 2/26/2024

Good morning,

To get the count into the Client Before on your button, you would need to run the query in the BeforeProcess event on the page then use setProxy to make that available in JS for the ClientBefore on your button.

https://xlinesoft.com/phprunner/docs/setproxyvalue.htm

-Jason

F
Fabio74 author 2/26/2024

Hi Jason,
thanks for your quick response.
I understand what you mean, however one of the conditions for counting depends on the record selected. Let me explain better:
I am on a details page, so filtered by master record.
I need to count based on one of the fields in the master record or the same (filtered) field in the details.
When the user presses the button, if the count is not 0 I have to send a confirmation message and act accordingly.
In other words I should first pass a value to the before process event to use it as a condition for counting.
Is it possible to do this?

F
Fabio74 author 2/27/2024

Good morning,
I answered myself. The field value is already available
on BeforeProcess event using $pageObject->getMasterRecord().
The process you showed works very well.
Thank you very much Jason.

D
druck281 2/29/2024

Glad you got it. Sometimes, it just takes a little nudge to make your brain work. Happens to me all the time. Sometimes, I randomly read posts in here just to see how other people think and it sparks something totally different in my application.

-Jason