SharePoint list / InfoPath labels - InfoPath Dev
in

InfoPath Dev

SharePoint list / InfoPath labels

Last post 07-18-2007 01:13 PM by Greg Collins. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 07-16-2007 12:05 PM

    • skrile
    • Top 500 Contributor
    • Joined on 08-17-2006
    • USA
    • Posts 29

    SharePoint list / InfoPath labels

    I am currently working on a project for my company and am building an Infopath 2003 document that needs to be accessible by many languages around the world.  Taking a page from my web design thinking, I was working toward a solution where the translations for my Infopath document would be stored in a Sharepoint list, accessed through a data connection, and the matching values would be "mapped" to various expression boxes that look to the user to be Lables.

    My Sharepoint translation list (ThirdPartyEvent_Translations) has the following attributes: 
    * stringid
    * languageid
    * translation

    My language choice dropdown at the top of the page has each language and their matching id's (i.e. English/en, Spanish (Mexican)/es-sp).

    So, here's what works right now:
    * I have a language dropdown
    * I have a Data connection to my sharepoint list that returns all my values
    * I put an Expression box on my page and set it's value to a filtered result from the ThirdPartyEvent_Translations sharepoint data connection.
     

    This was looking like it would take forever and there would be a lot of "hidden" code to manage.  It seemed to me to be smarter to create a group in my data list called Labels.  In that group I would have a list of all the StringIDs from my Sharepoint list and drag and drop those onto my form to serve as the labels for the form.

     This is what I want to have happen:

    Rather than hand-coding each box on the page, I want the value of each of the text boxes populated with the matching data from my Sharepoint List.  Therefore, when a user first opens the form, I want the text boxes to all be populated with the selected value of the language dropdown and the matching language id. This is where I'm having my trouble.  I've gone to the code-behind and played with some syntax, but it's clear I don't know what I'm doing!  Here's what I have - and is not working.  This is a specific example (trying to get the translation for one string id called "user_username").  I envision writing some type of script that would loop through each of the Sharepoint attributes and setting the corresponding Label value on the form.  This would allow me to trigger the function either through the OnLoad event, or when the language drop down is changed.  The UI.Alerts are there just for my testing, but in the real solution I would be setting the .text value to the matching text boxes on the page (something I can do and know the syntax for ).

    function XDocument::OnLoad(eventObj)
       { 
           var objTranslation = XDocument.DataObjects("ThirdPartyEvent_Translations").DOM;
          objTranslation.setProperty("SelectionNamespaces",'xmlns:dfs="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution" ' + ' xmlns:d="http://schemas.microsoft.com/office/infopath/2003/ado/dataFields"');
          var selectedLanguage = XDocument.DOM.selectSingleNode("/my:myFields/my:languageview").text;
          var selectedNode = objTranslation.selectSingleNode("//dfs:myFields/dfs:dataFields/d:ThirdPartyEvent_Translations[../@stringid='user_username' and ../@languageid='" + selectedLanguage + "']")
          if (selectedNode.selectSingleNode("Translation").text == null)

              { XDocument.UI.Alert('nope'); } 

              else { XDocument.UI.Alert(selectedNode.selectSingleNode("Translation").text); }

      }

    This code results in a .js error "'null' is null or not an object" on the line "if (selectedNode.selectSingleNode("Translation").text == null) "

     

    I would really appreciate it if someone could face me toward the light on this one!

  • 07-16-2007 04:00 PM In reply to

    Re: SharePoint list / InfoPath labels

    You are trying to get to a property of a null object: {NODE}.text, where {NODE} is the selectSingleNode stuff, and the .text is the property on that node.

    If {NODE} is null, then accessing .text is invalid.

    So your test should be:

    if (selectedNode.selectSingleNode("Translation") == null)

  • 07-17-2007 04:36 AM In reply to

    • skrile
    • Top 500 Contributor
    • Joined on 08-17-2006
    • USA
    • Posts 29

    Re: SharePoint list / InfoPath labels

    I've tried several version of that statement including:

    if (selectedNode.selectSingleNode("Translation") == null)

    and recieve the same Null error.  I'm wondering whether the syntax for selectedNode is corret.  Does it look correct to you?

     

    var selectedNode = objTranslation.selectSingleNode("//dfs:myFields/dfs:dataFields/d:ThirdPartyEvent_Translations[../@stringid='user_username' and ../@languageid='" + selectedLanguage + "']")

  • 07-17-2007 05:05 AM In reply to

    • skrile
    • Top 500 Contributor
    • Joined on 08-17-2006
    • USA
    • Posts 29

    Re: SharePoint list / InfoPath labels

    Woo Hoo.  Played some more and got this working!

    var selectedNode = objTranslation.selectSingleNode("//dfs:myFields/dfs:dataFields/dfs:ThirdPartyEvent_Translations/@Translation[../@stringID = 'user_sectionhead' and ../@languageid = 'en']")

     

    And then the translation can be referenced with:

    selectedNode.text

    So, that's good.  Now to figure out how to loop through each stringID in the ThirdPartyEvent....(figured this out over here:  http://www.infopathdev.com/forums/permalink/21731/21747/ShowThread.aspx#21747)

  • 07-18-2007 01:13 PM In reply to

    Re: SharePoint list / InfoPath labels

    Great! Glad to hear you got it working. Good sluething!
Page 1 of 1 (5 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.