Forums: [SOLVED] Update another table from button - Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

[SOLVED] Update another table from button Update another table from button on list page Rate Topic: -----

#1 User is offline   mtpocket 

  • Member
  • PipPip
  • Group: Members
  • Posts: 23
  • Joined: 06-December 15

Posted 19 May 2018 - 09:48 PM

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 !!!!! ";

- Client After
var message = result["txt"];
ctrl.setMessage(message);

The problem I'm experiencing is when clicking the button it still updates the table irrespective of the condition.

Thanks
<_<
0

#2 User is offline   Brian21 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 165
  • Joined: 20-April 09

Posted 20 May 2018 - 12:18 AM

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.
0

#3 User is offline   mtpocket 

  • Member
  • PipPip
  • Group: Members
  • Posts: 23
  • Joined: 06-December 15

Posted 20 May 2018 - 09:51 AM

View PostBrian21, on 20 May 2018 - 02:18 AM, said:

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
0

#4 User is offline   mtpocket 

  • Member
  • PipPip
  • Group: Members
  • Posts: 23
  • Joined: 06-December 15

Posted 20 May 2018 - 03:58 PM

View Postmtpocket, on 20 May 2018 - 11:51 AM, said:

View PostBrian21, on 20 May 2018 - 02:18 AM, said:

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


Solved.

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

Thanks
0

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic