Validation on a list checking for duplicates - using preceding and following sibling - and translate. - InfoPath Dev
in

InfoPath Dev

Validation on a list checking for duplicates - using preceding and following sibling - and translate.

Last post 09-09-2011 09:32 AM by Catharine. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 09-08-2011 06:53 AM

    Validation on a list checking for duplicates - using preceding and following sibling - and translate.

    Hi,

    I am using InfoPath 2007.

    I have a form with a repleating field.  I have set up some validation to check for duplicates in the list. The field is called Aliases and the validation is...

    . = preceding-sibling::my:Aliases

    and

    . = following-sibling::my:Aliases

    This works brilliantly - thank you for previous blogs and posts which helped me get that right. 

    I am shredding the data to SQL where it is part of a primary key.  In SQL a value "xyz"  is considered the same as "XYZ" so I need to do something to prevent those "duplicate" values.

    So I have added the following  validation

     translate(., "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "abcdefghijklmopqrstuvwxyz") = translate(preceding-sibling::my:Aliases, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "abcdefghijklmopqrstuvwxyz")

    and 

    translate(., "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "abcdefghijklmopqrstuvwxyz") = translate(following-sibling::my:Aliases, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "abcdefghijklmopqrstuvwxyz")

    I thought this would do the trick, but this does not fire when values xyz and XYZ are put in the field. 

    Is this the correct thing to be doing?  Is there another way to achieve it.  Or do I have to move to code ? :(

    Thank you

    Catharine

     

    Filed under: ,
  • 09-09-2011 07:40 AM In reply to

    Re: Validation on a list checking for duplicates - using preceding and following sibling - and translate.

    The problem here is that translate() will only be applied to the first preceding or following sibling, and the validation would only work if the duplicates were right next to each other.

    You can use eval() to apply a function across all nodes in a set, and it should work here.  Please try this:

    translate(., "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "abcdefghijklmnopqrstuvwxyz") = xdMath:Eval(preceding-sibling::my:Aliases | following-sibling::my:Aliases, "translate(., 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')")

    Note that having the preceding-sibling::my:Aliases | following-sibling::my:Aliases like that allows you to combine this into one expression.

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 09-09-2011 09:32 AM In reply to

    Re: Validation on a list checking for duplicates - using preceding and following sibling - and translate.

    That is brilliant THANK YOU. 

    This works a treat. 

    Have a great weekend

    Catharine

Page 1 of 1 (3 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.