ignore duplicate text when concatenating with double eval - InfoPath Dev
in

InfoPath Dev

ignore duplicate text when concatenating with double eval

Last post 05-14-2014 03:28 PM by sposit. 13 replies.
Page 1 of 1 (14 items)
Sort Posts: Previous Next
  • 12-08-2010 11:14 AM

    • rmsphoto
    • Not Ranked
    • Joined on 04-15-2010
    • Indianapolis
    • Posts 25

    ignore duplicate text when concatenating with double eval

    I have applied learning from the previous post http://www.infopathdev.com/forums/t/16943.aspx to concatenate several fields - works beautifully! But here's my new catch: This function is building a list of email address from various fields - up to 20+ recipients. It is very possible that the user will select the same person for several roles, therefore adding the same email to the string multiple times. Is there a way to prevent/ignore/remove duplicated field data in the final concatenated string? Thanks for any help,
    Filed under: ,
  • 12-13-2010 05:47 AM In reply to

    Re: ignore duplicate text when concatenating with double eval

    Hi RMSPhoto,

    There's no way to filter out duplicates in the double eval. You may be able to filter them out in the form though by creating a separate hidden repeater that you set with the values of the first one. I can't think of how to do this right now, but there may be a way to limit it to unique values using rules. That's all I can think of though.

    Patrick Halstead
    Project Manager at Qdabra
  • 12-13-2010 07:00 AM In reply to

    • rmsphoto
    • Not Ranked
    • Joined on 04-15-2010
    • Indianapolis
    • Posts 25

    Re: ignore duplicate text when concatenating with double eval

    I appreciate your taking the time to think about this, and post a reply. (Luckily, even with the same address listed multiple times, the user only receives a single email. - So it's not a biggie, anyway...) Thanks, again,
  • 12-13-2010 07:47 AM In reply to

    Re: ignore duplicate text when concatenating with double eval

    Could you show us what your formula is right now?  I think I've found a way to accomplish this.

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 12-13-2010 10:02 AM In reply to

    • rmsphoto
    • Not Ranked
    • Joined on 04-15-2010
    • Indianapolis
    • Posts 25

    Re: ignore duplicate text when concatenating with double eval

    Here is the current double eval formula:

    substring(eval(eval((EDG-EEEmail | EDG-MEEmail | EDG-DD1Email | EDG-PlasticsEmail | EDG-EETEmail | EDG-MTEmail | EDG-DD2Email | EDG-TWEmail)[. != ""], 'concat("; ", .)'), ".."), 3, 10000)

    Note: Each of the fields in this formula, may have multiple emails within, separated by "; ". These fields are built by straight rules. This is how the final concat'd string may contain 20+ emails, with possible repeats...

    example:
    1) EDG-EEEmail = [email protected]; [email protected]; [email protected]
    2) EDG-EETmail = [email protected]; [email protected]
    3) [email protected]; [email protected]

    concat'd result = [email protected]; [email protected], [email protected]; [email protected]; [email protected]; [email protected]; [email protected]

    would like it to be instead = [email protected]; [email protected], [email protected]; [email protected]; [email protected]

    Thanks for your help!
  • 12-13-2010 10:38 AM In reply to

    Re: ignore duplicate text when concatenating with double eval

    Please give this a try 

    substring(eval(eval((EDG-EEEmail | EDG-MEEmail | EDG-DD1Email | EDG-PlasticsEmail | EDG-EETEmail | EDG-MTEmail | EDG-DD2Email | EDG-TWEmail)[. != ""][not(. = preceding::*)], 'concat("; ", .)'), ".."), 3, 10000)

    That is, add [not(. = preceding::*)] after [. != ""]

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 12-13-2010 11:18 AM In reply to

    • rmsphoto
    • Not Ranked
    • Joined on 04-15-2010
    • Indianapolis
    • Posts 25

    Re: ignore duplicate text when concatenating with double eval

    Very nice! This works perfectly when each field is identical, but it does not seek and destroy individual duplicate email addresses that are nested among different strings that are concat'd.

    e.g.
    works when field1="[email protected]", and field2 also = "[email protected]"
    result: [email protected]

    but does not work when field1="[email protected]; [email protected]", and field2="[email protected]; [email protected]"
    result:[email protected]; [email protected]; [email protected]; [email protected] (i.e. "[email protected]" is still duplicated)

    I think my request may not quite be feasible in a codeless world... Still - a very nice addition to the formula, that I will implement.

    Thanks,
  • 12-13-2010 07:48 PM In reply to

    Re: ignore duplicate text when concatenating with double eval

    Yes, I don't think it's going to be possible to come up with an expression to filter out duplicates from within the individual strings.

     How are the sub-lists getting formed?  Are you using a separate double-eval for each of those?  If so, it's probably possible to formulate the main double-eval to concatenate all of the e-mails without first assembling them into sub-lists.  That would probably succeed in excluding all the duplicates.

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 12-14-2010 06:34 AM In reply to

    • rmsphoto
    • Not Ranked
    • Joined on 04-15-2010
    • Indianapolis
    • Posts 25

    Re: ignore duplicate text when concatenating with double eval

    The sub-lists are formed in 9 different fields (representing work disciplines). The user selects from a "people picker", or from a fixed list for each discipline; and the same personnel may be selected for multiple disciplines. Each of the nine sub-lists is built from using rules. So I don't think the double eval would work for those sub-lists...

    Again, I really appreciate your taking the time to help!
  • 05-01-2014 10:58 AM In reply to

    • sposit
    • Not Ranked
    • Joined on 05-01-2014
    • Posts 4

    Re: ignore duplicate text when concatenating with double eval

     Jimmy, can you revisit this with a bit simpler example please? I don't have the nested repeating fields, but still want to remove any duplicates. My aggregate formula looks like this:

    substring((eval(eval(FieldName, 'concat(., "; ")'), "..")), 0, (string-length(eval(eval(FieldName, 'concat(., "; ")'), "..")) - 1)) 

     

     (The substring is merely to remove the final semicolon.)

     

    Thanks in advance!

     Tyler 

  • 05-07-2014 01:01 PM In reply to

    • sposit
    • Not Ranked
    • Joined on 05-01-2014
    • Posts 4

    Re: ignore duplicate text when concatenating with double eval

    So I tried this: substring((eval(eval(FieldName[not(. = preceding::*)], 'concat(., "; ")'), "..")), 0, (string-length(eval(eval(FieldName, 'concat(., "; ")'), "..")) - 1))

     enabled form ... is this formulation not allowed in browser forms?

     Thanks,

     Tyler 

  • 05-13-2014 09:21 AM In reply to

    • sposit
    • Not Ranked
    • Joined on 05-01-2014
    • Posts 4

    Re: ignore duplicate text when concatenating with double eval

    Correction: I can't seem to publish a web form with the formula above -- when publishing, I get an error that the form can only be published as a Filler form. Is this kind of formula not compatible with web forms? (This is in SharePoint Online, fwiw.) Thanks for any help you can provide.

  • 05-13-2014 09:29 AM In reply to

    Re: ignore duplicate text when concatenating with double eval

    Double eval is compatible with browser forms. What does the design checker say the issue is?

    Hilary Stoupa

  • 05-14-2014 03:28 PM In reply to

    • sposit
    • Not Ranked
    • Joined on 05-01-2014
    • Posts 4

    Re: ignore duplicate text when concatenating with double eval

    Double eval doesn't seem to be the issue -- it's the addition of the [not(. = preceding::*)]. The Design Checker doesn't actually say much of anything -- it only includes a couple items: 1) Data connections contain parameterized queries and 2) Could not verify the form template on the specified server. Strangely, when I revert back to the old version of the equation, the Design Checker then populates with a whole bunch of (mostly cosmetic) issues. The checker apparently can't even review the form template (error #2) while the updated equation is in place.

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