This topic is locked

Custom Button from Master Table Info on detail page

3/6/2020 2:48:23 PM
PHPRunner General questions
A
aeaton2017 author

I am looking for a custom button from the MasterTable Info to go to another page for an employee. Here is what I got so far
Server:
$data = $pageObject->getMasterRecord();

$result["EmployeeID"]=$data["id"];
also tried
$record = $button->getCurrentRecord();

$result["EmployeeID"]=$record["id"];
Client After:
location.href='documents_list.php?mastertable=AdminEmployee&masterkey1='+result["EmployeeID"];
It gives an error with no error message. So I really don't know what the issue could be.
Thoughts?

Admin 3/6/2020

If you are adding button to the master page then getMasterRecord() won't work but getCurrentRecord() will.
There must be some other code there produces this issue. Use this article to see find the exact output from buttonhandler.php request:

https://xlinesoft.com/phprunner/docs/troubleshooting_custom_buttons.htm
It will point you in the right direction.

A
aeaton2017 author 3/7/2020



If you are adding button to the master page then getMasterRecord() won't work but getCurrentRecord() will.
There must be some other code there produces this issue. Use this article to see find the exact output from buttonhandler.php request:

https://xlinesoft.com/phprunner/docs/troubleshooting_custom_buttons.htm
It will point you in the right direction.


Its not on the master page, but I am looking at the masterlist which is on top of the details page. I need a button to open redirect to another page..

N
Nir Frumer 3/7/2020



I am looking for a custom button from the MasterTable Info to go to another page for an employee. Here is what I got so far
Server:
$data = $pageObject->getMasterRecord();

$result["EmployeeID"]=$data["id"];
also tried
$record = $button->getCurrentRecord();

$result["EmployeeID"]=$record["id"];
Client After:
location.href='documents_list.php?mastertable=AdminEmployee&masterkey1='+result["EmployeeID"];
It gives an error with no error message. So I really don't know what the issue could be.
Thoughts?


why don't yoy do it all on the server tab
https://xlinesoft.com/phprunner/docs/redirect_to_another_page.htm
hope it helps,

Admin 3/7/2020

It depends on where you adding this button in Page Designer. If you adding it to something that is the part of the Details table, use getMasterRecord(). If you adding it to something that is the part of the Master table, use getCurrentRecord(). In either case, you need to figure out what exactly is wrong following steps in the article I mentioned.
From what I see, there is some other code in your Server event that causes this issue.

A
aeaton2017 author 3/9/2020



It depends on where you adding this button in Page Designer. If you adding it to something that is the part of the Details table, use getMasterRecord(). If you adding it to something that is the part of the Master table, use getCurrentRecord(). In either case, you need to figure out what exactly is wrong following steps in the article I mentioned.
From what I see, there is some other code in your Server event that causes this issue.


I have buttons that work on the list grid, with no problem using the same method. However, I need a button a master data on details page to open another page with that employees data. When I try this it returns "null" like this "documents_list.php?mastertable=AdminEmployee&masterkey1=null" I can't get a value to work.

Admin 3/12/2020

According to what I see the value of $result["EmployeeID"] passed from Server is null or empty. This means you need to go to the server event and make sure that the correct value is being assigned to $result["EmployeeID"].
Depending on what option do you use, you will have to print either $data or $record array and this will shed more light on what is happening.

Admin 3/12/2020

I have run some tests and it appears that that server part of buttons added to "masterlist" page is not executed at all. This is a bug in PHPRunner and we will fix it.
So the best workaround, for now, is to set one of master table field 'View as' type to Custom. And here is the code that you can use:

$value = "<a href='documents_list.php?mastertable=AdminEmployee&masterkey1=".$data["id"]."'>Employees</a>";
A
aeaton2017 author 3/13/2020



I have run some tests and it appears that that server part of buttons added to "masterlist" page is not executed at all. This is a bug in PHPRunner and we will fix it.
So the best workaround, for now, is to set one of master table field 'View as' type to Custom. And here is the code that you can use:

$value = "<a href='documents_list.php?mastertable=AdminEmployee&masterkey1=".$data["id"]."'>Employees</a>";



thank you, I thought I was going crazy...It works!!! Not ideal but it works.. THANK YOU!!