Setting the values of Nodes to nonstring values - InfoPath Dev
in

InfoPath Dev

Setting the values of Nodes to nonstring values

Last post 10-01-2007 06:08 AM by MStevens. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 09-28-2007 11:46 AM

    Setting the values of Nodes to nonstring values

    I've been writing custom code (C#)  for a button in InfoPath 2007 that queries a webservice to return a dataset and then updates several fields on the form with values from said dataset.  The functionality is basically so people can fill out a form and submit it and look up the data in the form and change values as need be.  Right now I've no issues with setting the values of drop down lists, or text boxes as long as the values are strings.... but I've also got a few checkboxes and Date picker. 

     I'd like to be able to be able to programatically set values of nodes whether they are strings, ints, bools, or Date/time objects and haven't been able to find a method for this.

    The method I'm using for setting values is to assign the node using the XPathNavigator to get the node then using the SetValue function to change the value.  Unfortunatley the SetValue function only accepts string arguements, and will blow up the form if you set that value to a textbox that has been assigned a datatype of integer, or decimal. 

     I'm certain that if I can figure out this snag, figuring out how to set the values on the date pickers, and the check boxes will be no issue.

    Thanks

    Filed under:
  • 09-28-2007 12:23 PM In reply to

    Re: Setting the values of Nodes to nonstring values

    Why did you choose to do this with c# code when it can be done within InfoPath?

    Typically we at least setup the data connection and load the data from the web service into a secondary dom.  Then use code or rules to move the data within the form.

    We have some sample forms included in the Database Accelerator download. Qdabra Database Accelerator Suite Version 2.1.2815 - Developer

  • 09-28-2007 01:14 PM In reply to

    Re: Setting the values of Nodes to nonstring values

    Well... I only have three options for the button which is Rules and custom code, submit, and refresh.  Neither submit nor refresh took care of the functionality that I needed, so I chose the rules and custom code option and set about implementing custom code using C# as my language of choice.

    What I've done is set up each of the webservice methods as data sources and then used the XPathNavgator to push values in and extract values from the data sources... I'm not sure if that's what you mean by a secondary dom or not. 

     Thank you for the link and I'll have a look at the sample forms you provided and see if that clears things up for me.

     

     

     

  • 09-28-2007 01:26 PM In reply to

    Re: Setting the values of Nodes to nonstring values

    If you have set up a data connection and have both the source and target data fields in your data sources then you just need some rules.

    Instead of selecting edit form code, select the rules button.

    From there you can add rules with conditions and actions.

    I am guessing you would add several actions which set a fields value.  Then you put the target field and the source in so that when the button is clicked and the conditions are met the actions are fired.  (If you do not enter a condition it will happen every time.)  A bit simpler than coding.

  • 10-01-2007 06:08 AM In reply to

    Re: Setting the values of Nodes to nonstring values

    Thanks for the advice Clay, that takes care of all of my problems and is only 100 to 150 times easier than what I was doing.

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