This topic is locked
[SOLVED]

Get field value from vertical grid with Button

9/25/2025 17:09:49
PHPRunner General questions
A
AlphaBase author

Button Client Before event:

$record = $button->getCurrentRecord();
$result["User_Updated"] = $record["User_Updated"];

I'm trying to get the field value from a vertical grid, but it's returning nothing at all. And there is a value in the field.

I've also tried $record = $ajax->getCurrentRecord() with no luck.
Where am I going wrong?

ChatGPT 9/25/2025

In PHPRunner, when you're working with a vertical grid, the way you access the current record may differ from how you would access a record in a standard table. In a vertical grid, the context of the current record can be a bit different depending on how events are triggered and how the data is structured.

Here's a checklist and some guidance to help you troubleshoot:

  1. Check the Context: Ensure that the button you're working with is indeed in the context of the vertical grid you're trying to access. Depending on where you've placed your button, it may not be linked to the correct record.


  2. Use the Correct Method: You mentioned trying $record = $button->getCurrentRecord(); and $record = $ajax->getCurrentRecord();. Make sure that you are using the correct context for the button event you are handling. Sometimes the button may not be directly under the grid.


  3. Debugging: To see what is being returned in $record, you can use:

    echo '<pre>';
    print_r($record);
    echo '</pre>';
    exit;

    This will help you see the structure of the $record variable and verify if the User_Updated field is present.


  4. Check Field Names: Double-check the field names. Sometimes, the field names in the database might differ from what you are trying to access in your code. Make sure that User_Updated is the exact name used in the database.


  5. Accessing Grid Data: If the button is outside the grid or not directly associated with a specific row, you may need to find a different way to access the grid data. For vertical grids, consider iterating over the records or using a specific method to get data from the grid.


  6. Event Context: Ensure that your button's client-side event is properly set up to trigger at the right time. If you're dealing with AJAX calls or other asynchronous processes, make sure the data has fully loaded before trying to access it.



If you can provide more context about where the button is located and how the grid is structured, I may be able to offer more specific advice.

A
AlphaBase author 9/25/2025

Does anyone have an idea why this isn't working?

A
AlphaBase author 9/26/2025

Figured it out:

Client Before event:

var File_No = rowData.fields['File_No'].html();
params["File_No"] = File_No;