Skip to main content
kavyam0002
September 2, 2022
Solved

Multiple Form

  • September 2, 2022
  • 7 replies
  • 0 views

Hi My question is 

i need a form to fill the details like below, for this requirement i am thinking to go with the form layout will be fine or any other methods i can go with? 

after filling these details if user wants to add one/more contracts he should get the same form below one after the other is that functionality is possible in forml ayout ?

let me know if any suggestions 

Contract No.
 
How many times [number validation]
Total No of Days previously extended (A) [number validation]
   
Current Extension Request:  
Contract Limit [aed validation]
Value of Full Contract - Outstanding  [aed validation]
Value of Extension sought [aed validation]
Capital Amount  [aed validation]
Interest Amount  [aed validation]
Current Maturity Date of Payment being extended  date validation
Number of days extension sought (B) number validation
New Extended Maturity Date  date validation
Total Number of days (A+B) calculation
Is interest to be recovered ? Y/N
Account to be charged with interest  Number validation 
   
Is the contract current Past Due  Y / N
If Y how many days past due?  
Add new contract no   
Please attach copy of Customer Request  [doc attach]

button to add more forms 

    Best answer by ujjwalr0002

    Yes it is possible please refer to the below screenshots and code.

    a!localVariables(
      local!xyz:'type!{urn:com:appian:types}AA_Vehicle'(),
      a!formLayout(
    
        contents: {
          a!forEach(
            items: local!xyz,
            expression: {
              a!cardLayout(
                contents: a!columnsLayout(
                  columns: {
                    a!columnLayout(
                      contents: {
                        a!sectionLayout(
                          label: "Vehicle Information",
                          labelSize: "SMALL",
                          contents: {},
                          divider: "NONE"
                        ),
                        a!sideBySideLayout(
                          items: {
                            a!sideBySideItem(
                              item: a!textField(
                                label: "Make",
                                labelPosition: "ABOVE",
                                value: fv!item.vehicleMake,
                                saveInto: fv!item.vehicleMake,
                                required: true,
                                validations: if(
                                  len(fv!item.vehicleMake) > 255,
                                  "Value may not be longer than 255 characters. You have entered " & len(fv!item.vehicleMake) & " characters.",
                                  null
                                )
                              )
                            ),
                            a!sideBySideItem(
                              item: a!textField(
                                label: "Model",
                                labelPosition: "ABOVE",
                                value: fv!item.vehicleModel,
                                saveInto: fv!item.vehicleModel,
                                required: true,
                                validations: if(
                                  len(fv!item.vehicleModel) > 255,
                                  "Value may not be longer than 255 characters. You have entered " & len(fv!item.vehicleModel) & " characters.",
                                  null
                                )
                              )
                            ),
                            a!sideBySideItem(
                              item: a!integerField(
                                label: "Year",
                                labelPosition: "ABOVE",
                                value: fv!item.vehicleYear,
                                saveInto: fv!item.vehicleYear,
                                required: true
                              )
                            )
                          }
                        ),
                        a!sideBySideLayout(
                          items: {
                            a!sideBySideItem(
                              item: a!textField(
                                label: "VIN",
                                labelPosition: "ABOVE",
                                value: fv!item.vehicleVIN,
                                saveInto: fv!item.vehicleVIN,
                                required: true,
                                validations: if(
                                  len(fv!item.vehicleVIN) > 17,
                                  "Value may not be longer than 17 characters. You have entered " & len(fv!item.vehicleVIN) & " characters.",
                                  null
                                )
                              ),
                              width: "2X"
                            ),
                            a!sideBySideItem(
                              item: a!integerField(
                                label: "Mileage",
                                labelPosition: "ABOVE",
                                value: fv!item.vehicleMileage,
                                saveInto: fv!item.vehicleMileage,
                                required: true
                              )
                            ),
                            a!sideBySideItem(
                              item: a!textField(
                                label: "Color",
                                labelPosition: "ABOVE",
                                value: fv!item.vehicleColor,
                                saveInto: fv!item.vehicleColor,
                                required: true,
                                validations: if(
                                  len(fv!item.vehicleColor) > 255,
                                  "Value may not be longer than 255 characters. You have entered " & len(fv!item.vehicleColor) & " characters.",
                                  null
                                )
                              )
                            )
                          }
                        ),
                        a!dropdownField(
                          label: "Category",
                          labelPosition: "ABOVE",
                          placeholder: "--- Select category ---",
                          choiceLabels: {"abc"},
                          choiceValues: {"abc"},
                          value: fv!item.vehicleCategory,
                          saveInto: fv!item.vehicleCategory,
                          required: true,
                          validations: {}
                        ),
    
                      }
                    ),
                    a!columnLayout(
                      contents: {
                        a!sectionLayout(
                          label: "Maintenance History",
                          labelSize: "SMALL",
                          contents: {},
                          divider: "NONE"
                        ),
                        a!sideBySideLayout(
                          items: {
                            a!sideBySideItem(
                              item: a!dateField(
                                label: "Last Maintenance",
                                labelPosition: "ABOVE",
                                value: fv!item.vehicleLastMaintenanceDate,
                                saveInto: fv!item.vehicleLastMaintenanceDate,
                                required: true,
                                validations: if(
                                  fv!item.vehicleLastMaintenanceDate > today(),
                                  "Enter a date before today",
                                  ""
                                )
                              )
                            ),
                            a!sideBySideItem(
                              item: a!dateField(
                                label: "Next Maintenance",
                                labelPosition: "ABOVE",
                                value: if(
                                  or(
                                    isnull(fv!item.vehicleLastMaintenanceDate),
                                    isnull(fv!item.vehicleCategory)
                                  ),
                                  "",
                                  caladddays(
                                    fv!item.vehicleLastMaintenanceDate,
                                    rule!AA_DetermineMaintenanceDate(
                                      vehicleCategory: fv!item.vehicleCategory
                                    )
                                  )
                                ),
                                saveInto: fv!item.vehicleNextMaintenanceDate,
                                showWhen: not(isnull(fv!item.vehicleID)),
                                required: false,
                                readonly: true
                              )
                            )
                          }
                        ),
                        a!sideBySideLayout(
                          items: {
                            a!sideBySideItem(
                              item: a!dateField(
                                label: "Added On",
                                labelPosition: "ABOVE",
                                value: fv!item.vehicleDateAdded,
                                showwhen: not(isnull(fv!item.vehicleDateAdded)),
                                required: false,
                                readonly: true,
                                align: "LEFT"
                              )
                            ),
                            a!sideBySideItem(
                              item: a!textField(
                                label: "Added By",
                                labelPosition: "ABOVE",
                                value: rule!AA_displayUser(fv!item.vehicleAddedBy),
                                showwhen: not(isnull(fv!item.vehicleAddedBy)),
                                required: false,
                                readonly: true
                              )
                            )
                          }
                        ),
    
                        a!fileUploadField(
                          label: "Image",
                          labelPosition: "ABOVE",
                          helptooltip: "Upload images in PNG or JPG formats",
                          target: cons!AA_DOCUMENTS_FOLDER_POINTER,
                          maxselections: 1,
                          value: fv!item.vehicleImage,
                          saveInto: fv!item.vehicleImage,
                          validations: a!localVariables(
                            local!invalidExtensions: difference(
                              upper(fv!files.extension),
                              { "PNG", "JPG" }
                            ),
                            if(
                              length(local!invalidExtensions) > 0,
                              "Attachments must be images. Remove: " & index(
                                fv!files,
                                "name",
                                wherecontains(
                                  local!invalidExtensions,
                                  upper(fv!files.extension)
                                ),
                                {}
                              ),
                              ""
                            )
                          )
                        ),
                        a!imageField(
                          label: "",
                          labelPosition: "COLLAPSED",
                          images: if(
                            isnull(fv!item.vehicleImage),
                            null,
                            {
                              a!documentImage(document: fv!item.vehicleImage)
                            }
                          ),
                          showwhen: not(isnull(fv!item.vehicleImage)),
                          size: "MEDIUM",
                          isThumbnail: false,
                          style: "STANDARD",
                          accessibilitytext: "Photo of vehicle"
                        )
                      }
                    )
                  }
                )
              ),
              a!sectionLayout(),
    
            }
          ),
          a!richTextDisplayField(
            value: a!richTextItem(
              text: "add New",
              link: a!dynamicLink(
                saveInto: a!save(
                  local!xyz,
                  append(
                    local!xyz,
                    'type!{urn:com:appian:types}AA_Vehicle'()
                  )
                )
              )
            )
          )
        }
      )
    )

    7 replies

    Participating Frequently
    September 2, 2022

    Yes it is possible please refer to the below screenshots and code.

    a!localVariables(
      local!xyz:'type!{urn:com:appian:types}AA_Vehicle'(),
      a!formLayout(
    
        contents: {
          a!forEach(
            items: local!xyz,
            expression: {
              a!cardLayout(
                contents: a!columnsLayout(
                  columns: {
                    a!columnLayout(
                      contents: {
                        a!sectionLayout(
                          label: "Vehicle Information",
                          labelSize: "SMALL",
                          contents: {},
                          divider: "NONE"
                        ),
                        a!sideBySideLayout(
                          items: {
                            a!sideBySideItem(
                              item: a!textField(
                                label: "Make",
                                labelPosition: "ABOVE",
                                value: fv!item.vehicleMake,
                                saveInto: fv!item.vehicleMake,
                                required: true,
                                validations: if(
                                  len(fv!item.vehicleMake) > 255,
                                  "Value may not be longer than 255 characters. You have entered " & len(fv!item.vehicleMake) & " characters.",
                                  null
                                )
                              )
                            ),
                            a!sideBySideItem(
                              item: a!textField(
                                label: "Model",
                                labelPosition: "ABOVE",
                                value: fv!item.vehicleModel,
                                saveInto: fv!item.vehicleModel,
                                required: true,
                                validations: if(
                                  len(fv!item.vehicleModel) > 255,
                                  "Value may not be longer than 255 characters. You have entered " & len(fv!item.vehicleModel) & " characters.",
                                  null
                                )
                              )
                            ),
                            a!sideBySideItem(
                              item: a!integerField(
                                label: "Year",
                                labelPosition: "ABOVE",
                                value: fv!item.vehicleYear,
                                saveInto: fv!item.vehicleYear,
                                required: true
                              )
                            )
                          }
                        ),
                        a!sideBySideLayout(
                          items: {
                            a!sideBySideItem(
                              item: a!textField(
                                label: "VIN",
                                labelPosition: "ABOVE",
                                value: fv!item.vehicleVIN,
                                saveInto: fv!item.vehicleVIN,
                                required: true,
                                validations: if(
                                  len(fv!item.vehicleVIN) > 17,
                                  "Value may not be longer than 17 characters. You have entered " & len(fv!item.vehicleVIN) & " characters.",
                                  null
                                )
                              ),
                              width: "2X"
                            ),
                            a!sideBySideItem(
                              item: a!integerField(
                                label: "Mileage",
                                labelPosition: "ABOVE",
                                value: fv!item.vehicleMileage,
                                saveInto: fv!item.vehicleMileage,
                                required: true
                              )
                            ),
                            a!sideBySideItem(
                              item: a!textField(
                                label: "Color",
                                labelPosition: "ABOVE",
                                value: fv!item.vehicleColor,
                                saveInto: fv!item.vehicleColor,
                                required: true,
                                validations: if(
                                  len(fv!item.vehicleColor) > 255,
                                  "Value may not be longer than 255 characters. You have entered " & len(fv!item.vehicleColor) & " characters.",
                                  null
                                )
                              )
                            )
                          }
                        ),
                        a!dropdownField(
                          label: "Category",
                          labelPosition: "ABOVE",
                          placeholder: "--- Select category ---",
                          choiceLabels: {"abc"},
                          choiceValues: {"abc"},
                          value: fv!item.vehicleCategory,
                          saveInto: fv!item.vehicleCategory,
                          required: true,
                          validations: {}
                        ),
    
                      }
                    ),
                    a!columnLayout(
                      contents: {
                        a!sectionLayout(
                          label: "Maintenance History",
                          labelSize: "SMALL",
                          contents: {},
                          divider: "NONE"
                        ),
                        a!sideBySideLayout(
                          items: {
                            a!sideBySideItem(
                              item: a!dateField(
                                label: "Last Maintenance",
                                labelPosition: "ABOVE",
                                value: fv!item.vehicleLastMaintenanceDate,
                                saveInto: fv!item.vehicleLastMaintenanceDate,
                                required: true,
                                validations: if(
                                  fv!item.vehicleLastMaintenanceDate > today(),
                                  "Enter a date before today",
                                  ""
                                )
                              )
                            ),
                            a!sideBySideItem(
                              item: a!dateField(
                                label: "Next Maintenance",
                                labelPosition: "ABOVE",
                                value: if(
                                  or(
                                    isnull(fv!item.vehicleLastMaintenanceDate),
                                    isnull(fv!item.vehicleCategory)
                                  ),
                                  "",
                                  caladddays(
                                    fv!item.vehicleLastMaintenanceDate,
                                    rule!AA_DetermineMaintenanceDate(
                                      vehicleCategory: fv!item.vehicleCategory
                                    )
                                  )
                                ),
                                saveInto: fv!item.vehicleNextMaintenanceDate,
                                showWhen: not(isnull(fv!item.vehicleID)),
                                required: false,
                                readonly: true
                              )
                            )
                          }
                        ),
                        a!sideBySideLayout(
                          items: {
                            a!sideBySideItem(
                              item: a!dateField(
                                label: "Added On",
                                labelPosition: "ABOVE",
                                value: fv!item.vehicleDateAdded,
                                showwhen: not(isnull(fv!item.vehicleDateAdded)),
                                required: false,
                                readonly: true,
                                align: "LEFT"
                              )
                            ),
                            a!sideBySideItem(
                              item: a!textField(
                                label: "Added By",
                                labelPosition: "ABOVE",
                                value: rule!AA_displayUser(fv!item.vehicleAddedBy),
                                showwhen: not(isnull(fv!item.vehicleAddedBy)),
                                required: false,
                                readonly: true
                              )
                            )
                          }
                        ),
    
                        a!fileUploadField(
                          label: "Image",
                          labelPosition: "ABOVE",
                          helptooltip: "Upload images in PNG or JPG formats",
                          target: cons!AA_DOCUMENTS_FOLDER_POINTER,
                          maxselections: 1,
                          value: fv!item.vehicleImage,
                          saveInto: fv!item.vehicleImage,
                          validations: a!localVariables(
                            local!invalidExtensions: difference(
                              upper(fv!files.extension),
                              { "PNG", "JPG" }
                            ),
                            if(
                              length(local!invalidExtensions) > 0,
                              "Attachments must be images. Remove: " & index(
                                fv!files,
                                "name",
                                wherecontains(
                                  local!invalidExtensions,
                                  upper(fv!files.extension)
                                ),
                                {}
                              ),
                              ""
                            )
                          )
                        ),
                        a!imageField(
                          label: "",
                          labelPosition: "COLLAPSED",
                          images: if(
                            isnull(fv!item.vehicleImage),
                            null,
                            {
                              a!documentImage(document: fv!item.vehicleImage)
                            }
                          ),
                          showwhen: not(isnull(fv!item.vehicleImage)),
                          size: "MEDIUM",
                          isThumbnail: false,
                          style: "STANDARD",
                          accessibilitytext: "Photo of vehicle"
                        )
                      }
                    )
                  }
                )
              ),
              a!sectionLayout(),
    
            }
          ),
          a!richTextDisplayField(
            value: a!richTextItem(
              text: "add New",
              link: a!dynamicLink(
                saveInto: a!save(
                  local!xyz,
                  append(
                    local!xyz,
                    'type!{urn:com:appian:types}AA_Vehicle'()
                  )
                )
              )
            )
          )
        }
      )
    )

    kavyam0002
    September 6, 2022

    this data how can i store in database. here will be adding multiple data/entries that data at a time to db how can i store it and even how can i design the process model for this requirement

    give me some suggestions 

    September 6, 2022

    You can create CDT and use that CDT to show data into Grid means under rows use the local variable with that CDT and under addnewrow link use the CDT in append function as well. Create a button and on click of that button you can write to DB use the local variable for valueToStore configuration

    a!localVariables(
      local!data:'type!{urn:com:appian:types}Account'(),
      a!formLayout(
        contents: {
          a!forEach(
            items: local!data,
            expression: {
              a!textField(
                label: "Account ID "&fv!index,
                value: fv!item.AccountID,
                saveInto: fv!item.AccountID
              ),
              a!textField(
                label: "Account Name "&fv!index,
                value: fv!item.AccountName,
                saveInto: fv!item.AccountName
              )
            }
          ),
          a!linkField(
            links: a!dynamicLink(
              label: "Add more",
              saveInto: {
                a!save(
                  local!data,
                  append(
                    local!data,
                    'type!{urn:com:appian:types}Account'()
                  )
                )
              }
            )
          ),
          a!buttonLayout(
            a!buttonWidget(
              label:"Save",
              saveInto: {
                a!writeToDataStoreEntity(
                  dataStoreEntity: cons!UAC_ACCOUNT,
                  valueToStore: local!data
                )
              }
            )
          )
        }
      )
    )

    September 2, 2022

    You can do it but before that wanted to know why not you are using grids for this?

    kavyam0002
    September 2, 2022

    you can see above requirement it looks like a form and when the user see the form they'll understand easily, user friendly. even i have asked for any other methods i can go with. am sure with grids it will not be user friendly looks like 

    September 2, 2022

    Oh Okay, Then Yes

    a!localVariables(
      local!data: 'type!{urn:com:appian:types}Account'(),
      a!formLayout(
        contents: {
          a!forEach(
            items: local!data,
            expression: {
              a!textField(
                label: "Account ID "&fv!index,
                value: fv!item.AccountID,
                saveInto: fv!item.AccountID
              ),
              a!textField(
                label: "Account Name "&fv!index,
                value: fv!item.AccountName,
                saveInto: fv!item.AccountName
              )
            }
          ),
          a!linkField(
            links: a!dynamicLink(
              label: "Add more",
              saveInto: {
                a!save(
                  local!data,
                  append(
                    local!data,
                    'type!{urn:com:appian:types}Account'()
                  )
                )
              }
            )
          )
        }
      )
    )