Skip to main content
August 27, 2021
Question

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

  • August 27, 2021
  • 22 replies
  • 0 views

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",

    22 replies

    stefanhelzle0001
    Brainy
    August 27, 2021

    Why not add a validation to the user name field which checks whether the entered value already exists?

    August 27, 2021

    would you give an example, i don't have sample code for "validation" part to study, i would be super appreciate

    stefanhelzle0001
    Brainy
    August 27, 2021

    Something like this

    if(
      a!queryEntity(
        /* Search for entered username */
      ).totalCount > 0,
      "Error",
      null
    )