This topic is locked

Before record updated $inline = true

5/22/2020 4:42:45 AM
PHPRunner General questions
K
kdgsv author

Hallo,
I'm using the following code at:

  • before record added
  • before record updated
    This for calculate the "linetotal" field

$data = $pageObject->getMasterRecord();

$_SESSION["country"]=$data["tbl_site_country"];
if ($_SESSION["country"] == 'Austria')

{

$values["tbl_unit_linetotal"] = ($values["tbl_unit_amount"] * $values["tbl_unit_price_a"]);


It works fine on "Edit Page" and "Add Page" also on "Inline Add"
It does not work during "Inline Edit"
I've played with the "$inline = true" but does not get it work.
Did someone get this working also in "Inline Edit"
Thank you.
Matthias

Sergey Kornilov admin 5/22/2020

What exactly didn't work in this code when you use it in inline mode?
How exactly did you play with "$inline = true"?
You need to provide more info, we cannot guess all the details.

K
kdgsv author 5/25/2020

Hallo Sergey,
The calculation works fine when I'm doing add, inline add or edit, but not with inline edit.
With doing inline edit the value is always set to zero
$inline = true;

$data = $pageObject->getMasterRecord();

$_SESSION["country"]=$data["tbl_site_country"];

if ($_SESSION["country"] == 'Germany')

**$inline = true;**

{

$values["tbl_unit_linetotal"] = ($values["tbl_unit_amount"] * $values["tbl_unit_price_de"]);

};

**$inline = true;**

return true;


I've added $inline = true; at different position in the code, at start, in the middle and also at the end (like shown above) but it looks like I'm using the wrong syntax.
I've not found an example on how to use this additional parameter.
Thank you
Matthias

Sergey Kornilov admin 5/25/2020

You are completely misunderstanding what parameter of the function is. The parameter is something that is passed to the function and you should not be assigning any values to it. Instead, can check the value of this parameter and adjust your calculations accordingly.

if ($inline) {
// we are in inline mode
} else {
// we are in the regular mode
}
K
kdgsv author 5/26/2020

Thank you Sergey,
I understood with

if ($inline)


it is possible to assign a differnt behavior in "inline edit" mode as in "edit" mode?
If yes, I don't need a different calculation.
I want to have the same calculation done in "edit" mode and "inline edit" mode.
Let me try again to explain what I don't understand:
This code:

$data = $pageObject->getMasterRecord();

$_SESSION["country"]=$data["tbl_site_country"];

if ($_SESSION["country"] == 'Germany')

{

$values["tbl_unit_linetotal"] = ($values["tbl_unit_amount"] * $values["tbl_unit_price_de"]);

};


is used in "before record added.
The calculation works ok when I do "add new" or "inline add"
By using the same code like shown above with event "before record updated" in "edit" mode the calculation works ok but not in "inline edit" mode.
Every time I do "inline edit" the value in "tbl_unit_linetotal" is set to zero.
Is there a difference between the event "before record added" and "before record updated"?
I was start playing with "$inline" because the calculation in "inline edit" was not working as I expected.
What I realized this morning while doing troubleshooting:
I'm showing master and detail table on one page. If I'm doing "inline edit" at the detail table while showing master and detail table together, the calculation while doing "inline edit" does not work.
While showing only the detail table without the master table, the calculation while doing "inline edit" works ok"
Thank you
Matthias