Questions and discussion about developing processes and programming in PHP, JavaScript, web services & REST API.
Forum rules: Please search to see if a question has already asked before creating a new topic. Please don't post the same question in multiple forums.
#815114
good morning!

I need you help to do the following:

I am working on a process for inventory request, the request can include more than one item to be requested using grid.

some grid columns are quantity approved and item type and item id, based on item approved quantity for each item requested, i need to update an external database for each row and each item with the new stock quantity.

how do I do that ? I have tried a hidden field in grid to update but it is not working, is it trigger the best way ?

thanks!
#815140
You need to use a trigger fired before the Dynaform to populate the grid and another trigger fired after the Dynaform to write the changes in the grid back to the database.

You can use hidden fields to store information in the grid that you don't want the user to see.

Here is an example:
Let's say you have a grid associated with the "inventoryList" variable and this grid has fields with the IDs:
itemId, itemType, quantityApproved

Then, your trigger before the DynaForm with the grid would be:
Code: Select all
$db = '1234567890abcdef1234567890abcdef'; //only needed if using a Database Connection
$sql = "SELECT ITEM_ID AS itemId, ITEM_TYPE AS itemType, ITEM_QUANTITY AS quantityApproved FROM INVENTORY";
@=inventoryList = executeQuery($sql, $db); 
Then, your trigger after the Dynaform would be:
Code: Select all
$db = '1234567890abcdef1234567890abcdef'; //only needed if using a Database Connection
if (isset(@=inventoryList)) {
    foreach (@=inventoryList as $aItem) {
         $id = $aItem['itemId'];
         //use addslashes() instead of mysql_real_escape_string() if not a MySQL database:
         $type =  mysql_real_escape_string($aItem['itemType']); 
         $quantity = (int) $aItem['quantityApproved']; //convert from string to integer
         $sql = "UPDATE INVENTORY SET ITEM_TYPE='$type', ITEM_QUANTITY=$quantity WHERE ITEM_ID='$id'";
         executeQuery($sql, $db);
    }
}
What's SAP FICO?

Trustworthy and skill-building, each of these actu[…]

To convert MBOX to PST, start by downloading and i[…]

My Assignment Services stands out as one of the be[…]

Erectile Dysfunction, commonly known as impotence,[…]