Filtering Secondary data source based on Field value in a Repeating Section - with a twist in the tail! - InfoPath Dev Sign in | Join | Help in Browser Forms InfoPath (Entire Site) InfoPath Dev InfoPath Dev is dedicated to bringing you the information and tools you need to be successful in your Microsoft Office InfoPath development projects. Home Blogs Forums Photos Downloads InfoPath Dev » InfoPath » Browser Forms » Filtering Secondary data source based on Field value in a Repeating Section - with a twist in the tail! Filtering Secondary data source based on Field value in a Repeating Section - with a twist in the tail! Last post 04-06-2018 06:01 AM by merley72. 16 replies. Page 1 of 2 (17 items) 1 2 Next > Sort Posts: Oldest to newest Newest to oldest Previous Next 03-18-2018 01:30 PM merley72 Joined on 05-14-2007 Posts 41 Filtering Secondary data source based on Field value in a Repeating Section - with a twist in the tail! Reply Contact Hello, I hope someone can aid me in this process around filtered secondary data sources.I have a form which has a Repeating section in it which hold details about how a specific Business Action will be dealt with. It is necessary to create multiple instances of the section to divide responsibility and break the job into manageable chunks. The Repeating Section has a couple of drop-down fields, a couple of text fields and some other stuff, PLUS a filtered secondary data source in this repeating section.What I want to achieve is for the filtered secondary data source to display an image which relates to a 'Banding Level' drop-down field chosen in each Repeating section. So behind the scenes the images are held in a SharePoint List (called the Keywords List) and each record has a 'Title' field and a Rich Text Field which is called 'BandingImage'. Information from this Keywords List is the secondary data source we wish to filter and display. Although currently there many different images records, for this example we can say there are 3 records - Title of the 1st record is 'First Level', the 2nd is 'Second Level' and the 3rd is 'Third Level' - as I mention each document has a different image in their Rich text field. So a user creates the blank document, and completes it with an option to use the 'Banding Level' field - let's say they choose the drop-down choice entitled 'Second Level'. What I want to happen is when the user chooses 'Level 2 in the drop-down, the image refreshes and displays the value from the 'Second Level' record. Simple you might say, but please read on. At this point everything is relatively easy to set up and I have this aspect of things working with no problem. I dragged the complete set of Secondary data source fields across on to the design of the form from the data fields list, removed the fields I didn't want to see and laid things out as I wanted, Then I added the following hide-when filter on the Group of the secondary data source on the design form:- 'Title' : is not equal to: 'BandingLevel' - (then hide everything not fitting this criteria). (Note, Title is the field in the secondary data source, and 'Banding Level' is the name of the field on the form we want to compare it to - it is in the 'Main' data source). I've saved the form, Previewed it, Published it and opened it correctly (from the web) and up to this point everything works fine for the FIRST Repeating table, and the filtered connection nicely displays the image & text as required. HOWEVER if the user creates a SECOND Repeating section, and goes through all the above steps but this time chooses ‘Third Level’, it blows up and displays nothing either in the first repeating section or the second section. But if both banding levels are set with the same choice (regardless of what is selected i.e. Level 1, 2 or 3) then the images display correctly. To advise, I have looked hard at the principle of using a modified version of the filtering using - current()/../my:BandingLevel - as I believe if I just use 'BandingLevel' as a generic field, it will seek the first one from the Repeating Section, and won't identify the value of the field in that specific Repeating Section. However the 'current()' approach doesn't want to play either and it still fails. Can anyone suggest where I am going wrong please? I'm happy to answer any questions and share a cut-down version of the form if that helps. Thanks very much in advance. Alan C. Filed under: browser enabled forms, repeating section, rich text, data connections 03-23-2018 08:16 AM In reply to Hilary Stoupa Joined on 06-20-2008 Posts 13,297 Re: Filtering Secondary data source based on Field value in a Repeating Section - with a twist in the tail! Mark as Not AnswerMark as Answer... Reply Contact Sorry I am slow in replying to this - can you attach a copy of your form under the options tab if you still need help? Hilary Stoupa 03-23-2018 09:05 AM In reply to merley72 Joined on 05-14-2007 Posts 41 Re: Filtering Secondary data source based on Field value in a Repeating Section - with a twist in the tail! SecondaryExample.xsn Mark as Not AnswerMark as Answer... Reply Contact HI Hilary, and thanks very much for coming back to me, I am still having a problem, but have realised I've over-complicated aspects of the question, have actually got half of the thing working, and really am now stuck on just one aspect. It boils down to can you use a 'Set a field's value' Action in a Rule to take the value of an image (held in my situation in a RTF of a Keyword document in a List which I access through the Secondary data source), and get that displayed in a Rich Text field on my document? I think the answer is 'No' using the OOB rules in InfoPath. I've got text values (and numbers) being pulled back from the secondary source data connection OK, and those are fine for each of the repeating sections. But images just don't want to play by the same method. Is this correct? Thanks a lot, Alan C.(If pulling an image into a field is possible using rules I'll do that please!.) EDITED - below Please find attached a reworked version of the form which I've prepared to show the problem as it presents. Your help is appreciated. Alan C. 03-26-2018 07:58 AM In reply to Hilary Stoupa Joined on 06-20-2008 Posts 13,297 Re: Filtering Secondary data source based on Field value in a Repeating Section - with a twist in the tail! Mark as Not AnswerMark as Answer... Reply Contact Yeah, copying rich text via rules isn't supported OOB. And the issue with the filter on your repeating section is that it will always reference the first instance of the repeating main data source group. I'm not sure if there is a way around that - we often use show / hide in these cases and just query for the data we need, but doesn't sound like it would work here, since you are using "contains". What version of SharePoint is this? I'll try to set up a little repro today or tomorrow & see if I can find a work around. Hilary Stoupa 03-26-2018 09:07 AM In reply to merley72 Joined on 05-14-2007 Posts 41 Re: Filtering Secondary data source based on Field value in a Repeating Section - with a twist in the tail! Mark as Not AnswerMark as Answer... Reply Contact Hi Hilary, thanks for the response. I did go a bit mad at first when I was trying to work out what was and wasn't possible regarding the copying of rich text via rules. A text element in an RTF seems to come across OK, but looses all the formatting, but if there is an image involved then simply nothing happens. Of course that is the worst because you think you've got something wrong in your code which might not be the case - whereas it would never copy anyway!As to the filtering of the secondary data source, I used 'contains' but I could use 'is equal to' instead if you think that might make a difference. In terms of the version, this is currently 2010 but it could be switched to 2013 again if that might make a difference. The initial end user of this system will be a customer on Office 365 so if there is a way of making it work in 2013 I'll adopt that.Something I was wondering about was if I could use a picture button to display the image? The button side of things would do nothing of course but if I could get the picture to be option dependent I was wondering if that might work. I've not played with those at all so any experience you can offer around that as a possible method would be appreciated - as always! Thanks again. Alan C. 03-27-2018 02:38 PM In reply to Hilary Stoupa Joined on 06-20-2008 Posts 13,297 Re: Filtering Secondary data source based on Field value in a Repeating Section - with a twist in the tail! Mark as Not AnswerMark as Answer... Reply Contact You can't use a field for the picture on a button. I tried setting up a repro with a list on my Office 365 site, but the picture isn't displayed at all in my form in preview in the secondary data connection. Does yours display in preview, or do you have to publish and view in the browser? Hilary Stoupa 03-28-2018 01:17 AM In reply to merley72 Joined on 05-14-2007 Posts 41 Re: Filtering Secondary data source based on Field value in a Repeating Section - with a twist in the tail! Mark as Not AnswerMark as Answer... Reply Contact Hi and thanks for trying things. Basically my images will display in preview and when published. The problem as I understand it is that InfoPath can't use the Rules logic to pull back just a specific image (basically copy it out of one field and into another), so filtering is the only option left. However when filtering you need to have both the object and the filter mechanism already in the secondary data source and of course in this situation we don't.If picture buttons can't be set using a derived value from a field, then that blows that idea. I did attempt something though with unfortunately again no success but I'd like your thoughts on that. Basically I used a button and tried to seed the secondary data source with a value, then doing the query data connection (which is parameterized) and stopping at that. My thinking was because I've done the query with the secondary data source that should rebuild the items being displayed in the section. As this is a very busy form I already have the fields, images and other stuffed in a series of hide-when sections which I show & hide using clickable tabs (buttons) which only display when pressed (and set a hidden 'DisplayTab' field) so I shoved the setting and query data connection into that. Clicking the button (setting the show section option) worked OK, and I proved I'd set the parameter, but it didn't work - but it might just have been my bits were not correctly set. Any thoughts on using that as a method? I'm probably going to give up on this pretty soon as it is taking far too much time - yours and mine - but I'll plod on a bit today with it just in the hope. Thanks again and regards, Alan C. 03-28-2018 09:22 AM In reply to Hilary Stoupa Joined on 06-20-2008 Posts 13,297 Re: Filtering Secondary data source based on Field value in a Repeating Section - with a twist in the tail! Mark as Not AnswerMark as Answer... Reply Contact Actually, show / hide is how we usually handle something like this, where we have a repeating section bound to a different data source inside the main ds. Attach your form with this attempt under the options tab & I'll take a look. Hilary Stoupa 04-03-2018 02:51 AM In reply to merley72 Joined on 05-14-2007 Posts 41 Re: Filtering Secondary data source based on Field value in a Repeating Section - with a twist in the tail! SecondaryExample.xsn Mark as Not AnswerMark as Answer... Reply Contact Hi Hilary, thanks for following up and apologies for the delay in responding. I've attached a new form I created with the same problem as the original form is very complicated, has loads of different Views etc and is a bit messy so I've recreated the problem in this one. I've explained the problem as I see it on the top part of the design form. Thanks in advance. Alan C. 04-04-2018 02:06 PM In reply to Hilary Stoupa Joined on 06-20-2008 Posts 13,297 Re: Filtering Secondary data source based on Field value in a Repeating Section - with a twist in the tail! Mark as Not AnswerMark as Answer... Reply Contact So - in your prior post you talked about just querying for the data you need to show via query fields and show / hide buttons. I don't see that in this sample. What field in the main data source has a value we could use to query back just the data you need from the secondary data source for a given main data source section? Hilary Stoupa 04-05-2018 02:02 AM In reply to merley72 Joined on 05-14-2007 Posts 41 Re: Filtering Secondary data source based on Field value in a Repeating Section - with a twist in the tail! Mark as Not AnswerMark as Answer... Reply Contact To the end user, the image displayed in the Icon field should be that which is associated with the number in the OverallLevel field. As it is not possible to copy & paste images etc using rules, the only way to display just the correct Icon image is by using a filter on the 'Keywords' secondary data source. If you look at the Rules associated with the Icon section on the design form, you can see it does two 'checks…', the second check filters out everything except where the value of the OverallLevel field is the same as the value held in a field called Text03 in the secondary data source. It is that rule which I believe doesn’t correctly reflect things. The problem comes because if you look at the main data source, you will see that most fields (including OverallNumber) are in a repeating section (called group2) which is needed to repeat the multi-levelled approach required for this aspect of the form. All is OK when there is only the original repeating section, but when a user creates a second / third repeating section, the form only ever displays the image in the Icon field related to the number in the original OverallLevel section. In comparison, the Guidance field is a field which pulls back text using Rules from the same 'Keywords' secondary data source - see the second Rule linked to the OverallNumber field. Here there is no problem with the repeating section as the values of each Guidance field sets correctly from the value in the OverallNumber (and OverallLevel). So I'm getting the Rules correct for Guidance, but wrong when filtering the Icon field. Thanks very much for staying with me over this. Alan C. 04-05-2018 07:56 AM In reply to Hilary Stoupa Joined on 06-20-2008 Posts 13,297 Re: Filtering Secondary data source based on Field value in a Repeating Section - with a twist in the tail! Mark as Not AnswerMark as Answer... Reply Contact Thank you for the additional explanation - I understand the issue and I also understand why conditional formatting doesn't work here (it is because you have a repeating section bound to different data source inside another repeating section - so "current()" won't work for us to get the parent repeating section values). What I am still asking about was an earlier statement you made that you were trying to use query fields to get back just the data for a specific section, using show / hide for the query. I don't see anything like that in this latest sample template. Is there a specific value in the parent repeating section that could be used for an equivalence query to get back just the images for this specific section? Hilary Stoupa 04-05-2018 10:14 AM In reply to merley72 Joined on 05-14-2007 Posts 41 Re: Filtering Secondary data source based on Field value in a Repeating Section - with a twist in the tail! Mark as Not AnswerMark as Answer... Reply Contact Hi Hilary, and sorry for not explaining about the show/hide side of things. Basically the current form I attached doesn’t have any of that in it as I tested things and it just wouldn’t work so I pulled that out of the template. To a certain extent I'm floundering at the edge of my capabilities with repeating fields (beyond!) and attempting anything which will only display the Icon Image relevant to the selected OverallNumber value.To try and answer your last question - "Is there a specific value in the parent repeating section that could be used for an equivalence query to get back just the images for this specific section" - when a user chooses the relevant options from the drop-downs and the values get set in the 'OverallNumber' and 'OverallLevel' fields, both are unique within that repeating section. The next repeating section could have different choices, and therefore different values in the Number and Level fields. So for each instance of a repeating section (which in my form is grouped under Group2) the unique value would be held in that section's 'OverallLevel' field. I'm not trying to be thick, but does that answer your question?Regards, Alan C. 04-05-2018 10:21 AM In reply to Hilary Stoupa Joined on 06-20-2008 Posts 13,297 Re: Filtering Secondary data source based on Field value in a Repeating Section - with a twist in the tail! Mark as Not AnswerMark as Answer... Reply Contact In your list with images, what is the field that relates back to the user's selections? Right now you are trying to compare on a multiline text field with contains. Could there instead be a regular text field in the list that exactly matched something selected in the repeating section so that we could use query fields to get back just the rows that match? Hilary Stoupa 04-05-2018 10:40 AM In reply to merley72 Joined on 05-14-2007 Posts 41 Re: Filtering Secondary data source based on Field value in a Repeating Section - with a twist in the tail! Mark as Not AnswerMark as Answer... Reply Contact Hi, I'm using two elements to filter the 'Keywords' secondary data source. The first is if a field named 'Field' has an entry called 'Matrix', the second is if the value in the OverallLevel contains the value in the Text03 field which as you correctly say is a multi-line XHTML field. That field (Text03 ) is only used in a couple of places, and not for anything fancy so I could convert it to a straight text field and then use an 'equals' instead of 'contains'. Is that likely to work? If it is I shall be very happy but very cross at the same time!!! Regards Alan C. Page 1 of 2 (17 items) 1 2 Next > Copyright © 2003-2019 Qdabra Software. All rights reserved.View our Terms of Use.
Hello, I hope someone can aid me in this process around filtered secondary data sources.
I have a form which has a Repeating section in it which hold details about how a specific Business Action will be dealt with. It is necessary to create multiple instances of the section to divide responsibility and break the job into manageable chunks. The Repeating Section has a couple of drop-down fields, a couple of text fields and some other stuff, PLUS a filtered secondary data source in this repeating section.
What I want to achieve is for the filtered secondary data source to display an image which relates to a 'Banding Level' drop-down field chosen in each Repeating section. So behind the scenes the images are held in a SharePoint List (called the Keywords List) and each record has a 'Title' field and a Rich Text Field which is called 'BandingImage'. Information from this Keywords List is the secondary data source we wish to filter and display. Although currently there many different images records, for this example we can say there are 3 records - Title of the 1st record is 'First Level', the 2nd is 'Second Level' and the 3rd is 'Third Level' - as I mention each document has a different image in their Rich text field.
To advise, I have looked hard at the principle of using a modified version of the filtering using - current()/../my:BandingLevel - as I believe if I just use 'BandingLevel' as a generic field, it will seek the first one from the Repeating Section, and won't identify the value of the field in that specific Repeating Section. However the 'current()' approach doesn't want to play either and it still fails.
Can anyone suggest where I am going wrong please? I'm happy to answer any questions and share a cut-down version of the form if that helps.
Thanks very much in advance. Alan C.
HI Hilary, and thanks very much for coming back to me, I am still having a problem, but have realised I've over-complicated aspects of the question, have actually got half of the thing working, and really am now stuck on just one aspect.
It boils down to can you use a 'Set a field's value' Action in a Rule to take the value of an image (held in my situation in a RTF of a Keyword document in a List which I access through the Secondary data source), and get that displayed in a Rich Text field on my document? I think the answer is 'No' using the OOB rules in InfoPath. I've got text values (and numbers) being pulled back from the secondary source data connection OK, and those are fine for each of the repeating sections. But images just don't want to play by the same method.
Is this correct? Thanks a lot, Alan C.
(If pulling an image into a field is possible using rules I'll do that please!.)
EDITED - below
Please find attached a reworked version of the form which I've prepared to show the problem as it presents. Your help is appreciated. Alan C.
Hi Hilary, thanks for the response. I did go a bit mad at first when I was trying to work out what was and wasn't possible regarding the copying of rich text via rules. A text element in an RTF seems to come across OK, but looses all the formatting, but if there is an image involved then simply nothing happens. Of course that is the worst because you think you've got something wrong in your code which might not be the case - whereas it would never copy anyway!
As to the filtering of the secondary data source, I used 'contains' but I could use 'is equal to' instead if you think that might make a difference. In terms of the version, this is currently 2010 but it could be switched to 2013 again if that might make a difference. The initial end user of this system will be a customer on Office 365 so if there is a way of making it work in 2013 I'll adopt that.
Something I was wondering about was if I could use a picture button to display the image? The button side of things would do nothing of course but if I could get the picture to be option dependent I was wondering if that might work. I've not played with those at all so any experience you can offer around that as a possible method would be appreciated - as always!
Thanks again. Alan C.
Hi and thanks for trying things. Basically my images will display in preview and when published. The problem as I understand it is that InfoPath can't use the Rules logic to pull back just a specific image (basically copy it out of one field and into another), so filtering is the only option left. However when filtering you need to have both the object and the filter mechanism already in the secondary data source and of course in this situation we don't.
If picture buttons can't be set using a derived value from a field, then that blows that idea.
I did attempt something though with unfortunately again no success but I'd like your thoughts on that. Basically I used a button and tried to seed the secondary data source with a value, then doing the query data connection (which is parameterized) and stopping at that. My thinking was because I've done the query with the secondary data source that should rebuild the items being displayed in the section. As this is a very busy form I already have the fields, images and other stuffed in a series of hide-when sections which I show & hide using clickable tabs (buttons) which only display when pressed (and set a hidden 'DisplayTab' field) so I shoved the setting and query data connection into that. Clicking the button (setting the show section option) worked OK, and I proved I'd set the parameter, but it didn't work - but it might just have been my bits were not correctly set. Any thoughts on using that as a method?
I'm probably going to give up on this pretty soon as it is taking far too much time - yours and mine - but I'll plod on a bit today with it just in the hope.
Thanks again and regards, Alan C.
Hi Hilary, thanks for following up and apologies for the delay in responding. I've attached a new form I created with the same problem as the original form is very complicated, has loads of different Views etc and is a bit messy so I've recreated the problem in this one.
I've explained the problem as I see it on the top part of the design form.
Thanks in advance. Alan C.
To the end user, the image displayed in the Icon field should be that which is associated with the number in the OverallLevel field.
Hi Hilary, and sorry for not explaining about the show/hide side of things. Basically the current form I attached doesn’t have any of that in it as I tested things and it just wouldn’t work so I pulled that out of the template. To a certain extent I'm floundering at the edge of my capabilities with repeating fields (beyond!) and attempting anything which will only display the Icon Image relevant to the selected OverallNumber value.
To try and answer your last question - "Is there a specific value in the parent repeating section that could be used for an equivalence query to get back just the images for this specific section" - when a user chooses the relevant options from the drop-downs and the values get set in the 'OverallNumber' and 'OverallLevel' fields, both are unique within that repeating section. The next repeating section could have different choices, and therefore different values in the Number and Level fields. So for each instance of a repeating section (which in my form is grouped under Group2) the unique value would be held in that section's 'OverallLevel' field. I'm not trying to be thick, but does that answer your question?
Regards, Alan C.
Hi, I'm using two elements to filter the 'Keywords' secondary data source. The first is if a field named 'Field' has an entry called 'Matrix', the second is if the value in the OverallLevel contains the value in the Text03 field which as you correctly say is a multi-line XHTML field. That field (Text03 ) is only used in a couple of places, and not for anything fancy so I could convert it to a straight text field and then use an 'equals' instead of 'contains'. Is that likely to work? If it is I shall be very happy but very cross at the same time!!!
Regards Alan C.