No values have been written. Details: could not insert: [USERROLEDT2804] (APNX-1-4208-004)

Could not display interface. Please check definition and inputs.

Interface Definition: Expression evaluation error: An error occurred while executing a smart service: An error occurred while trying to write to the data store [KONE_User_Development_Database]. No values have been written. Details: could not insert: [USERROLEDT2804] (APNX-1-4208-004)

I make a interface for new user to register, but once new user finish his information fill in and hit submit, the first time is good, all data inserted to back end without problem. However,if he click twice in submit button, always jump out report error as above.

  Discussion posts and replies are publicly visible

  • I doubt it might be the name column is unique but that person click twice though auto increment a new userId as primary key but the name is replicated so which not allowed.

  • 0
    Certified Lead Developer
    in reply to immortalvirgil

    OK. Then you might want to prevent the user from clicking twice. Not sure about the exact use case. When I do things like this, I modify the state of the UI in a way the user can not enter the same data multiple times.

  • Thank you sir, I am new to appian not go that far yet, are there other refer to document i can see such process or UI interface?

  • 0
    Certified Lead Developer
    in reply to immortalvirgil

    AFAIK you use a!writetodatastore. Why not just clean all the fields using some a!save() in the onSuccess parameter. You already know how to do that from another post.

  • That is what I already did and it is work well. After clean to empty i let the submit button being disabled until all fields are going to become filled

  • 0
    Certified Associate Developer
    in reply to immortalvirgil

    Hi,

    Can you please check the tom-cat log for the root cause? That will help to identify the error.

    Thanks,

    Hema

  • a!localVariables(
      local!rule:rule!KONE_Development_userinputsheet_Rule(),
      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: all(fn!isnull, {ri!userinputsheet.KONE_user_name}),
      a!sectionLayout(
        label:"Update Info",
        contents: {
          a!columnsLayout(
            columns: {
              a!columnLayout(
                contents: {
                  a!textField(
                    label: "Username",
                    value: ri!userinputsheet.KONE_user_name,
                    saveInto: ri!userinputsheet.KONE_user_name,
                    refreshAfter: "KEYPRESS"
                  ),
                  a!buttonLayout(
                    primaryButtons: {
                      a!buttonWidget(
                        label: "SEARCH",
                        saveInto: {
                          ri!userinputsheet.KONE_user_name
                        },
                        disabled: local!noFiltersApplied
                      )
                    }
                  ),
                  a!gridLayout(
                    label: "Editable Grid",
                    labelPosition: "ABOVE",
                    headerCells: {
                      a!gridLayoutHeaderCell(
                        label: "Username"
                      ),
                      a!gridLayoutHeaderCell(
                        label: "First Name"
                      ),
                      a!gridLayoutHeaderCell(
                        label: "Last Name"
                      ),
                      a!gridLayoutHeaderCell(
                        label: "Email"
                      ),
                      a!gridLayoutHeaderCell(
                        label: "Role"
                      ),
                      a!gridLayoutHeaderCell(
                        label: "Branch"
                      ),
                      a!gridLayoutHeaderCell(
                        label: "Region"
                      ),
                      a!gridLayoutHeaderCell(
                        label: "Manager_role"
                      ),
                      a!gridLayoutHeaderCell(
                        label: "Language"
                      ),
                      a!gridLayoutHeaderCell(
                        label: "CE_LEVEL"
                      ),
                      a!gridLayoutHeaderCell(
                        label: "Telephone Number"
                      ),
                      a!gridLayoutHeaderCell(
                        label: "Exceptional Case Library View Right"
                      ),
                      a!gridLayoutHeaderCell(
                        label: "Update"
                      ),
                      a!gridLayoutHeaderCell(
                        label: "Delete"
                      ),
                      a!gridLayoutHeaderCell(
                        label: "Restart"
                      )
                    },
                    columnConfigs: {
                      a!gridLayoutColumnConfig(
                        width: "DISTRIBUTE"
                      ),
                      a!gridLayoutColumnConfig(
                        width: "DISTRIBUTE"
                      ),
                      a!gridLayoutColumnConfig(
                        width: "DISTRIBUTE"
                      ),
                      a!gridLayoutColumnConfig(
                        width: "DISTRIBUTE"
                      ),
                      a!gridLayoutColumnConfig(
                        width: "DISTRIBUTE"
                      ),
                      a!gridLayoutColumnConfig(
                        width: "DISTRIBUTE"
                      ),
                      a!gridLayoutColumnConfig(
                        width: "DISTRIBUTE"
                      ),
                      a!gridLayoutColumnConfig(
                        width: "DISTRIBUTE"
                      ),
                      a!gridLayoutColumnConfig(
                        width: "DISTRIBUTE"
                      ),
                      a!gridLayoutColumnConfig(
                        width: "DISTRIBUTE"
                      ),
                      a!gridLayoutColumnConfig(
                        width: "DISTRIBUTE"
                      ),
                      a!gridLayoutColumnConfig(
                        width: "DISTRIBUTE"
                      ),
                      a!gridLayoutColumnConfig(
                        width: "DISTRIBUTE"
                      ),
                      a!gridLayoutColumnConfig(
                        width: "DISTRIBUTE"
                      ),
                      a!gridLayoutColumnConfig(
                        width: "DISTRIBUTE"
                      )
                    },
                    rows: {
                      a!forEach(
                        items: local!rule,
                        expression:a!gridRowLayout(
                          contents: {
                            a!textField(
                              label: "Username",
                              labelPosition: "ABOVE",
                              value:fv!item.KONE_user_name,
                              saveInto: {
                                fv!item.KONE_user_name,
                              a!save(target:ri!userinputsheet.KONE_user_name,value:save!value),
                              a!save(target:ri!userrole.NAME,value:save!value),
                              a!save(target:ri!userrole.USER_ID,value:a!localVariables(local!value:fv!item.KONE_user_name,
                              a!forEach(
                                items:rule!KONE_Development_Username_UserId(),
                                expression: if(local!value=fv!item.username,fv!item.userid,{}),
                              ),
                              )),
                              },
                              refreshAfter: "UNFOCUS",
                              readOnly: true,
                              validations: {}
                            ),
                            a!textField(
                              label: "First Name",
                              labelPosition: "ABOVE",
                              value:fv!item.FIRST_NAME,
                              saveInto: {fv!item.FIRST_NAME,
                                a!save(target:ri!userinputsheet.FIRST_NAME,value:save!value)},
                              refreshAfter: "UNFOCUS",
                              validations: {}
                            ),
                            a!textField(
                              label: "Last Name",
                              labelPosition: "ABOVE",
                              value:fv!item.LAST_NAME,
                              saveInto: {fv!item.FIRST_NAME,
                              a!save(target:ri!userinputsheet.LAST_NAME,value:save!value),
                              },
                              refreshAfter: "UNFOCUS",
                              validations: {}
                            ),
                            a!textField(
                              label: "Email",
                              labelPosition: "ABOVE",
                              value:fv!item.Email,
                              saveInto: { 
                                fv!item.Email,
                                a!save(target:ri!userinputsheet.Email,
                              value:save!value),
                              a!save(target:ri!userrole.EMAIL,value:save!value)},
                              refreshAfter: "UNFOCUS",
                              validations: {}
                            ),
                            a!dropdownField(
                              label: "Role",
                              labelPosition: "ABOVE",
                              choiceLabels:reject(fn!isnull,local!allRole),
                              choiceValues:reject(fn!isnull,local!allRole),
                              value:if(isnull(fv!item.Role),"null",fv!item.Role),
                              saveInto:{
                                fv!item.Role,
                                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.ROLE,
                                    value: save!value),
                                    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,{})        
                                    ))
                              },
                              validations: {}
                            ),
                            a!dropdownField(
                              label: "Branch",
                              labelPosition: "ABOVE",
                              choiceLabels:reject(fn!isnull,local!allBranch),
                              choiceValues:reject(fn!isnull,local!allBranch),
                              value:if(isnull(fv!item.Branch),"null",fv!item.Branch),
                              saveInto:{
                                fv!item.Branch,
                                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,{})        
                                ))
                              },
                              refreshAfter: "UNFOCUS",
                              validations: {}
                            ),
                            a!dropdownField(
                              label: "Region",
                              labelPosition: "ABOVE",
                              choiceLabels:reject(fn!isnull,local!allRegion),
                              choiceValues:reject(fn!isnull,local!allRegion),
                              value:fv!item.Region,
                              saveInto:{
                                fv!item.Region,
                                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,{})        
                                ))
                              },
                              refreshAfter: "UNFOCUS",
                              validations: {}
                            ),
                            a!dropdownField(
                              label: "Manager_role",
                              labelPosition: "ABOVE",
                              choiceLabels:reject(fn!isnull,local!allRole),
                              choiceValues:reject(fn!isnull,local!allRole),
                              value:if(isnull(fv!item.Manager_role),"null",fv!item.Manager_role),
                              saveInto:{
                                fv!item.Manager_role,
                                a!save(target:ri!userinputsheet.Manager_role,value:save!value)
                              },
                              refreshAfter: "UNFOCUS",
                              validations: {}
                            ),
                            a!dropdownField(
                              label: "Language",
                              labelPosition: "ABOVE",
                              choiceLabels:reject(fn!isnull,local!allLanguage),
                              choiceValues:reject(fn!isnull,local!allLanguage),
                              value:if(isnull(ri!userinputsheet.Language),"null",ri!userinputsheet.Language),
                              saveInto:{
                                fv!item.Language,
                                a!save(target:ri!userinputsheet.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!userinputsheet.Language,fv!item.Language_Id,{})        
                                ))
                              },
                              refreshAfter: "UNFOCUS",
                              validations: {}
                            ),
                            a!textField(
                              label: "CE_LEVEL",
                              labelPosition: "ABOVE",
                              value:fv!item.CE_LEVEL,
                              saveInto: {
                                fv!item.CE_LEVEL,
                                a!save(target:ri!userinputsheet.CE_LEVEL,value:save!value),
                                a!save(target:ri!userrole.LEVEL,value:save!value)
                              },
                              refreshAfter: "UNFOCUS",
                              validations: {}
                            ),
                            a!textField(
                              label: "Telephone Number",
                              labelPosition: "ABOVE",
                              value:fv!item.Telephone_number,
                              saveInto: {
                                fv!item.Telephone_number,
                                a!save(target:ri!userinputsheet.Telephone_number,value:save!value),
                                a!save(target:ri!userrole.TELEPHONE_NUMBER,value:save!value)
                              },
                              refreshAfter: "UNFOCUS",
                              validations: {}
                            ),
                            a!textField(
                              label: "Exceptional Case Library View Right",
                              labelPosition: "ABOVE",
                              value:fv!item.Exceptional_case_library_view_right,
                              saveInto: {
                                fv!item.Exceptional_case_library_view_right,
                                a!save(target:ri!userinputsheet.Exceptional_case_library_view_right,value:save!value),
                                a!save(target:ri!userrole.IS_EXCEPTION,value:0),
                                a!save(target:ri!userrole.ACTIVE,value:1),
                                a!save(target:ri!userinputsheet.updateTime,value:now()),
                              },
                              refreshAfter: "UNFOCUS",
                              validations: {}
                            ),
                            a!richTextDisplayField(
                              label:"Update",
                              labelPosition:"ABOVE",
                              value:{
                                a!richTextIcon(
                                  icon:"check",
                                  link:a!dynamicLink(
                                    saveInto:{
                                      a!writeToMultipleDataStoreEntities(
                                        valuesToStore: {
                                          a!entityData(entity: cons!KONE_Development_userinputsheet_Constant, data: ri!userinputsheet),
                                          a!entityData(entity: cons!KONE_Development_userrole_Constant, data: ri!userrole)
                                        }
                                      ),
                                    }
                                  ),
                                  linkStyle:"STANDALONE",
                                  color:"POSITIVE"
                                )
                              }
                            ),
                            a!richTextDisplayField(
                              label:"Delete",
                              labelPosition:"ABOVE",
                              value:{
                                a!richTextIcon(
                                  icon:"arrow-down",
                                  link:a!dynamicLink(
                                    saveInto:{a!save(target:ri!userrole.ACTIVE,value:0),
                                    a!writeToMultipleDataStoreEntities(
                                      valuesToStore: {
                                        a!entityData(entity: cons!KONE_Development_userinputsheet_Constant, data: ri!userinputsheet),
                                        a!entityData(entity: cons!KONE_Development_userrole_Constant, data: ri!userrole)
                                      },
                                    ),
                                    }
                                  ),
                                  linkStyle:"STANDALONE",
                                  color:"NEGATIVE"
                                )
                              }
                            ),
                            a!richTextDisplayField(
                              label:"Restart",
                              labelPosition:"ABOVE",
                              value:{
                                a!richTextIcon(
                                  icon:"arrow-up",
                                  link:a!dynamicLink(
                                    saveInto:{a!save(target:ri!userrole.ACTIVE,value:1),
                                    a!writeToMultipleDataStoreEntities(
                                      valuesToStore: {
                                        a!entityData(entity: cons!KONE_Development_userinputsheet_Constant, data: ri!userinputsheet),
                                        a!entityData(entity: cons!KONE_Development_userrole_Constant, data: ri!userrole)
                                      },
                                    ),
                                    }
                                  ),
                                  linkStyle:"STANDALONE",
                                  color:"POSITIVE",
                                )
                              }
                            ),
                          }
                        )
                      )
                    },
                  ),
                }
              )
            }
          )
        }
      )
    )
    

    would you watch this for me again where it reappear the same error for Details: could not insert: [USERROLEDT2804] (APNX-1-4208-004). The userrole table primariy key as userid, but the username have to be unique as well, I wish to make an update interface but set the userid and username readonly since they are primary key and unique. Theoretically should be insert successfully, how it report this? appreciate your help