in

InfoPath Dev

Check if a drop-down list contains a specific value

Last post 06-26-2008 11:47 AM by Hilary Stoupa. 6 replies.
Page 1 of 1 (7 items)
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 / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 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 / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 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 / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
Page 1 of 1 (7 items)
Copyright © 2003-2007 Qdabra Software. All rights reserved.
View our Terms of Use.