Change field display type at runtime

Is it possible to change the display type of a field from TEXT_FIELD to COMBOBOX at runtime? If yes, how? I tried solutionModel.getForm( formName ).getComponent( fieldName ), but I don’t find something about that.

Hi,

Yes, it is possible to change the display type of an element at runtime.

   // Get the form name
	var jsForm= solutionModel.getForm(<formName>);
	// Get the field by passing the name of the field
	var jsField = jsForm.getField('<fieldName>');
	// Check the display type 
	if(jsField .displayType === JSField.TEXT_FIELD) {
		
		// Set the Display type
		jsField .displayType = JSField.COMBOBOX;
	}
	
	//Recreate the UI
	controller.recreateUI();

Another way to do this is by setting two fields overlapping eachother and adjusting the visibility of the element you want to show inside onRender event.

Hope this will help!

Thanks
Sovan

sovanm:

	// Get the field by passing the name of the field
var jsField = jsForm.getField('<fieldName>');

Of course, getField was it. I used it already, but I don’t saw it earlier. Thanks, Sovan.