Hi everyone,
I'm using Default Value(CurrentUserName()) on a Add Page and everything it's fine, when add a row user name add correctly, but when using the grid add, the user name didn't add, and idk why.
Someone can help me?
Hi everyone,
I'm using Default Value(CurrentUserName()) on a Add Page and everything it's fine, when add a row user name add correctly, but when using the grid add, the user name didn't add, and idk why.
Someone can help me?
You may use Row_Rendered server event to assign a value to the control, for example:
if ($this->CurrentAction == "gridadd") {
$this->YourFieldName->EditValue = CurrentUserName(); // adjust YourFieldName to your actual field name
}
If EditValue
does not work above, then try CurrentValue
instead.
Thank you for reponse
mobhar wrote:
You may post your Fields setup for that Username field for more discussion, like:
- Does it use Select or Textbox control?
Its a text box, But the user clearly doesn't add it manually, because I'm using the CurrentUserName()
- Does the field use Lookup Table or not?
Not it doesn't
- And any other related setting you might added.
Nop, The field works fine when I added it normally, but when I use the Grid Add, that's when the CurrentUserName() just doesn't work, I have nothing special in that field
If the field uses Textbox control and it does not use Lookup Table, then the code I posted above should work properly.
I've just tested in demo2024 project for suppliers table and ContactTitle field (for example), I added the following code and it works properly:
if ($this->CurrentAction == "gridadd") {
$this->ContactTitle->EditValue = CurrentUserName(); // adjust ContactTitle to your actual field name
}
I can see the current username by default in ContactTitle field in Grid-Add mode.
Thanks for response, I put the code, but it doesn't work ;( I put this code on Row_Rendered (idk if this the correct place)
Somethis that i miss to say and actually your asked me, this is my field seeting on Fields:
List Page: Uncheck list
Edit Page: Uncheck, Read Only Uncheck
Edit Tag: Hidden
Add: Default Value: CurrentUserName()
With this settings on my field, when I Added normaly, it works perfectly, this doesn' work when use the Grid Add
And I think this is the most important things
I try change the checks, I try checked edit page, I changed the edit tag to textbox(in this case i need to put code on read only on Row_Rendered)
DGarza wrote:
List Page: Uncheck list
You need to check the field in List page to show and update it in Grid-Add. (Note that Grid-Add is feature of the List page.) If you want to auto-update the field without showing it, you should use Auto-Update Value, not Default value.
arbei wrote:
You need to check the field in List page to show and update it in Grid-Add. (Note that Grid-Add is feature of the List page.) If you want to auto-update the field without showing it, you should use Auto-Update Value, not Default value.
Oh, thank you very much men! It works