assign values in my text fields - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

assign values in my text fields

Last post 08-04-2008 07:16 PM by Hilary Stoupa. 7 replies.
Page 1 of 1 (8 items)
Sort Posts: Previous Next
  • 07-30-2008 01:36 AM

    • reiqwan
    • Not Ranked
      Male
    • Joined on 07-30-2008
    • South Africa
    • Posts 11

    assign values in my text fields

    Hi All;

    I need to assign values in my text fields to get information from the URL querystring - I know this is possible using VSTA as I've managed to find the some  mentioning of it which gets the information from the URL or external provider:

    but not sure exactly how to take this code and assign it to the neccessary text field - so in other words I need to take the querystring value make it a variable in my form an then assign its value to my text field:

     some_variable = urlvalue

     urlvalue = textfield1.text

     should be pretty simple; but not sure how to do it?

    Thanks for the assistance;

  • 07-30-2008 02:08 AM In reply to

    • Shiva
    • Top 25 Contributor
    • Joined on 04-15-2005
    • India
    • Posts 694

    Re: assign values in my text fields

    Hello Welcome to the Forums,

    We can set that value using rule in InfoPath or we can write the code to set the values to text box.

    Code as below,

    //Get the secondary dom

    var secondaryDOM = XDocument.GetDOM("Data Connection Name");

    //Get the query string node

    var queryString =  secondaryDOM.selectSingleNode("XPath of your field");

    //Setting the query string node value to textbox.

    textbox1.text = queryString.text;

  • 07-30-2008 12:07 PM In reply to

    • reiqwan
    • Not Ranked
      Male
    • Joined on 07-30-2008
    • South Africa
    • Posts 11

    Re: assign values in my text fields

     Hi - and thanks for your response - with regard to your response I have a few queries about it -

    1) When you say "We can set that value using rule in InfoPath" how do I go about doing this

    and you might have to excuse my ignorance for this but I'm fairly new to Infopath 2007 and VSTA:

    2)  When you refer to the secondary DOM - do you mean the Data Object Model

    3) With regard to this line -> var secondaryDOM = XDocument.GetDOM("Data Connection Name");  I am not using a Data COnnection; basically just the information from my URL to get information for the form

     4) for this line here var queryString =  secondaryDOM.selectSingleNode("XPath of your field");  the Xpath you refer to is that jus tthe node?.... for example variable=testVariable

    5) For this line here my intellisense doesnt seem topick up my fieldnames when I type in their first few letters is there a reason behind this - do I need to reference any extra/special classes? 

     

    Thanks  again for your assistance and I look forward to your response.

  • 07-30-2008 08:13 PM In reply to

    Re: assign values in my text fields

    You shouldn't have to write code to get the URL of your form template, if that is the URL you are after. On the text field you wish to have set to the URL, simply right click, select Properties, and in the default value select the Formula Editor button. Paste this in the formula editor:

    substring-before(substring-after(/processing-instruction()[local-name(.) = "mso-infoPathSolution"], 'href="'), '"')

    Once your form is published to a SharePoint site, that formula will return the full URL of the template. Let me know if you need more information, okay?

    Hilary Stoupa

  • 07-31-2008 07:51 AM In reply to

    • reiqwan
    • Not Ranked
      Male
    • Joined on 07-30-2008
    • South Africa
    • Posts 11

    Re: assign values in my text fields

     Hi Hillary and thanks for the response - It's really appreciated and pushes out the URL - which is a good start.

     

    However I am in need of getting other data as well such as the other items in the querystring such as  - 

    &Source=

    &DefaultItemOpen=

    &SaveLocation=

    ?XsnLocation=

    How would I get those values as well from the URL querystring? - basically I need to figure out - once I've assisgned a variable how do I get that assigned value?

    Thanks again.

  • 07-31-2008 11:31 AM In reply to

    Re: assign values in my text fields

    I'm not entirely certain what you are asking, but to set and get values from a field in your form (C#, IP2007):

    //to get a form node
    XPathNavigator field = MainDataSource.CreateNavigator().SelectSingleNode("my:myFields/my:field1", NamespaceManager);

    //to set its value
    field.SetValue("value");

    //to get its value
    string value = field.Value;

    As far as getting the other values from the query string, this link may be able to help you.

    Hilary Stoupa

  • 08-04-2008 08:24 AM In reply to

    • reiqwan
    • Not Ranked
      Male
    • Joined on 07-30-2008
    • South Africa
    • Posts 11

    Re: assign values in my text fields

    Thanks again for this - regarding your answer it really helped!

    Thanks for the link to the Infopath site it was great in understanding more about Infopath forms.

     I am now trying to pass parameters through my xmlformview infopath web viewer component:

    Do you know if this is possible?

    Regards;

  • 08-04-2008 07:16 PM In reply to

    Re: assign values in my text fields

    I'm sorry, I don't know.... You've probably already run across this post, but just in case it helps you and you haven't, I thought I'd add it to the thread.

    Hilary Stoupa

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