form layout problems

I am trying to combine different interfaces into one interface, However it keeps return with error with "The contents field on a column layout cannot contain a form layout. Received a form layout at index 1.".

What is the problem, by the way, if there is a rule input boolean value with pending true or false, then how should i fill in the rule!(????). Anyone tell me?

  Discussion posts and replies are publicly visible

  • A Form Layout is in effect the outermost container for a user interface for Start or Task forms. Therefore you cannot have a form layout inside any other interface layout component. It seems like you have a form layout in the contents attribute of a column layout (this is what the message is telling you).

    I don't understand your second point, could you elaborate please?

  • a!localVariables(
      local!chooseValue:1,
      local!buttonChoice,
      local!backupuserauditcasttype:rule!KONE_Development_BACKUP_USER_AUDIT_castType(),
      local!userrolecasttype:rule!KONE_Development_USER_ROLE_castType(),
      a!formLayout(
        label:choose(local!chooseValue,"KONE Maintenanence System","Registration System","Update System","Delete System"),
        contents:{
          a!radioButtonField(
            label: "Please Choose",
            labelPosition: "COLLAPSED",
            choiceLabels: {"Registration", "Update","Delete"},
            choiceValues: {"Registration", "Update","Delete"},
            value:local!buttonChoice,
            saveInto: {a!save(target:local!buttonChoice,value:save!value),
                      if(local!buttonChoice="Registration",
                      a!save(target:local!chooseValue,value:2),
                      if(local!buttonChoice="Update",
                      a!save(target:local!chooseValue,value:3),
                      if(local!buttonChoice="Delete",
                      a!save(target:local!chooseValue,value:4),
                      {}
                      )
                      )
                      ) 
                      },
            choiceLayout: "STACKED",
            validations: {}
          ),
        a!imageField(
          label: "Image",
          labelPosition: "COLLAPSED",
          images: {
            a!documentImage(
              document: cons!KONE_IMAGE01
            )
          },
          showWhen:local!chooseValue=1,
          size: "LARGE",
          isThumbnail: false,
          style: "STANDARD"
        ),
        
          rule!KONE_Development_Insert_Interface(backupuseraudit:local!backupuserauditcasttype, userrole:local!userrolecasttype,
          submit:true(),
          )
        }
      ),
    )

    Though i didn't a!formLayout inside contents but it is still report. The second one is what shall I put inside the interface rule!KONE_Development_insert_Interface() bracket? The submit as boolean value processed through inside the interface, no one know whether it is true or false, then how should i do?

  • If rule!KONE_Development_Insert_Interface() contains an a!formLayout() then this is why you are getting the message. Referencing code in another rule is like having copied/pasted that code into your current code, so that's almost certainly why you are getting the validation message.

    Without looking inside your contained rule I cannot comment ion what it is doing with the submit: true() value you are passing to it.

  • here it is. I have three interface like this need to combine together

    a!localVariables(
      local!switchValue,
      local!allRole:rule!KONE_Development_Role(),
      local!allLanguage:rule!KONE_Development_Language(),
      local!allBranch:rule!KONE_Development_Branch(),
      local!allRegion:rule!KONE_Development_Region(),
      local!noFiltersApplied: any(fn!isnull, {ri!backupuseraudit.koneusername,
      ri!backupuseraudit.firstname,
      ri!backupuseraudit.lastname,
      ri!backupuseraudit.email,
      ri!backupuseraudit.role,
      ri!backupuseraudit.branch,ri!backupuseraudit.region,ri!backupuseraudit.managerrole,
      ri!backupuseraudit.language,ri!backupuseraudit.celevel,ri!backupuseraudit.telephonenumber,
      }),
    
    
      a!formLayout(
        label:"Registration",
        contents: {
          a!textField(
            label: "Username(please fill lower case or it will switch to be lower)",
            value: {trim(lower(ri!backupuseraudit.koneusername))},
            saveInto: {
              a!save(target:ri!backupuseraudit.koneusername,
              value:save!value),
              a!save(target:ri!userrole.NAME,
              value:save!value)
            },
            required: true,
            validations:a!forEach(
            items:rule!KONE_Development_userrole(),
            expression:if(fv!item=ri!backupuseraudit.koneusername,"Username exists",{})
            )
          ),
          a!textField(
            label: "FirstName",
            value: {ri!backupuseraudit.firstname},
            saveInto: {ri!backupuseraudit.firstname},
            required: true
          ),
          a!textField(
            label: "LastName",
            value: {ri!backupuseraudit.lastname},
            saveInto: {ri!backupuseraudit.lastname},
            required: true
          ),
          a!textField(
            label: "Email",
            value: {ri!backupuseraudit.email},
            saveInto: {
              a!save(target:ri!backupuseraudit.email,
              value:save!value),
              a!save(target:ri!userrole.EMAIL,value:save!value)
            },
            required: true,
            validations: if(find("@",ri!backupuseraudit.email),if(find(".com",ri!backupuseraudit.email),null,"not contain correction .com"),if(find(".com",ri!backupuseraudit.email),"not contain @","not contain @ and .com"))
          ),
          a!dropdownField(
            label:"Role",
            placeholder:"---please fill your Role---",
            choiceLabels:reject(fn!isnull,local!allRole),
            choiceValues:reject(fn!isnull,local!allRole),
            value:ri!backupuseraudit.role,
            saveInto:{
              a!save(target:ri!backupuseraudit.role,value:save!value),
              a!save(
                target:ri!userrole.ROLE_ID,
                value: a!forEach
                (items:rule!KONE_Development_Role_RoleId(),
                expression:if(fv!item.role=ri!backupuseraudit.role,fv!item.Role_Id,{})        
                )),
                a!save(target:ri!userrole.PHASE_ID,
                value:a!forEach
                (items:rule!KONE_Development_Role_RoleId(),
                expression:if(fv!item.Role=ri!backupuseraudit.Role,fv!item.Role_Id,{})        
                ))
            },
            required:true       
          ),
          a!dropdownField(
            label:"Branch",
            placeholder:"---please fill your Branch---",
            choiceLabels:reject(fn!isnull,local!allBranch),
            choiceValues:reject(fn!isnull,local!allBranch),
            value:ri!backupuseraudit.Branch,
            saveInto:{
              a!save(target:ri!backupuseraudit.Branch,value:save!value),
              a!save(target:ri!userrole.BRANCH,value:save!value),
              a!save(target:ri!userrole.BRANCH_ID,
              value:a!forEach
              (items:rule!KONE_Development_Branch_BranchId(),
              expression:if(fv!item.Branch=ri!backupuseraudit.Branch,fv!item.Branch_Id,{})        
              ))
            },
            required:true       
          ),
          a!dropdownField(
            label:"Region",
            placeholder:"---please fill your Region---",
            choiceLabels:reject(fn!isnull,local!allRegion),
            choiceValues:reject(fn!isnull,local!allRegion),
            value:ri!backupuseraudit.region,
            saveInto:{
              a!save(target:ri!backupuseraudit.region,value:save!value),
              a!save(target:ri!userrole.REGION,value:save!value),
              a!save(target:ri!userrole.REGION_ID,
              value:a!forEach
              (items:rule!KONE_Development_Region_RegionId(),
              expression:if(fv!item.Region=ri!backupuseraudit.region,fv!item.Region_Id,{})        
              ))
            },
            required:true       
          ),
          a!dropdownField(
            label:"Manager_Role",
            placeholder:"---please fill your Role---",
            choiceLabels:reject(fn!isnull,local!allRole),
            choiceValues:reject(fn!isnull,local!allRole),
            value:ri!backupuseraudit.managerrole,
            saveInto:{
              a!save(target:ri!backupuseraudit.managerrole,value:save!value)
            },
            required:true     
          ),
          a!dropdownField(
            label:"Language",
            placeholder:"---please fill your Language---",
            choiceLabels:reject(fn!isnull,local!allLanguage),
            choiceValues:reject(fn!isnull,local!allLanguage),
            value:ri!backupuseraudit.language,
            saveInto:{
              a!save(target:ri!backupuseraudit.language,value:save!value),
              a!save(target:ri!userrole.LANG_ID,
              value:a!forEach
              (items:rule!KONE_Development_Language_LanguageId(),
              expression:if(fv!item.Language=ri!backupuseraudit.language,fv!item.Language_Id,{})        
              ))
            },
            required:true       
          ),
          a!textField(
            label: "CELevel",
            value: {ri!backupuseraudit.celevel},
            saveInto: {
              a!save(target:ri!backupuseraudit.celevel,value:save!value),
              a!save(target:ri!userrole.LEVEL,value:save!value)
            },
            required: true
          ),
          a!textField(
            label: "Telephone Number",
            value: {ri!backupuseraudit.telephonenumber},
            saveInto: {
              a!save(target:ri!backupuseraudit.telephonenumber,value:save!value),
              a!save(target:ri!userrole.TELEPHONE_NUMBER,value:save!value)
            },
            required: true,
            validations: if( len(ri!backupuseraudit.telephonenumber) <> 11, "phone number should be 11 digits", null )
          ),
          a!textField(
            label: "Exceptional Case Library View Right",
            value: {ri!backupuseraudit.exceptinlcselibrryviewright},
            saveInto: {
              a!save(target:ri!backupuseraudit.exceptinlcselibrryviewright,value:save!value),
              a!save(target:ri!userrole.IS_EXCEPTION,value:0),
              a!save(target:ri!userrole.ACTIVE,value:1)
            },
            required: true
          ),
          a!buttonArrayLayout(
            buttons: {
              a!buttonWidget(
                label: "Go Back",
                saveInto:a!save(target:local!switchValue,value:0),
                style: "NORMAL"
              ),
              a!buttonWidget(
                label: "submit2",
                style: "NORMAL",
                saveInto:{
                a!save(target:ri!submit,value:true()),
                a!save(target:ri!backupuseraudit.updatetime,value:now()),
                a!save(target:ri!backupuseraudit.reason,value:"Insert"),
                a!save(target:ri!backupuseraudit.backupby,value:loggedInUser()),
                a!save(target:ri!backupuseraudit.backupon,value:now()),
                a!startProcess(
                  processModel: cons!KONE_Development_Insert_PM_constant,
                  processParameters:{backupuseraudit:ri!backupuseraudit,userrole:ri!userrole}
                )
                }
              )
            },
            align: "START"
          )    
        },
        buttons:a!buttonLayout(
          primaryButtons:{
            a!buttonWidget(
              label: "Clear",
              saveInto:{
                a!save(target:ri!backupuseraudit,value:null())
              },
              style: "NORMAL"
            ),
            a!buttonWidget(
              label: "Submit",
              saveInto:{
                a!save(target:ri!backupuseraudit.updatetime,value:now()),
                a!save(target:ri!backupuseraudit.reason,value:"Insert"),
                a!save(target:ri!backupuseraudit.backupby,value:loggedInUser()),
                a!save(target:ri!backupuseraudit.backupon,value:now()),
                a!writeToMultipleDataStoreEntities(
                  a!entityData(entity: cons!KONE_Development_BACKUP_USER_AUDIT_Constant, data:ri!backupuseraudit),
                  a!entityData(entity: cons!KONE_Development_userrole_Constant, data:ri!userrole)
                )
              },
              submit: true,
              style: "PRIMARY",
              disabled:local!noFiltersApplied
            )
          }
        )
      )
     
    )

  • Only the main interface should use a!formLayout(). The sub-interfaces should use a!columnsLayout() or a!sectionLayout() or a!cardLayout() or a!boxLayout() depending on the requirememt

  • One of the easiest ways to resolve this initially is to change any instances of a!formLayout() in sub-rules to a!sectionLayout(). Then you can reference these inside of another rule. If you need to also move buttons or other functionality from the form, you may need to manually copy that over into your parent rule.

  • seems almost there, it doesn't report error, but write code in the interface though I add contents: under a!sectionLayout, why?

  • 0
    Certified Lead Developer
    in reply to immortalvirgil

    Something in your code isn't formatted properly, it looks as though the sectionLayout's "label" parameter is seeing the entire back-end code from the sub-interface you're trying to call.  Check for missing close quotes, commas, etc.

    As a side note, in the spirit of "keeping it simple", I highly suggest you practice more basic SAIL coding before attempting such advanced stuff.  These types of things aren't nearly so big of an issue once you have sufficient practice/experience.