This topic is locked
[SOLVED]

 Update another table from button

5/19/2018 5:48:51 PM
PHPRunner General questions
mtpocket author

Hi,
I have a button on grid of list page.
This is my button instructions: -

  • Client before

    ctrl.setMessage("Sending request to server...");
  • Server (and this is where I'm battling)

    IF ($values["V1"]==0) { //instruction or condition to update table then follow through

    global $dal;

    $record = $button->getCurrentRecord(); //this is the button being clicked on list grid & I'm sure it's confusing the entire process

    if ($record["ID"])

    {

    $Stock = $dal->Table('Stock');

    $Stock->Param['ID'] = $record['SID1'];

    $Stock->Value['Stock_on_Hand'] = ($record['CSOH1'] + $record['T1']);

    $Stock->Update();

    }

    }

    else

    {

    // do nothing

    }

    $result["txt"] = $params["txt"]."Updated !!!!! ";


C
copper21 5/19/2018

If I am looking at this right, "$values["V1"]==0" won't work because the variable "$values" doesn't have a value in buttons.
You have to use $button->getCurrentRecord() to get any values from variables.

mtpocket author 5/20/2018



If I am looking at this right, "$values["V1"]==0" won't work because the variable "$values" doesn't have a value in buttons.
You have to use $button->getCurrentRecord() to get any values from variables.


Hi Brian,
The ($values["V1"]==0) does have a value in the record. The button which is located on GRID of LIST page will just move the record to another table if the value=0.
Perhaps the above is a better explanation.
Thanks

mtpocket author 5/20/2018



Hi Brian,
The ($values["V1"]==0) does have a value in the record. The button which is located on GRID of LIST page will just move the record to another table if the value=0.
Perhaps the above is a better explanation.
Thanks


Solved.
I used a different approach by hiding the BUTTON if it's not=0
Thanks