How to make the active column from database can't be null switch to be allowed?

a!localVariables(
  
  
   
  local!allRole:rule!KONE_Development_ROLE(),
  local!allLanguage:rule!KONE_Development_LANGUAGE(),
  local!allBranch:rule!KONE_Development_BRANCH(),
  local!allRegion:rule!KONE_Development_REGION(),
 
    

  a!formLayout(
    contents: {
      a!textField(
        label: "Username",
        value: {ri!userinputsheet.kone_user_name},
        saveInto: {
          a!save(target:ri!userinputsheet.kone_user_name,
                 value:save!value),
          a!save(target:ri!userrole.NAME,
                 value:save!value),
         },
        required: true
      ),
      a!textField(
        label: "firstName",
        value: {ri!userinputsheet.FIRST_NAME},
        saveInto: {ri!userinputsheet.FIRST_NAME},
        required: true
      ),
      a!textField(
        label: "LastName",
        value: {ri!userinputsheet.LAST_NAME},
        saveInto: {ri!userinputsheet.LAST_NAME},
        required: true
      ),
      a!textField(
        label: "Email",
        value: {ri!userinputsheet.Email},
        saveInto: {
          a!save(target:ri!userinputsheet.Email,
                 value:save!value),
          a!save(target:ri!userrole.EMAIL,value:save!value),
        },
        required: true
      ),
      a!dropdownField(
        label:"Role",
        placeholder:"---please fill your Role---",
        choiceLabels:reject(fn!isnull,local!allRole),
        choiceValues:reject(fn!isnull,local!allRole),
        value:ri!userinputsheet.Role,
        saveInto:{
        a!save(target:ri!userinputsheet.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!userinputsheet.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!userinputsheet.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!userinputsheet.Branch,
        saveInto:{
        a!save(target:ri!userinputsheet.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!userinputsheet.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!userinputsheet.Region,
        saveInto:{
        a!save(target:ri!userinputsheet.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!userinputsheet.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!userinputsheet.Manager_role,
        saveInto:{
          a!save(target:ri!userinputsheet.Manager_role,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!userinputsheet.Language,
        saveInto:{
        a!save(target:ri!userinputsheet.Language,value:save!value),
        a!save(target:ri!userrole.LANGUAGE_ID,
        value:a!forEach
        (items:rule!KONE_Development_Language_LanguageId(),
        expression:if(fv!item.Language=ri!userinputsheet.Language,fv!item.Language_Id,{})        
        ))
        },
        required:true       
      ),
      a!textField(
        label: "CELevel",
        value: {ri!userinputsheet.CE_LEVEL},
        saveInto: {
          a!save(target:ri!userinputsheet.CE_LEVEL,value:save!value),
          a!save(target:ri!userrole.LEVEL,value:save!value)
        },
        required: true
      ),
      a!textField(
        label: "Telephone Number",
        value: {ri!userinputsheet.Telephone_number},
        saveInto: {
          a!save(target:ri!userinputsheet.Telephone_number,value:save!value),
          a!save(target:ri!userrole.TELEPHONE_NUMBER,value:save!value)
        },
        required: true
      ),
      a!textField(
        label: "Exceptional Case Library View Right",
        value: {ri!userinputsheet.Exceptional_case_library_view_right},
        saveInto: {
          a!save(target:ri!userinputsheet.Exceptional_case_library_view_right,value:save!value),
          a!save(target:ri!userrole.IS_EXCEPTION,value:save!value),
        },
        required: true
      )
      
    },
    buttons: a!buttonLayout(
      primaryButtons: {
        a!buttonWidget(
          label: "Submit",
          saveInto:(
            a!writeToDataStoreEntity(
              dataStoreEntity: {cons!KONE_Development_userrole_Constant,cons!KONE_Development_userinputsheet_Constant},
              valueToStore:{ri!userrole,ri!userinputsheet}          
            ),
          ),
          submit: true,
          style: "PRIMARY"
        )
       
      }
      
    )
  )
)

error is: Interface Definition: Expression evaluation error: An error occurred while executing a smart service: An error occurred while trying to write to the entity "KONE_Development_userrole" [id=8a2e408a-8d63-40b5-8b0b-ac820966b9ea@16406, type=USER_ROLE (id=3178)] (data store: KONE_User_Development_Database). Details: org.hibernate.exception.ConstraintViolationException: could not insert: [USERROLEDT2804]: java.sql.SQLIntegrityConstraintViolationException: (conn=65245) Column 'ACTIVE' cannot be null: org.mariadb.jdbc.internal.util.exceptions.MariaDbSqlException: Column 'ACTIVE' cannot be null: java.sql.SQLException: Column 'ACTIVE' cannot be null Data: TypedValue[it=3179,v={{<null>,immortalvirgil,luzhe.wang@accenture.com,,131,131,CNZZ,SO,,,,,41,6,<null>,<null>,<null>,<null>,,,<null>,6,8613478478682,0,},{<null>,,luzhe.wang@accenture.com,HQ CSE Manager,<null>,<null>,CNZZ,SO,,,,HQ SC CSE Engineer,<null>,<null>,<null>,<null>,<null>,<null>,,,<null>,<null>,8613478478682,<null>,}}]

how can i make the active column can be null? Thank you so much

  Discussion posts and replies are publicly visible

Parents
  • +1
    Certified Lead Developer

    You need to have one of your existing field's saveInto parameters (it doesn't really matter which one, as long as it's one the user has to fill out), set a value for all required columns such as "isActive".

    Additionally I don't believe a!writeToDataStoreEntity will accept an array of DSE constants like in your original posted code, but I think some other responders have already addressed this (i assume you should be able to use a!writeToMultipleDataStoreEntities() instead).

Reply
  • +1
    Certified Lead Developer

    You need to have one of your existing field's saveInto parameters (it doesn't really matter which one, as long as it's one the user has to fill out), set a value for all required columns such as "isActive".

    Additionally I don't believe a!writeToDataStoreEntity will accept an array of DSE constants like in your original posted code, but I think some other responders have already addressed this (i assume you should be able to use a!writeToMultipleDataStoreEntities() instead).

Children