Comparison of two values case insensitive - InfoPath Dev
in

InfoPath Dev

Comparison of two values case insensitive

Last post 10-27-2017 06:27 AM by malkovich. 9 replies.
Page 1 of 1 (10 items)
Sort Posts: Previous Next
  • 10-25-2017 07:51 AM

    Comparison of two values case insensitive

    Hello,

    My request is simple. In a form, I would like to compare if the value of a field already exists in a sharepoint list.

    I've created a data connection (with a sharepoint list) that I can use for some treatment. For a field, I made a validation rule which compares his value with the values of the existing sharepoint list.

    The rule is : if SiteName is equal to ListSiteNames -> display of a message Error! . But this rule is only case sensitive (if "Utaka" is equal to "Utaka -> Error! )

    For the moment, the rule (if "utaka" is equal to "Utaka") is not an error, but I would like that it's an error.

    I've created another condition : if the expression "msxsl:string-compare(.,xdXDocument:GetDOM("CNSS")/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW/ListSiteNames, "", "i") = 0"

    This condition works but compares only with the first element of the list, I can compare with the thirth element if I want when changing with SharePointListItem_RW[3] but never with the whole list.

    I call on your expertise to help me.

    Thanks in advance.

  • 10-25-2017 11:19 AM In reply to

    Re: Comparison of two values case insensitive

     I wonder if you move that filter - something like this:

    xdXDocument:GetDOM("CNSS")/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW[msxsl:string-compare(current(),ListSiteNames, "", "i") = 0] 

    Hilary Stoupa

  • 10-26-2017 02:31 AM In reply to

    Re: Comparison of two values case insensitive

     Hi Hilary,

    Thank you for answering.

    When I replace the expression in the rule by  "xdXDocument:GetDOM("CNSS")/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW[msxsl:string-compare(current(),ListSiteNames, "", "i") = 0] ", it doens't work.

    Best regards.

  • 10-26-2017 07:35 AM In reply to

    Re: Comparison of two values case insensitive

    I'll try it on a test form, see what I've got wrong there. When you say "it doesn't work" - do you just mean the formatting doesn't hide things as expected?
    Hilary Stoupa

  • 10-26-2017 07:48 AM In reply to

    Re: Comparison of two values case insensitive

     The expression is accepted but the condition is not fulfilled, and the error is not indicated.

  • 10-26-2017 07:52 AM In reply to

    Yup, I see the issue - see the attached sample form. Save it locally, right click and select design and you can see in the validation on field1, I'm using a count of matches. The XPath I gave you returns a value from a field if it matches, so instead of true / false, you'd be getting the value of the field. I added a calc'd value to my form to help me debug the formula. I left it there so you could also see that technique (I hate working in the dark, you know?)
    Hilary Stoupa

  • 10-26-2017 12:10 PM In reply to

    Re: Comparison of two values case insensitive

    You are great! It works! Many many thanks.
  • 10-26-2017 12:51 PM In reply to

    Re: Comparison of two values case insensitive

    In InfoPath Filler, this expression works -> count(xdXDocument:GetDOM("CNSS")/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW/d:ListSiteNames[msxsl:string-compare(current(), ., "", "i") = 0]) > 0 but when I publish, I've got an error : "an invalid expression has been detected : msxsl:string-compare(current(), ., "", "i") = 0"
  • 10-26-2017 03:42 PM In reply to

    Re: Comparison of two values case insensitive

    Oh, will this be used in the browser? You'll have to use translate instead (sorry, it's icky): count(xdXDocument:GetDOM("CNSS")/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW/d:ListSiteNames[translate(current(),'ABCDEFHIJKLMNOPQRSTUVWXYZ', 'abcdefhijklmnopqrstuvwxyz') = translate(.,'ABCDEFHIJKLMNOPQRSTUVWXYZ', 'abcdefhijklmnopqrstuvwxyz')]) > 0
    Hilary Stoupa

  • 10-27-2017 06:27 AM In reply to

    Re: Comparison of two values case insensitive

     It's just perfect! Thank you for your help.

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