-
I click the “Add New” button and a new row is created at the bottom of the grid. = Correct behavior
-
I add my data in the fields and click the “Save” button. I get an error saying that a key field is missing.
-
Because this is an editable grid, I’m assuming I need to know the unique identifier of the newly added row, so I’m trying to add it myself.
-
I include the TEAM_GUID field (which is the same for every row in the grid, and OBJ_GUID field (which is the primary key field) in the grid, just so I can see what’s in them.
-
I try to populate the TEAM_GUID field (hard coded for now) and the OBJ_GUD by using a stored procedure (which is tested and works)
-
I put the following code in the onBeforeInsert event.
// SQL to retrieve a new OBJ_GUID
sc_lookup(my_data, “SELECT p.NEW_GUID FROM GET_NEW_GUID p;”);
if ({my_data} === false)
{
echo “Data Access Error: Message=”. {my_data_erro} ;
}
elseif (empty({my_data}))
{
echo “No data returned”;
}
else
{
{OBJ_GUID} = {my_data[0][0]};
}
// Use the global variable for team_guid
{TEAM_GUID} = ‘A4C58C92-62BF-4993-A134-D6FD88B52B80’;
- Now, when I add a new record, the TEAM_GUID field and the OBJ_GUID field are both blank. This is probably why the DB is rejecting the INSERT, because of a blank TEAM_GUID and blank OBJ_GUID.
How do I populate primary key fields of a new record in an Editable Grid?