so i have one scenario, where I need to reflect all the fields of a table to another form which doesn't have any datasource and fields. It totally depend on the user. If he add x data values then x fields should be reflected to new form .
so i have one scenario, where I need to reflect all the fields of a table to another form which doesn't have any datasource and fields. It totally depend on the user. If he add x data values then x fields should be reflected to new form .
Hi Nikolas,
Thanks for your reply. Will do so.
Hi Harshal,
The sample code is just a static method which you can run from anywhere. And you can also put it anywhere.
The code will create a form dynamically. You should put the code in the place where you want to trigger the creation of the form. You can point an action menu item to the class that has this method, and then place this menu item in places where you want to trigger the creation/launching of this dynamic form.
Can you please tell where should this be written?
I would like to ask in which method should I add this code? Should i add it in init method of the form where I will be showing fields?
thanks for the code, but by this are we not creating the new form via code?/
Below I have shared a code showing how to add unbounded fields to form design. I just added Int64 and string fields but other types can be added with similar logic. The field adding part can be converted into a method as in the other example, and you can send the type and orher values from the outside.
static void Dmr_ES_RunTimeFormDesign(Args _args) { Args args; Form form; FormRun formRun; FormBuildDesign formBuildDesign; FormBuildStringControl formBuildStringControl; FormBuildInt64Control formBuildInt64Control; FormBuildTabControl formBuildTabControl; FormBuildTabPageControl formBuildTabPageControl; ; // Create the form header. form = new Form(); // Create the form design. formBuildDesign = form.addDesign("Design"); formBuildDesign.caption("myForm"); // Add tabbed page controls, a grid control, and string controls. formBuildTabControl = formBuildDesign.addControl(FormControlType::Tab, "Overview"); formBuildTabPageControl = formBuildTabControl.addControl(FormControlType::TabPage,"Details"); formBuildTabPageControl.caption("Details"); formBuildInt64Control = formBuildTabPageControl.addControl(FormControlType::Int64, "MyInt64UnboundedField"); formBuildInt64Control.label("MyInt64UnboundedField"); formBuildInt64Control.helpText("MyInt64UnboundedField"); formBuildInt64Control.allowEdit(true); formBuildInt64Control.value(1234); formBuildStringControl = formBuildTabPageControl.addControl(FormControlType::String, "MyStringUnboundedField"); formBuildStringControl.label("MyStringUnboundedField"); formBuildStringControl.helpText("MyStringUnboundedField"); formBuildStringControl.allowEdit(true); formBuildStringControl.text("My string Value"); args = new Args(); args.object(form); // Create the run-time form. formRun = classfactory.formRunClass(args); formRun.run(); formRun.detach(); }
Now this is an example- these fields can be infinite number. As soon as user saves the field, these fields should be reflected to other form according to their type. Hope you get it.
It's not exactly dynamic in the example you showed. There is a table and form in the background. Only the form has no design. It creates a new design with the fields of the table.
With a similar structure, you can add table-independent unbounded (without datasource and datafield value) controllers. You can assign an initial value. But in this case, it is not possible to have a grid-like structure. Each control can hold only one value.
That table is still dynamic. I want to add the field according to the users preference. suppose the user want 3 text type fields then first i need to create 3 string data type fields. Still cant get it , how should i do it.
Of course, you can create a form with code and run it in runtime, but I'm not sure if you really need such a thing. In the first form there is a table where you get the values from the user. Why not use the same table.
Also validateWrite is not a place where we would want to add this kind of code. If there is no very special situation, write it under a button as in the example.
Lastly, I can't see any serious errors in the example, but I have to try it to be sure (I may not have time during the day).
If you share with us the error you encounter while using it, we will try to help.
André Arnaud de Cal...
293,278
Super User 2025 Season 1
Martin Dráb
231,994
Most Valuable Professional
nmaenpaa
101,156
Moderator