Rule conditions on lookup dropdown box selected item - InfoPath Dev
in

InfoPath Dev

Rule conditions on lookup dropdown box selected item

Last post 06-27-2016 04:23 AM by lifelong. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 06-22-2016 04:43 AM

    Rule conditions on lookup dropdown box selected item

    Hi there, InfoPath noob here. Can someone help me with this simple question? Sooooo frustrated right now. I would like to configure a rule condition based on a lookup dropdown box's selected item. My dropdown box, let's call it lkpLookup, uses a SharePoint list as its data source. And let's say that the three condition dropdown boxes are called Condition Target, Comparison Operator, and Value To Compare. First, I select the dropdown box "lkpLookup" as the Condition Target. Great. Then I select "is equal to" as the Comparison Operator. Perfect. When I view the options in the Value To Compare dropdown box, I might hope to see either: - the Title properties of items from the SharePoint list referenced by the lkpLookup data source. - an option to "Enter text", where I could enter text to search for a match against list item Title properties. Instead of this, I see "Type a number...", "Select a field or group...", and "Use a formula...". Potential solutions - Would the form work if I was to select "Type a number...", and enter the ID property of the target list item? But why should I have to lookup and hardcode the ID(s) of the list item(s) I'm trying to target? Thankfully, the referenced SharePoint list isn't dynamic, but there must be a solution for dynamic lists where the ID(s) can't be assumed to be static. - If I change the Comparison Operator to "contains", I now get the Value To Compare option to "Type Text...". But my rule doesn't fire. Even though lkpLookup's field property confirms that the "Get information from this column" is looking at the correct column, I have a sneaking feeling the Value To Compare is still being compared with the ID column of the referenced SharePoint list instead . How can I configure the Condition Target to look at the Title property instead of the ID? I feel like I have missed a very simple step. Can anyone help me out and tell me what that is? P.S., My desired action is not to filter another dropdown, i.e. cascading dropdown lists. The action I want to run has nothing intrinsically to do with the queried list item.
  • 06-22-2016 06:05 AM In reply to

    Re: Rule conditions on lookup dropdown box selected item

    UPDATE: In lkpLookup's Entry Value under Control Properties I tried changing the XPath code to reference d:Title instead of d:ID. This now allows the rule to be fired in the appropriate conditions. However, now there is some kind of error with the conditions, there is a red dashed line around the dropdown box control with a ToolTip error "Only positive integers allowed". Googling the error suggests setting the Entry Value back to ID, this could be a step backward. It also suggests making it optional for something to be selected. This is also not the right thing to do, since the error appears when an option is selected. Still need help, please!
  • 06-23-2016 01:59 PM In reply to

    Re: Rule conditions on lookup dropdown box selected item

     I'm guessing this is a SharePoint List form? If so, and this is a lookup type in your list, you need to make sure you use the ID for the value in the drop down - that is what SharePoint expects.

    Is the rule on the lkpLookup field? What is the comparison you are trying to create? You'll probably need to use a formula to return the right ID for the condition ...

    Hilary Stoupa

  • 06-24-2016 10:14 PM In reply to

    Re: Rule conditions on lookup dropdown box selected item

    Yes indeed this is a form for a SharePoint Online list. The lookup dropdown is actually looking at a different list to the rest of the form fields. The rule isn't on the lookup control, it's on a textbox, because that's the control I want the actions to happen on. If formulas are the only way let's go with that, bear in mind I haven't written one before. Would either of these approaches work? 1. The whole list item with all its column values has already been extracted from a SharePoint query and is stored in some object, the column values are properties of that object. Challenges: 1a What is the name of the object where the values are stored? 1b How can I access its properties using an XPath expression? 2. The whole list item has not been extracted from a SharePoint query, therefore I need to write my own query to access the list item columns and aim that at SharePoint Online. Challenges: 2a what does XPath query syntax look like? 2b what structure does SharePoint use to store the list? 2c my SharePoint site isn't public, I'd have to authenticate with SharePoint... in XPath?!? I had a look at the link below, but it didn't seem to offer much help with either of these approaches. Do you know of any more appropriate resources? Cheers https://support.office.com/en-us/article/Add-Formulas-and-Functions-in-InfoPath-2010-a14c7efd-9884-4e09-9435-7e683666e7e5
  • 06-27-2016 04:23 AM In reply to

    Re: Rule conditions on lookup dropdown box selected item

    I managed to fix my own problem, it's a little hacky in that it saves the Title of the lookup dropdown box to a separate hidden textbox, but it works! Here's the solution: (order is important) 1. Create a new data connection called qryMyList and point it at the same list as your lookup field 2. Create a new textbox control called tbxSelectedItemHidden. Use formatting to hide the textbox (white text, remove borders) 3. Create a rule on lkpLookup that sets a field's value. Don't set a condition, with no condition it will run whenever the field changes. In the action, set the ID query field under qryMyList to the value of lkpLookup (lkpLookup's value, as you correctly pointed out, is the ID column of the selected item) 4. Create another rule on lkpLookup that queries qryMyList for data 5. Create another rule on lkpLookup that sets a field's value. Don't set a condition. In the action, set the tbxSelectedItemHidden field. The value will be a formula. Insert a field/group and Show Advanced View. Select the qryMyList data connection and select the Title data field 6. Create rule conditions that reference tbxSelectedItemHidden. Voila! Thanks for your help with this Hilary and sorry if I confused you, I didn't understand how to ask the question correctly at first. If there's any ways you could advise to make the solution more elegant I'm all ears. Cheers
Page 1 of 1 (5 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.