This topic is locked
[SOLVED]

getCurrentRecord is always showing id of first record on the page

12/30/2022 9:41:06 AM
PHPRunner General questions
W
wfcentral author

I use the code below to pull various IDs on different list pages so I can use a pop-up button to open external pages based on the ID they are editing. It works fine on all pages except one. I can't see anything different on this one list page, but for some reason it is always pulling the ID of the first record on the page. I'm using the latest version of phprunner 10.8.

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

admin 12/30/2022

Makr sure that you have selected a proper key column, the one that has different values for each record. It looks like in your situation all records have the same value in key column field.

W
wfcentral author 1/2/2023

It is a proper key column. I have even displayed it to the list page to ensure that it is unique for each record.

The only thing I'm suspecting may be an issue is that I use this same button on another page which is a unique view of the same table. The button on the other page works fine. So, I don't know if you have to use different IDs on each page? for example on page 1 I could use RS_ID and on page 2 I could create an alternate alias of that so it shows as Student_ID and create an entirely separate button (though I think I tried this and it didn't fix the issue).

Robert

admin 1/4/2023

The question doesn't make much sense to me. Each page should work the same way and unless you are doing something different there like modifying the SQL query by adding aliases to the key column.

W
wfcentral author 1/5/2023

I figured out the issue. The page that was having issues was using a VIEW that was created in myphpadmin (not inside phprunner). I had neglected to set a primary key for that table in phprunner because users would not be editing it so I didn't think it was required. Without having a unique ID defined the getCurrentRecord doesn't work correctly.