Data connections in jscript - differences from 2003 to 2010 - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

Data connections in jscript - differences from 2003 to 2010

Last post 07-09-2012 02:17 AM by TerryB. 8 replies.
Page 1 of 1 (9 items)
Sort Posts: Previous Next
  • 07-06-2012 08:29 AM

    Data connections in jscript - differences from 2003 to 2010

    HELP please!!! 

    I'm currently migrating from 2003 to 2010 in both InfoPath and SharePoint terms. The form I'm migrating has a lot of jscript that I need to retain (re-write etc. would be too much and I don't really have the time!) so I'm extracting the files & maintaining it that way. The 2003 form had some code that read data from a sharepoint list that had been added as a data connection. The code to read from the sharepoint list is something like :-

    var sectionName = "Project Management";

    var gate1 = XDocument.GetDOM("Gate_functional_areas").selectSingleNode("//dfs:Gate functional areas[@Title = '" + sectionName + "']/@Gate 1 Mandatory").text;
    // i.e. return from the list the value of Gate 1 mandatory when @Title = Project Management.

    How can I do same with a 2010 setup?

    I've tried 
    var gate1 = XDocument.GetDOM("Gate_functional_areas").selectSingleNode("//ns2:SharePointListItem_RW[ns2:Title = '" + sectionName + "']/ns2:Gate 1 Mandatory").text;   

    but it just doesn't work. I've got all my namespaces ok etc.

    I've also tried setting the search criteria, query the data then read the value - still no joy.

    XDocument.GetDOM("Gate_functional_areas").selectSingleNode("/dfs:myFields/dfs:queryFields/q:SharePointListItem_RW/q:Title").text = "Project Management";
    XDocument.GetDOM("Gate_functional_areas").Query;
    var gate1 = XDocument.GetDOM("Gate_functional_areas").selectSingleNode("//ns2:SharePointListItem_RW/ns2:Gate 1 Mandatory").text;

     I've also tried inserting "_x0020_" for spaces in the value I'm trying to get hold of e.g. ns2:Gate_x0020_1_x0020_Mandatory - beacuse if you create an expression box to display a data item from the data connection this is what it does.

    I really would appreciate some guidance as this is important and my backs to the wall to get this working!

    Thanks.

  • 07-07-2012 08:38 AM In reply to

    Re: Data connections in jscript - differences from 2003 to 2010

    Are you trying to use VB.NET or C# code?

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 07-07-2012 08:45 AM In reply to

    Re: Data connections in jscript - differences from 2003 to 2010

    I'm using jscript because this is what we used when we were in a 2003 environment. I couldn't change the code now as there's just far too much of it and the other 3000+ lines of code work fine. The only problem seems to be extracting the data from the sp list. Thanks.
  • 07-07-2012 08:56 AM In reply to

    Re: Data connections in jscript - differences from 2003 to 2010

    2010 ShP list/library data connections support filtering out of he box. Just add a rule to set he query data field and run the query. You'll want to convert or remove the code to get browser support in 2010. We could probably do his for you and I'm guessing it wouldn't be hugely time consuming. BTW, Greg has decided to become a farmer and doesn't do much IP these days. :)
    Patrick Halstead
    Project Manager at Qdabra
  • 07-07-2012 09:02 AM In reply to

    Re: Data connections in jscript - differences from 2003 to 2010

    So are you saying that this is code that was already working fine but stopped working when you opened the form in 2010?  Or is this a portion that you recently modified?  JScript isn't a language that's available in 2010, but if what you mean is that you're opening 2003 forms with JScript in 2010, then I don't think there should be any difference between 2003 and 2010.

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 07-07-2012 09:34 AM In reply to

    Re: Data connections in jscript - differences from 2003 to 2010

    Patrick/Jimmy - firstly many thanks for the prompt replies very much appreciated & Greg probably had the right idea!! 1. The form was developed in IP 2003 (with lots of jscript) and deployed in an SP03 environment and it has worked fine for 18 months (somedays 120+ users - I have an audit log written to by using webservices/updatelistitems). 2. Some months ago I opened the form in IP2010 designer and saved it to be compatible for 2003 and deployed to the 2003 SP environment (I had to make a few changes because IP10 seems to be less tolerant to recursive onafterchange issues). This is the current form in use. 3. Now I'm trying to upgrade it to be a IP2010 form (rather than 2003 filler compatible) and deploy it in our new 2010 SP environment and for it to be used by IP10 filler users. To maintain the script I have been extracting the form files and maintaining it that way - a rewrite would be a big chunk of effort without necessarily improving functionality. Working through 3 on the whole it's fine other than the issue I'm having about accessing the SP lists data. Patrick - I appreciate what you're saying about the ootb filtering and if I was starting again I wouldn't be using code (I'm actually advocating the codeless web forms is what we should deploy for any future projects ). But I am where I am and would much prefer to just get the code syntax working rather than changing logic/rules etc. (the specific line I'm having the problem is embedded in a couple of for & while loops). It's a big form and heavily used by many users so I want to derisk the migration phase I'm going through. The issue is compounded by the fact that I'm moving to another role in another part of our organisation and so need to get this migrated before the end of the month. Hope this helps explain. Again Many thanks for your help. Terry Boulter
  • 07-07-2012 10:57 AM In reply to

    Re: Data connections in jscript - differences from 2003 to 2010

    So if I understand correctly, you had to change some of the data connections to make your form 2010 compatible and you're having trouble updating the code that accesses those data connections.  Is that what the issue is?

    If so, I think a likely problem is that there's simply an issue with the XPath you've got there.  "@Gate 1 Mandatory" is definitely incorrect because node names can't have spaces like that.  I think the version you tried _x0020_s in it is probably a step closer, but maybe you're missing an @ symbol somewhere.  The most reliable way to get the correct paths for fields is to rightclick them in the taskpane and select Copy XPath, then paste that somewhere.  Please give that a try and see if it brings you any closer to the answer.

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 07-07-2012 02:06 PM In reply to

    Re: Data connections in jscript - differences from 2003 to 2010

    Jimmy - yes that's exactly the issue. I'm not able to check your suggestions at the moment as vpn is down and I can't access the environment, so it'll be tomorrow. But from what you're suggesting it's only a matter of syntax rather than it not being possible. I've actually tried accessing data that doesn't have spaces, but I couldn't get that working. Anyway I'll give iit a try tomorrow and get back to you. Again thanks for the help.
  • 07-09-2012 02:17 AM In reply to

    Re: Data connections in jscript - differences from 2003 to 2010

    Issue resolved! Phew. Good old OE (Operator Error). I was using the wrong namespace for ns2. In design mode I checked the properties dataFields which shows Namespace: http://schemas.microsoft.com/office/infopath/2003/dataFormSolution

     and I took that and set ns2 to same - wrong. Checking ns2:SharePointListItem_RW the namespace should be http://schemas.microsoft.com/office/infopath/2009/WSSList/dataFields 

    It's now working - Thanks for your help.

     

Page 1 of 1 (9 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.