CurrentUserName Grid Add

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
DGarza
User
Posts: 91

CurrentUserName Grid Add

Post 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?


mobhar
User
Posts: 11660

Post 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.


DGarza
User
Posts: 91

Post 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?


mobhar
User
Posts: 11660

Post 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.

DGarza
User
Posts: 91

Post 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


mobhar
User
Posts: 11660

Post 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.


DGarza
User
Posts: 91

Post 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)


arbei
User
Posts: 9286

Post 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.


DGarza
User
Posts: 91

Post 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


Post Reply