Add new field/attribute by user on a custom form 

Add new field/attribute by user on a custom form 

  

Hi Experts, 

I am early bird in OutSystems and have a requirement where the end user wants to have a dynamic form, where if he wants to have a new field added on the form can do so. 

Need to provide an interface where user can define a new field for a form by selecting data type, form field type (e.g. text input, combo box or radio button). The system creates a new attribute in the table and adds a field on the form as per definition. 

Please advise if this requirement is possible in OutSystems and how? 

As far as I know with every change in the Data structures we have to publish our app again. With an application that is already published and in production, how can we achieve this goal. 

Regards, 

KA

Solution

This is not really an Outsystems issue it's a design issue.  How would you design a table (entity) to do this if you were just using SQL?  It doesn't make sense to create tables for each user or do any other SQL tricks since you'd have no way to create an application that would perform well, if it worked at all.

The only solution to this type of requirement I've seen implemented works a follows.  Create an entity with the following fields - Id, UserId, FieldName, DataTypeId, TextField.  Also create a static entity with Id and DataType. Each record in the first table represents a field that the user created.  You can then create/edit/delete fields as needed using logic on the submit button.

While the solution I described will work and I've actually seen it implemented in non-Outsystems projects, there are a number of issues that may make it unusable for you.  1) Data conversion - all fields must be converted to/from text every time they are displayed or stored.  2) Querying/Reporting - because a user defined record really consists of a number of records grouped together, traditional query and report tools will have difficulties.  3) Selecting by date - because the dates are stored as text fields, selecting by dates usually doesn't perform well.

The best thing to do is experiment with the solution and see if its worth the effort.  If not, just create an entity with a bunch of fields of different types and limit the users to that number.


Hope this helps,
Curt


Solution

Curt Raddatz wrote:

This is not really an Outsystems issue it's a design issue.  How would you design a table (entity) to do this if you were just using SQL?  It doesn't make sense to create tables for each user or do any other SQL tricks since you'd have no way to create an application that would perform well, if it worked at all.

The only solution to this type of requirement I've seen implemented works a follows.  Create an entity with the following fields - Id, UserId, FieldName, DataTypeId, TextField.  Also create a static entity with Id and DataType. Each record in the first table represents a field that the user created.  You can then create/edit/delete fields as needed using logic on the submit button.

While the solution I described will work and I've actually seen it implemented in non-Outsystems projects, there are a number of issues that may make it unusable for you.  1) Data conversion - all fields must be converted to/from text every time they are displayed or stored.  2) Querying/Reporting - because a user defined record really consists of a number of records grouped together, traditional query and report tools will have difficulties.  3) Selecting by date - because the dates are stored as text fields, selecting by dates usually doesn't perform well.

The best thing to do is experiment with the solution and see if its worth the effort.  If not, just create an entity with a bunch of fields of different types and limit the users to that number.


Hope this helps,
Curt


Thanks for the reply Curt. Yes, it is a design issue that I was thinking how to solve in OutSystems! I have seen applications where user can extend the entities (table) by defining new User Defined Fields.

Like for example, user wants to have a new field of Hobies on the employee form. The admin user creates a new field using an interface to define the new field with required attributes, system generates an alter table query against the request and modifies the table. Next time the user logs in and see a new field on the form. Offcourse the Employee form has to be dynamic to add fields based on the entity structure.

Instead of the user asking developer to customise the form, the application gives him the facility to make such changes with in the application. I think the last suggestion is more workable and easy to manage. Make entity with bunch of different field types and stick the user to it.

Appreciate your suggestions and putting me in right direction.

Regards,
KAKA