This topic is locked
[SOLVED]

 Field valuw on a record-row

11/14/2019 12:10:55 PM
PHPRunner General questions
J
jacques author

Hi,
Can anyone help me out
On a list_page each row has a field named main_ID

Now I want to add a code-snippet on each row doing something with that record based on the value main_ID
question

How do I obtain the value of main_ID programaticly in the code-snippet without adding a button that I need to click
thanks fot thinking

S
Steve Seymour 11/14/2019



Hi,
Can anyone help me out
On a list_page each row has a field named main_ID

Now I want to add a code-snippet on each row doing something with that record based on the value main_ID
question

How do I obtain the value of main_ID programaticly in the code-snippet without adding a button that I need to click
thanks fot thinking


var myvariable = row.getFieldValue("main_ID");

J
jacques author 11/14/2019



Thank you,

When I put this in JavaScript OPnload how do I call the value in the pgp-code snippet each record?
var myvariable = row.getFieldValue("main_ID");


N
Nir Frumer 11/14/2019





hi

you don't say what you are trying to do,

If your operation is on a field level - you can do it through the field'd custom display

Otherwise use the list page: Before record processed
hope it helps,

J
jacques author 11/14/2019



hi

you don't say what you are trying to do,

If your operation is on a field level - you can do it through the field'd custom display

Otherwise use the list page: Before record processed
hope it helps,


In the php-codesnippet I want to do some different actions with the value of main_ID (check on a other table, check on other field valies, etc) and echo the result on that same row.

I can do it with a home-made function through the custom display but I thought there is purhaps a much more easy way to do it.

Sergey Kornilov admin 11/14/2019

The best approach is to use 'View as' Custom instead of the code snippet. This way you handle both display part and easy access to record values.

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

S
Steve Seymour 11/17/2019



In the php-codesnippet I want to do some different actions with the value of main_ID (check on a other table, check on other field valies, etc) and echo the result on that same row.

I can do it with a home-made function through the custom display but I thought there is purhaps a much more easy way to do it.


As it happens, I just needed to do similar in one of my projects...
I have a customer table and I wanted to show the customers boat name along with the customer ID.

I tried to do it with the mouseover event but couldn't get it to work so I used custom view...
In the customer table I used custom view for the account_id field, and searched the boat table for the customers boat name.
account_id is the field name in the customers table, and a similar linked field in the boat table.
This field now shows the original customers account_id and underneath the customers boat name in parenthesis ()
Here's the code...
global $dal;

$acc_id = $data["account_id"];

$sql = "select * from boat where account_id = '$acc_id'";

$rs = CustomQuery($sql);

$bdata = db_fetch_array($rs);

$value = $acc_id . "
(" . $bdata["boatname"] . ")";