How to validate duplicate values whitin an array field while opening a new change register

I'm trying these :

on change management, open a new record change, i'm filling the required fields.  The assets field is one of them. It's an array field and i don´t know if it is possible to set a validation so that the values be unique.

In this example, while opening a new record change, the assets field has 7 values, and they're all different  :

assets :  SOL  NUBE  RAYO  TRUENO  LUNA  ESTRELLA  LLUVIA

 

In this other example, while opening a new record change, the assets field has 5 values :

assets : SOL  LUNA  SOL  RAYO  RAYO

and there are 2 values repeated

¿Is it possible to stablish a validation to show a message like "The values on the assets field must be unique"? ¿the validation must be set in formatctrl? ¿as a calculation  or  with a javascript?

 

Any suggestions?  please.

 

Thanks in advance,

Norita

 

Parents
  • Hi Norita,

     

    I have an array field that I didn't want duplicates in also, but I don't do a validation when duplicates are entered, I just remove the duplicates on update.  If this interests you, let me know and I will give you details on how I did it.

     

    Audrey 

  • Hi Audrey,  perhaps it will be the solutions for me too.  Please tell me how to remove duplicates from the array.

     

    Thanks in advance,

    Norita

  • Verified Answer

    Hi Norita,

     

    If your field is assets, then you would add a couple Calculations to your formatctrl as follows:

     

    Add/Update: true

    Calculation:  $temp.assets={};$assets=denull(assets in $file);$assets.lng=lng($assets)

     

    Add/Update:  lng($assets)>0

    Calculation: for $assets.i = 1 to $assets.lng do (if (not null($assets.i in $assets)) then if (index($assets.i in $assets, $temp.assets)=0) then ($temp.assets=insert($temp.assets, 1, 1, $assets.i in $assets)));assets in $file=$temp.assets

     

    If your field name is not assets, then modify as necessary.  I hope this helps.

     

    Audrey

Reply
  • Verified Answer

    Hi Norita,

     

    If your field is assets, then you would add a couple Calculations to your formatctrl as follows:

     

    Add/Update: true

    Calculation:  $temp.assets={};$assets=denull(assets in $file);$assets.lng=lng($assets)

     

    Add/Update:  lng($assets)>0

    Calculation: for $assets.i = 1 to $assets.lng do (if (not null($assets.i in $assets)) then if (index($assets.i in $assets, $temp.assets)=0) then ($temp.assets=insert($temp.assets, 1, 1, $assets.i in $assets)));assets in $file=$temp.assets

     

    If your field name is not assets, then modify as necessary.  I hope this helps.

     

    Audrey

Children