avoid insert duplicate information to database and give a hint to the user

Sorry, i keep looking for ways to not let user insert duplicate username to the database, but always fails, i know primary key as username can't be repeatedly insert in to the database by its service, but i just want

to give user a hint, and tell him can't register same username others used before and let it not to update to the back end database by its smartservice, then how can I do?

{

label: "Insert",
saveInto:(
a!writeToDataStoreEntity(
dataStoreEntity: cons!usernameConstant,
valueToStore:(ri!username)
),
),

submit: if(ri!username.username in local!rule.username
,false,true),
style: "PRIMARY",

}      OR

label: "Insert",

saveInto:(

if(

ri!username.username in local!rule.username,

{},
a!writeToDataStoreEntity(
dataStoreEntity: cons!usernameConstant,
valueToStore:(ri!username)

)
),
),

submit: true,
style: "PRIMARY",

  Discussion posts and replies are publicly visible

Parents Reply
  • a!localVariables(
      local!rule:rule!usernameRule(),
    a!formLayout(
      label: "Username",
      contents: {
        a!textField(
          label: "username",
          labelPosition: if(
            ri!readOnly,
            "ADJACENT",
            "ABOVE"
          ),
          value: ri!username.username,
          saveInto: ri!username.username,
          refreshAfter: "UNFOCUS",
          validations: {}
        ),
        a!textField(
          label: "gender",
          labelPosition: if(
            ri!readOnly,
            "ADJACENT",
            "ABOVE"
          ),
          value: ri!username.gender,
          saveInto: ri!username.gender,
          refreshAfter: "UNFOCUS",
          validations: {}
        ),
        a!columnsLayout(
          columns: {
            a!columnLayout(
              contents: {
                a!textField(
                  label: "Password",
                  labelPosition: if(
                    ri!readOnly,
                    "ADJACENT",
                    "ABOVE"
                  ),
                  value: ri!username.password,
                  saveInto: ri!username.password,
                  characterLimit: 255,
                  readOnly: ri!readOnly
                )
              }
            )
          }
        ),
      },
     
      buttons: a!buttonLayout(
        primaryButtons: {
          a!buttonWidget(
            label: "Insert",
            
            saveInto:(
              a!writeToDataStoreEntity(
                dataStoreEntity: cons!usernameConstant,
                valueToStore:(ri!username)
               ),       
               ),
               
            submit: if(ri!username.username in local!rule.username
            ,false,true),
            style: "PRIMARY",
          ),
          a!buttonWidget(
            label: "update",
            saveInto:(
              a!writeToDataStoreEntity(
                dataStoreEntity: cons!usernameConstant,
                valueToStore:ri!username,           
              ),
            ),
            submit: true,
            style: "PRIMARY"
          ),
          a!buttonWidget(
            label: "delete",      
            saveInto:(
              a!deleteFromDataStoreEntities(
                dataToDelete: {
                  a!entityDataIdentifiers(
                    entity: cons!usernameConstant,
                    identifiers:{ri!username.username},
                  )
                }
              )
            ),
            submit: true,
            style: "PRIMARY"
          )
        },
        secondaryButtons: {
          a!buttonWidget(
            label: "Cancel",
            value: true,
            saveInto: ri!cancel,
            submit: true,
            style: "NORMAL",
            validate: false
          )
        },
        showWhen: or(
          isnull(
            ri!readOnly
          ),
          not(
            ri!readOnly
          )
        )
      )
     
    )
    )
    

Children