Highlighted
Super Contributor.
Super Contributor.
1606 views

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

Jump to solution

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

 

Good questions will have Good answers
0 Likes
1 Solution

Accepted Solutions
Highlighted
Acclaimed Contributor.
Acclaimed Contributor.

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

Jump to solution

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

View solution in original post

5 Replies
Highlighted
Acclaimed Contributor.
Acclaimed Contributor.

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

Jump to solution

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 

0 Likes
Highlighted
Super Contributor.
Super Contributor.

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

Jump to solution

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

Good questions will have Good answers
0 Likes
Highlighted
Acclaimed Contributor.
Acclaimed Contributor.

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

Jump to solution

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

View solution in original post

Highlighted
Super Contributor.
Super Contributor.

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

Jump to solution

Excellent..¡It works!

Thank you very much Audrey

Good questions will have Good answers
0 Likes
Highlighted
Visitor.

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

Jump to solution

Hi Audrey,

can you please tell me about how remove duplicate elemnts from an array on update?

Regards

Pushkaraj

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.