This topic is locked

Custom Button in Reports

1/23/2026 18:58:48
PHPRunner General questions
C
chandoshi authorDevClub member

I added a Custom Button with following code for "Client Before" to open an Edit Screen in popup. This works fine in a list view.
For some reason the code "row.getFieldValue("fkJobId");" does not return the field value when added to a report.

var pkeys = row.getFieldValue("fkJobId");
var win = Runner.displayPopup( {
url: "jobs1_edit.php?page=editjob&editid1="+pkeys,
width: window.innerWidth-10,
height: window.innerHeight-10,
//header: 'Edit Customer: [ ' + row.getFieldText("Customer")+' ]',
header: '<a href="#" onclick="window.win.close();return false;">.</a>',
afterCreate: function(popup) {
window.popup = popup;
}
});
return false;

ChatGPT 1/23/2026

The issue you're encountering with row.getFieldValue("fkJobId"); not returning the field value in a report view, while it works fine in a list view, could be due to the way PHPRunner handles data in different views.

Potential Reasons and Solutions:

  1. Field Accessibility:

    • In report views, the data may not be structured the same way as in list views. Ensure that the field fkJobId is actually available and populated in the context of the report. You can check this by logging the available fields in the row object.

    console.log(row);
  2. Row Object:

    • The row object in a report view may not contain the same methods or properties as in a list view. You might want to check if row is defined and if it has the expected structure.


  3. Check Field Names:

    • Ensure that the field name fkJobId is correctly spelled and matches the name used in your database and PHPRunner configuration. Sometimes, discrepancies in naming can lead to undefined results.


  4. Use getFieldText:

    • If getFieldValue doesn’t work, you can try using getFieldText to see if it retrieves the value correctly. However, this will return the displayed text rather than the actual value.

    var pkeys = row.getFieldText("fkJobId");
  5. Debugging:

    • Add debugging statements to see what the row object contains in the report context. This can give you clues about what fields are available.


  6. Alternative Approach:

    • If the above methods do not work, consider creating a custom SQL query for the report that ensures the desired fields are included.



Example Debugging Code:

You could modify your code temporarily to include some debugging information, like so:

var pkeys = row.getFieldValue("fkJobId");
console.log("fkJobId Value: ", pkeys); // Check if it returns the expected value
console.log("Row Object: ", row); // Inspect the entire row object

var win = Runner.displayPopup( {
url: "jobs1_edit.php?page=editjob&editid1="+pkeys,
width: window.innerWidth-10,
height: window.innerHeight-10,
header: '<a href="#" onclick="window.win.close();return false;">.</a>',
afterCreate: function(popup) {
window.popup = popup;
}
});
return false;

Conclusion:

By following the above steps, you should be able to determine why the fkJobId field is not returning a value in your report. Make sure to check the structure of the row object and verify that the field is available in that context. If necessary, adjust your approach based on what you find during your debugging process.