writing the client side scripting on workspace or ui builder

saikumarkak
Tera Contributor

Hello,

I want client side scripting in workspace or ui builder. that the client script will stop the form submission when the mandatory fields are not filled in the form and shows the error on the form when i clicked on the save button. that the client script should work in workspace.

2 REPLIES 2

Saloni Suthar
Mega Sage
Mega Sage

Do you have to show a custom error message? because when the fields are mandatory on the form, and try to save the form without filling in the fields, the error message should appear. 


If my response helped you, please click on "Accept as solution" and mark it as helpful.
- Saloni

Maik Skoddow
Tera Patron
Tera Patron

Hi @saikumarkak 

 

basically, you can use traditional client scripts also in Workspaces. For example:

function onSubmit() {
  // Example: Check if a mandatory field 'short_description' is empty
  if (!g_form.getValue('short_description')) {
    g_form.addErrorMessage('Short Description is mandatory.');
    return false; // Prevent form submission
  }
  // Add checks for other mandatory fields as needed

  return true; // Allow submission if all validations pass
}

 

Important Notes for Workspace/UI Builder

  • Some traditional client APIs like g_form.getMissingFields() or g_form.checkMandatory are not supported in Workspace

  • You need to explicitly check each mandatory field's value using g_form.getValue(fieldName) and handle errors manually.

  • UI Policies execute after client scripts; if conflicting, UI Policy logic applies

  • You cannot call server-side events directly from client scripts, but you can handle validations fully on the client side before submission