I have a really complicated problem that I haven't been able to find a solution for and was wondering if anyone can provide some suggestions.
Background: I have a SharePoint list that contains 2 multiple choice fields. Choice field 1 contains a list of countries. The user can select multiple values e.g. Country 1, Country 3, Country 23 etc. Choice field 2 contains a list of what I call "filter groups", e.g. Group 1, Group 2, Group 3 etc. Again the user can select multiple values.
Now comes the challenging bit. There is a relationship between the country field and the group field. A country requires that certain groups are defined/selected.
Let me give an example. Country 1 requires that Groups A, B and C are selected Country 2 requires that Groups A, C and F are selected Country 3 requires that Groups G and H are selected. etc..
So if I have selected Country 1, Country 2 and Country 3 I require that Groups A,B,C,F,G and H are selected (goal is they are selected automatically).
If I then change the country selection to just Country 1 and Country 3 then Groups A,B,C,G and H should be selected - so simply removing the groups associated with a country is not an option as those groups could be used by other countries and therefore remain selected.
One more complication :-) The Groups field can contain additional values which are not in the groups associated with each country.
Now I have a piece of java script which is capable of analysing the values of the Countries field and creating the values for the grouping field. This can run against the SharePoint list and can update the grouping field.
So now to the real challenge:
In order to allow the user to enter and modify the data in the list I have created in SharePoint a page with a web part containing an InfoPath form. This is quite a complex form and uses all the field processing features that are supported by InfoPath. My problem is that I can find no way to build in the complex logic that is required to maintain the Grouping field based on changes made in the Countries field.
What have I already looked at? 1) Using xdEtension function to call code. This doesn't work because the form is linked to a list and therefore InfoPath doesn’t allow "code behind" i.e. it disables the developer tabs and code button. 2) Defining the "presaveAction()" method. This doesn't ever seem to get called. 3)I have looked into how I could manipulate the DOM to add new values into the InfoPath grouping field but I have no idea how this can be done.
Options for solving this: What I would really like to be able to do is when the user updates the countries field that it automatically regenerates the correct grouping entries so that it is possible to see exactly what is going on. This would mean building the logic into an expression and using rules to change the field in InfoPath. This is way beyond my skills at the moment (I have built several expressions already but the complexity of covering the above mentioned logic is way beyond me).
Failing that I could hide the grouping field and somehow calculate the values before the form saves to the SharePoint list. This would mean I would need to be able to capture the save operation and manipulate the grouping field entries before allowing InfoPath to save the data to the list. Even if it is possible to capture the event the question is how do you manipulate the Grouping field entries?
The other option is to capture when InfoPath has saved the entry and then go into the SharePoint list and read out the countries and grouping fields for the saved record and then rewrite the grouping entries with the correct values. I would have hoped that I could have done this with a workflow that captured when a record had been modified and then call my JavaScript code to manipulate the required Grouping field. This doesn't however seem to be possible. If I could find some means to execute a piece of JavaScript on the web page once the form has been saved this would be enough to allow me to use my existing script to update the list.
So basically I'm at a loss. I'm happy to entertain any suggestions /ideas how I can solve this using either InfoPath features, JavaScript embedded in the SharePoint page (including using JQuery), or SharePoint list features such as workflows.
0 commentaires:
Enregistrer un commentaire