Page 1 of 1

CurrentUserName Grid Add

Posted: Mon Dec 05, 2022 11:22 pm
by DGarza

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?


Re: CurrentUserName Grid Add

Posted: Tue Dec 06, 2022 12:01 am
by mobhar

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.


Re: CurrentUserName Grid Add

Posted: Thu Dec 08, 2022 12:14 am
by DGarza

Hi, thanks, I changed to CurrentValue, because EditValue didn't work, but didn't work too, the value didn't add on bd, there are not any error on debug mode or console on the browser.

Something else?


Re: CurrentUserName Grid Add

Posted: Tue Oct 03, 2023 8:45 am
by mobhar

You may post your Fields setup for that Username field for more discussion, like:

  • Does it use Select or Textbox control?
  • Does the field use Lookup Table or not?
  • And any other related setting you might added.

Re: CurrentUserName Grid Add

Posted: Tue Oct 03, 2023 2:12 pm
by DGarza

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


Re: CurrentUserName Grid Add

Posted: Tue Oct 03, 2023 5:10 pm
by mobhar

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.


Re: CurrentUserName Grid Add

Posted: Tue Oct 03, 2023 11:17 pm
by DGarza

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)


Re: CurrentUserName Grid Add

Posted: Wed Oct 04, 2023 9:32 am
by arbei

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.


Re: CurrentUserName Grid Add

Posted: Wed Oct 04, 2023 10:53 pm
by DGarza

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