Check if a drop-down list contains a specific value - InfoPath Dev
in

InfoPath Dev

Check if a drop-down list contains a specific value

Last post 03-31-2017 07:37 AM by Hilary Stoupa. 17 replies.
Page 1 of 2 (18 items) 1 2 Next >
Sort Posts: Previous Next
  • 06-25-2008 01:45 PM

    Check if a drop-down list contains a specific value

    Hi,

    I have a section in a form which I want to make visible if the current user's id is included as one of the values in a drop-down list box on the form, if the user is not included in the drop-down list I want the section to be invisible.  I have tried doing this using conditional formatting but it only works if I select the user id from the drop-down list.  Any help or assistance is greatly appreciated.

    Filed under:
  • 06-25-2008 02:22 PM In reply to

    Re: Check if a drop-down list contains a specific value

    Hello:

    Did you enter your drop down list values manually? Or are they coming from a data connection? If they are coming from a data connection, you can try the following with condiitional formatting:

      1. Add a new condition
      2. In the first drop down, select the group that contains your drop down list information
      3. In the second drop down, select is equal to
      4. In the third drop down, select the field that has the current user's id
      5. Now, go back to the first drop down, and change your selection to "The expression"
      6. You will see something like this now in the expression area: my:group1/my:field2 != my:field3 (this will vary depending on your form's schema, the data connection for the drop down list, etc)
      7. Modify the expression to look like this: my:group1[my:field2 != my:field3] so that you are filtering for field3 not being equal to field2
      8. Select the conditional formatting you want

    Let me know if you need further clarification or have any troubles with this.

    Hilary Stoupa

  • 06-26-2008 07:59 AM In reply to

    Re: Check if a drop-down list contains a specific value

    Hi there

    I did as you suggested but unfortunately it did not work for me.  The expression I ended up with was my:gpApprover[my:ddlApproverUserIdList = my:tbCurrentUser] 

    I can get the conditional fomatting to work if I manually select the User Id from the drop-down list but what I really want is to be able to check that the drop-down list contains the user id of the current user and if so then hide a section on the form.  It almost seems that I need to do some code behind on the bind event of the drop-down list which I am not sure can be done in InfoPath 2007 or is browser-only compatible.

    I would appreciate any other suggestions.

    Patrick

  • 06-26-2008 09:25 AM In reply to

    Re: Check if a drop-down list contains a specific value

    Could you post screen shots for me of your data source task pane to show me your schema? I do understand what you are trying to do, and was successful in the test form I used prior to responding to your first post. For my form, there is a secondary data source providing the options in the drop down list -- are your options coming from your main data source? I think you may be able to do this with conditional formatting, but we need to make sure the filter on that condition is right...

    Hilary Stoupa

  • 06-26-2008 11:07 AM In reply to

    Re: Check if a drop-down list contains a specific value

    Hi,

    Can you please tell me how to paste a screen shot into this forum? It doesn't seem obvious to me.

    My options for the secondary data source come from an external source, a SharePoint list.  As an alternative I have also been trying to query the secondary data source to see if it contains the user id of the current user and then apply conditional formatting on the result of that query.

    Patrick 

     

  • 06-26-2008 11:35 AM In reply to

    Re: Check if a drop-down list contains a specific value

    Hi Hilary

    I may have solved the problem by querying the secondary data source directly and applying the conditional formatting based on the result.  The query which appears to be working is

    not(xdXDocument:GetDOM("ETL Deployment Approvers")/dfs:myFields/dfs:dataFields/dfs:ETL_Deployment_Approvers/@Net_Id[. = xdUser:get-UserName()])

    Thanks for all your help.

     Patrick

     

  • 06-26-2008 11:47 AM In reply to

    Re: Check if a drop-down list contains a specific value

    Beautiful! Glad you got it!

    Hilary Stoupa

  • 08-11-2009 12:57 PM In reply to

    • lanita
    • Not Ranked
    • Joined on 07-21-2009
    • Posts 7

    Re: Check if a drop-down list contains a specific value

    I'm doing a check to see if the current user is in the drop-down (from secondary data source)  and switch to a different view if he is. So, instead of doing conditional formatting I'm adding a rule in the form options.

    I followed the steps that you provided but it didn't work for me.

    Any help would be apprecatied

  • 08-11-2009 01:07 PM In reply to

    Re: Check if a drop-down list contains a specific value

    Hi:

    So what you are doing is checking to see if a user is in a particular field from a secondary data source, and if so, changing a view? What does your rule look like and what is it set on?

    Hilary Stoupa

  • 08-11-2009 01:37 PM In reply to

    • lanita
    • Not Ranked
    • Joined on 07-21-2009
    • Posts 7

    Re: Check if a drop-down list contains a specific value

    Yes. But I also tried to query directly the data source.

     The rule is set under Tools-> Form Options -> Open and Save -> Rules.

    And here is the codition for the rule:

    xdXDocument:GetDOM("Documentum")/dfs:myFields/dfs:dataFields/tns:GetUserCollectionFromGroupResponse/tns:GetUserCollectionFromGroupResult/tns:GetUserCollectionFromGroup/tns:User/@LoginName[. = concat("CORP\", xdUser:get-UserName())]

     There is no option to set a filter on a data source when you set a condition in the first drop down and choose Select field or Group, so I did it manually in the expression.

    And the rule is "switch data source" .

  • 08-11-2009 01:59 PM In reply to

    • lanita
    • Not Ranked
    • Joined on 07-21-2009
    • Posts 7

    Re: Check if a drop-down list contains a specific value

    Here is how my data structure looks like:

    -myFields

      -queryFileds

          -tns:GetUserCollectionFromGroup

               -Users

                   -User (this is a repeating group)

                          :Notes

                           :Name

                           :IsSiteAdmin

                           :Sid

                           :ID

                            :LoginName

                            :Email

                            :IsDomainGroup

    -dataFields

       -tsn:GetUserCollectionFromGroupResponse

             -GetUserCollectionFromGroupResult

                 -GetUserCollectionFromGroup

                   -Users

                      -User (this is a repeating group)

                          :Notes

                           :Name

                           :IsSiteAdmin

                           :Sid

                           :ID

                            :LoginName

                            :Email

                            :IsDomainGroup

  • 08-13-2009 05:21 PM In reply to

    Re: Check if a drop-down list contains a specific value

    this should be pretty simple.  Check out my blog post on User Roles in browser forms (I have 2 separate ones, but the concept is the same for hiding sections) and pay close attention to Figure 8:

    InfoPath - User Roles in Browser-Enabled Forms Using AD Groups

    "If All Occurrences of UserID are not equal to DropDownSelection, then Hide Section"

  • 08-14-2009 09:10 PM In reply to

    • lanita
    • Not Ranked
    • Joined on 07-21-2009
    • Posts 7

    Re: Check if a drop-down list contains a specific value

    Thanks for your solution. I got it working now. In my case I needed "If Any Occurrences of drop down are equal to Current User then switch the view".

  • 08-15-2013 11:39 AM In reply to

    Re: Check if a drop-down list contains a specific value

    Hi, Im having the same issue and tried to use your instructions but I had a question: Where do I enter the condition I am supposed to create?
  • 08-18-2013 04:37 PM In reply to

    Re: Check if a drop-down list contains a specific value

    Please go to Clay's SharePoint Madness blog site and post your comment there.

    Patrick Halstead
    Project Manager at Qdabra
Page 1 of 2 (18 items) 1 2 Next >
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.