Master table is epsilon
Detail table is epsilon_comments
So a logged in user can add comments against a master record in epsilon and that all works fine and updates the detail page as expected
I want to add who made the comment
so for the epsilon_comments table in Server Events\Tabel\Specific\ Row Updating
I added
$myResult = ExecuteStatement("UPDATE epsilon_comments SET who='test'");// Row Updating even // Enter your code here
// To cancel, set return value to false
return true;
Before I try and add CurrentUserID() I thought I would test just using text ‘test’
So no errors but the who field does not get updated ?
you should do this in the row_updated() event… that way you’re assured the records were inserted/updated successfully. if an error occurs and the record isn’t updated… you’ve updated the detail record
Given that I want the person who adds the comment to be added to the who field
what would I set Where to ?
Lastly add an execute like this Execute($sSql)
$myResult = ExecuteStatement(“UPDATE epsilon_comments SET who=‘test’”);// Row Updating even // Enter your code here
// To cancel, set return value to false
return true;
Execute($sSql)
For modifying field contents before adding a record, you should use the Row_Inserting event.
function Row_Inserting(?array $oldRow, array &$newRow): ?bool
{
$newRow["who"] = 'test';
// To skip/cancel, set return value to null/false
return true;
}
function Row_Inserting(?array $oldRow, array &$newRow): ?bool
{
$newRow["who"] = 'test';
// To skip/cancel, set return value to null/false
return true;
}
I replaced ‘test’; with CurrentUser(); and again it works as expexted
so my last bit is to add the name of the current user
so added this
function Row_Inserting(?array $oldRow, array &$newRow): ?bool
{
$newRow["who"] = SetClientVar("login", ["currentUserName" => CurrentUserInfo("FirstName") . " " . CurrentUserInfo("LastName")]);
// To skip/cancel, set return value to null/false
return true;
}
So whilst it does not fail it does not update the field who with the actual First and Second name as needed
If I use
function Row_Inserting(?array $oldRow, array &$newRow): ?bool
{
$newRow["who"] = CurrentUserID();
// To skip/cancel, set return value to null/false
return true;
}
it sets who to the user _ID so the overall approach does work just need a pointer around how to get the first and second name please
U have setup a Master/Detail page
Master table is epsilon Detail table is epsilon_comments
So a logged in user can add comments against a master record in epsilon and that all works fine and updates the detail page as expected
I want to add who made the comment only logged in users can.
so for the epsilon_comments table in Server Events\Tabel\Specific\ Row Updating
The following works but simply populates the who field with a number and I want to populate with the logged in users name?
function Row_Inserting(?array $oldRow, array &$newRow): ?bool
{
$newRow["who"] = CurrentUserID();
// To skip/cancel, set return value to null/false
return true;
}
So what do I replace CurrentUserID();
with to get my result, thanks for all the help so far.