Solved

Duplicate value in listview row

  • 18 January 2016
  • 8 replies
  • 9126 views

Does anyone know how to automatically validate duplicate row entry on a list view based on the first column either during each row entry or on form submit/validate.


Or ignore the duplicate value when list is called?


 


This is wrong:


icon

Best answer by JonathanT 20 January 2016, 19:31

Here's a proof of concept for SmartForms that checks for duplicate entries of a column over all rows:



- You can't normally nest 'For' loops but if you create the inner loop in an unbound rule you can use 'execute another rule' to inject it. 


- Outer loop sets currentString to the current row's value (the title in this case).


- Inner loop checks for a duplicate. There will always be one duplicate per check because the loops are iterating over the same list, so I set dupsFound to -1 and then check if it's '> 0'


- Iterate dupsFound is an expression that just returns 'dupsFound + 1'.
- If 'dupsFound > 0', set valid as false, then display the result in a message.  You can replace the last part with logic that prevents saving and/or warns the user about duplicate entries.


 

View original

8 replies

Userlevel 6
Badge +10

Hi,

 

I guess you can validate this using for each before the editedadded row is submitted,

 

I will try to implement this and let you know

Hi, what I've done about this before is save the row to the DB (luckily there was a sequence I was using which was created before I had to save the data and I saved the data with this sequence ID). When a new row is created and data entered into the text box I do a "get list" on the saved SMO data filtering with the sequence ID and the newly entered data in the text box.

 

If the value is unique I go ahead and close the text box/save the data. If the value is duplicated I have a rule which clears the text box of the duplicate value and the user is unable to save.

 

It would be great if someone had an easier way to do this.

Here's a proof of concept for SmartForms that checks for duplicate entries of a column over all rows:



- You can't normally nest 'For' loops but if you create the inner loop in an unbound rule you can use 'execute another rule' to inject it. 


- Outer loop sets currentString to the current row's value (the title in this case).


- Inner loop checks for a duplicate. There will always be one duplicate per check because the loops are iterating over the same list, so I set dupsFound to -1 and then check if it's '> 0'


- Iterate dupsFound is an expression that just returns 'dupsFound + 1'.
- If 'dupsFound > 0', set valid as false, then display the result in a message.  You can replace the last part with logic that prevents saving and/or warns the user about duplicate entries.


 

Dear Jonathan,

 

I have tried the same in view and form level  both, but its not working.

 

My requirement is user will add items one by one, while submitting all the items , system should vlaidate is any duplicate item codes.

 

Kindly looking for your support..!!

 

Dears,

 

Provide the parametes values mentioned below, its working.

 

Workaround:
Create 3 parameters
current string - text 
dupsFound - number set to -1
valid - bool true

Using an unbound rule as the inner for loop, and calling “then execute another rule” rule as the outer for loop creates the logic necessary to check for duplicates. 
When a duplicate is found dupsFound 1 in a statement, 
If dupsFound >= 1 set valid to false. 

http://community.k2.com/t5/K2-blackpearl/Is-it-possible-to-compare-two-SMOs-Loop-trough-all-items-an...

 

Create some Oubound Rule to Verify and return the result. yes is possible !!!.

 

Then only bad thing is SMO does not have a Loop for each... only a List View.

 

Hope this helps =)

Badge +1
Were you able to do this?
Badge +1
i want to validate before saving.

Reply