Class CustomFormApi.CustomFormBuilder

Object
CustomFormBuilder
Enclosing class:
CustomFormApi

public static class CustomFormApi.CustomFormBuilder extends Object
Helper class to create Custom Forms. The class exposes several methods of the type setXX() for properties of the custom form. The custom form is then created in the database by invoking the method create. Note that no permissions are checked when updating the custom form.
See Also:
  • Method Details

    • setName

      public CustomFormApi.CustomFormBuilder setName(String name)
      Sets the Custom Form name. This name has to be unique in the context of the used Custom Form Type. If not specified, a name derived from the database id will be used.
      Example:
      
       def customForm = api.customFormApi()
           .newCustomForm()
               .setName("CustomForm01)
           .create()
       
      Parameters:
      name - The name of the Custom Form.
      Returns:
      this builder instance
    • setLabel

      public CustomFormApi.CustomFormBuilder setLabel(String label)
      Sets the Custom Form label.
      Example:
      
       def customForm = api.customFormApi()
           .newCustomForm()
               .setLabel("My Custom Form")
           .create()
       
      Parameters:
      label - The label of the Custom Form.
      Returns:
      this builder instance
    • setTypeId

      public CustomFormApi.CustomFormBuilder setTypeId(Long id)
      Sets the Custom Form Type id. Please note the required format (specify the Id instead of typedId).
      Example:
      
       def customForm = api.customFormApi()
           .newCustomForm()
               .setTypeId(123)
           .create()
       
      Parameters:
      id - The id of the Custom Form Type. Id is typedId without the'.CFOT' suffix (if the typedId is 123.CFOT then Id is 123).
      Returns:
      this builder instance
    • setUserGroupViewDetails

      public CustomFormApi.CustomFormBuilder setUserGroupViewDetails(String userGroupViewDetails)
      Sets the Custom Form User Group View Details. Example:
      
       def customForm = api.customFormApi()
           .newCustomForm()
               .setUserGroupViewDetails("viewGroup")
           .create()
       
      Parameters:
      userGroupViewDetails - The name of the User Group.
      Returns:
      this builder instance
    • setUserGroupEdit

      public CustomFormApi.CustomFormBuilder setUserGroupEdit(String userGroupEdit)
      Sets the Custom Form User Group Edit. Example:
      
       def customForm = api.customFormApi()
           .newCustomForm()
               .setUserGroupEdit("groupEdit")
           .create()
       
      Parameters:
      userGroupEdit - The name of the User Group.
      Returns:
      this builder instance
    • setAttributeValue

      public CustomFormApi.CustomFormBuilder setAttributeValue(String attributeName, Object value)
      Sets the value of the specified 'attributeXX' column of the CustomForm class.
      Example:
      
       def customForm = api.customFormApi()
           .newCustomForm()
               .setAttributeValue("attribute1", "meatball01")
           .create()
       
      Parameters:
      attributeName - The name of the attribute column to update.
      value - The value of the attribute.
      Returns:
      The same instance of this class.
    • setAttributeExtension

      public CustomFormApi.CustomFormBuilder setAttributeExtension(Map<String,Object> attributeExtension)
      Adds a custom attributeExtension___key:value field to the CustomForm. setAttributeExtension(java.util.Map<java.lang.String, java.lang.Object>) might be useful for setting the attributeExtension fields from scratch or for mass actions.

      Information: To view the attributeExtension via UI, add the attribute extension field first – navigate to the CustomForm header context menu (three dots next to the column label) > Customize Attribute Extension. Add the name of the AttributeExtension key you want to display in the table.
      Otherwise, AttributeExtension fields are stored in the database only and are not visible in the user interface. AttributeExtension fields can be fetched with the given CustomForm object.

      Example:

      
       def newCustomForm = api.customFormApi()
           .newCustomForm()
               .setAttributeExtension(["key1": "value1", "key2": "value2"])
           .create()
       
      Parameters:
      attributeExtension - A map of additional custom attributes of the CustomForm
      Returns:
      The instance of CustomFormApi.CustomFormBuilder
      Since:
      11.1 - Paper Plane
      See Also:
    • setAttributeExtensionValue

      public CustomFormApi.CustomFormBuilder setAttributeExtensionValue(String name, Object value)
      Updates the value of an existing attributeExtension___key:value field or creates a new one.

      Example:

      
       def newCustomForm = api.customFormApi()
           .newCustomForm()
               .setAttributeExtensionValue("name", "value")
           .create()
       
      Parameters:
      name - field name (key)
      value - new value
      Returns:
      the same instance of this class
      Since:
      11.1 - Paper Plane
      See Also:
    • create

      public Object create()
      Finishes the create operation. When this is executed, the Custom Form will be created in the database. Also, pre-phase will be ran to generate inputs.

      Note: Since 12.0.0, this operation only works in contexts that allow object modification. The previous behaviour can still be achieved by using the 'customFormApiAlwaysAllowsObjectModification' application property.

      Returns:
      an Object containing the data of the created Custom Form, or null in case of syntax check mode or allow object modification being false.

      The data that can be extracted is:
      • id
      • uniqueName
      • label
      • attributeXX (1..30)
      • inputs (the specific type of the inputs can vary)
      • outputs (the specific type of the outputs can vary)
      Throws:
      EntityExistsException - if the combination of parentTypedId and uniqueName already exists
      CustomFormExceptions.CalculationErrorException - if an error happens during the pre-phase calculation
      See Also: