34
Views
6
Comments
Solved
How to insert default values in the fields on datatable
Question

Hello guys i have this datatable, and i need when the user insert data in the datatable, the default value in the collum "Estado" is "Em espera"i nned in the collum "Nome" it go pick automaticly the name of the user which do login and it´s insert the data. The field "Estado" it´s gonna be 3 options (Open, Close, Working in) (the users is not can insert this value, the default value when the user go insert other data are "open" And the admin can change the state of ticket to open, close or analising) The user it´s gonna select one of them. The name, the website need to get the username which was making the register That it´s possible?

Solution

Hello Franscisco,


It will be a good practice if you will create a Static Entity for your field "Estado" as it has only static values.

I can see "Estado" is used as an attribute so first create an static Entity with name Estado and with those three attributes(create 'open' first), and change data type of your previous Estado attribute to "Estado identifier" . make it as mandatory. Now this field will be displayed as dropdown. As open is first attribute, in dropdown it will display in screen by default, even user won't select it, it will selected by default and value 'open' will be saved. 

for second part, you can use GetUser(GetUserId()).User.Username for username or GetUser(GetUserId()).User.Name for name to display.


hope it helps!

Thanks,

Sanjay

Hi,

You can update this in your Table properties.

Is Mandatory -> No

Default Value ->"XZY"

 


Option Second


Assign this   GetUser(GetUserId()).Name to the field you want to populate with the current login username or name

Solution

Hello Franscisco,


It will be a good practice if you will create a Static Entity for your field "Estado" as it has only static values.

I can see "Estado" is used as an attribute so first create an static Entity with name Estado and with those three attributes(create 'open' first), and change data type of your previous Estado attribute to "Estado identifier" . make it as mandatory. Now this field will be displayed as dropdown. As open is first attribute, in dropdown it will display in screen by default, even user won't select it, it will selected by default and value 'open' will be saved. 

for second part, you can use GetUser(GetUserId()).User.Username for username or GetUser(GetUserId()).User.Name for name to display.


hope it helps!

Thanks,

Sanjay

Rank: #10383

Hello Francisco,


Like Sanjay said, first of all you need to create a static entity with the three states you want (Open, Close, Working in), then follow this steps:

  1. Create a static entity named "Estado".
  2. Insert the three states, writing ther labels. Change Id field to IsAutoNumber = NO, and fill the ids accordingly (1 , 2, ...)
  3. In the table SuporteTicket  change the data type of column "Estado" to "Estado Identifier"
  4. Like Akash said, in SuporteTicket attributes tab change Is Mandatory to NO and default value to the id number of the state "Open" (what you have done in step 2).
  5. Make sure that in the create action for "SuporteTicket" you are not overriding the default value for a blank space. If you expand that create action you will see that you are able to set every column independently. You only have to insert the desired Estado Identifier
Rank: #824

Thanks for all, ALL help me but i can just mark one solution, sorry ;-;