<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://www.infopathdev.com:443/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Newbie Questions</title><link>https://www.infopathdev.com:443/forums/39.aspx</link><description>New to InfoPath? Search to see if your question has already been answered. If it has not, then ask it here or the appropriate topic forum.</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP3 (Build: 31118.962)</generator><item><title>Re: Using Set command in vbscript</title><link>https://www.infopathdev.com:443/forums/thread/3096.aspx</link><pubDate>Fri, 25 Aug 2006 14:41:18 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:3096</guid><dc:creator>hensleydl</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/3096.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=39&amp;PostID=3096</wfw:commentRss><description>mbenbow - thanks for your reply, I see where it helps.  I have another question.  Do you have to execute PopFieldValue any time you need to change the value from the script?  We're linking the form from an SQL table so we do a lot of updating of fields through the script (object code)  This would not be much of a problem on small forms but it could be a problem when you have to load values to the script from the form and from the SQL table.  Any thoughts would be appreciated.</description></item><item><title>Re: Using Set command in vbscript</title><link>https://www.infopathdev.com:443/forums/thread/3095.aspx</link><pubDate>Thu, 24 Aug 2006 18:44:23 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:3095</guid><dc:creator>henscola</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/3095.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=39&amp;PostID=3095</wfw:commentRss><description>This is a copy of the code that I used for this test form.  This form works, I'm just wondering if there's a better way instead of all those "SET" commands&lt;br /&gt;&lt;br /&gt;Sub XDocument_OnLoad(eventObj)&lt;br /&gt;' Write your code here&lt;br /&gt;Dim RecCnt2&lt;br /&gt;Dim RecNbr2&lt;br /&gt;&lt;br /&gt;'==========&lt;br /&gt;' Link Script Variables to Fields in Forms&lt;br /&gt;'==========&lt;br /&gt;Set txtUId = XDocument.DOM.selectSingleNode("//my:txtUId")&lt;br /&gt;Set txtCnn = XDocument.DOM.selectSingleNode("//my:txtCnn")&lt;br /&gt;Set txtAward_To = XDocument.DOM.selectSingleNode("//my:txtAward_To")&lt;br /&gt;Set txtOrg = XDocument.DOM.selectSingleNode("//my:txtOrg")&lt;br /&gt;Set txtFor = XDocument.DOM.selectSingleNode("//my:txtFor")&lt;br /&gt;Set txtSubmit_By = XDocument.DOM.selectSingleNode("//my:txtSubmit_By")&lt;br /&gt;Set txtOrg_By = XDocument.DOM.selectSingleNode("//my:txtOrg_By")&lt;br /&gt;Set txtTele = XDocument.DOM.selectSingleNode("//my:txtTele")&lt;br /&gt;Set dtmDate_Sub = XDocument.DOM.selectSingleNode("//my:dtmDate_Sub")&lt;br /&gt;Set txtRecNbr = XDocument.DOM.selectSingleNode("//my:txtRecNbr")&lt;br /&gt;Set txtRecCnt = XDocument.DOM.selectSingleNode("//my:txtRecCnt")&lt;br /&gt;Set lstSearch = XDocument.DOM.selectSingleNode("//my:lstSearch")&lt;br /&gt;Set lstCntPinTries = XDocument.DOM.selectSingleNode("//my:lstCntPinTries")&lt;br /&gt;Set txtSearch = XDocument.DOM.selectSingleNode("//my:txtSearch")&lt;br /&gt;    &lt;br /&gt;    TrimUserId()&lt;br /&gt;    TrimCnnStr()&lt;br /&gt;    OpenDbConnection()&lt;br /&gt;	InitializeForm()&lt;br /&gt;    DetermineRecNbrAndCount RecNbr2, RecCnt2&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;This forms accesses data from a SQL database.  The SQL side works fine with no problems.</description></item><item><title>Re: Using Set command in vbscript</title><link>https://www.infopathdev.com:443/forums/thread/3094.aspx</link><pubDate>Thu, 24 Aug 2006 18:35:01 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:3094</guid><dc:creator>mbenbow</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/3094.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=39&amp;PostID=3094</wfw:commentRss><description>Hey,&lt;br /&gt;&lt;br /&gt;I did the following on a training form so that the user could click a button and the data would be populated in the field or removed from the field.  Not sure if it will help you...&lt;br /&gt;&lt;br /&gt;All code is VBScript...&lt;br /&gt;&lt;br /&gt;Sub ClearDataFields_OnClick()&lt;br /&gt; 'Write your code here&lt;br /&gt;	PopDefaults xDocument.view.name, True&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;Sub PopDataFields_OnClick()&lt;br /&gt;	PopDefaults xDocument.view.name, False&lt;br /&gt;End sub&lt;br /&gt;&lt;br /&gt;Sub PopDefaults(ByVal sViewName, bRemoveData)&lt;br /&gt;'purpose	to populate default values based on which view you&lt;br /&gt;'			are in.  If bRemoveData is true, clear fields&lt;br /&gt;	Dim sTxt&lt;br /&gt;	&lt;br /&gt;	Select Case UCase(sViewName)&lt;br /&gt;		Case "FORMATFIELDS"&lt;br /&gt;			PopFieldValue "//my:ChainID", "1001-11-11", bRemoveData&lt;br /&gt;			PopFieldValue "//my:CostCenter", "01255", bRemoveData&lt;br /&gt;			PopFieldValue "//my:DateControl", "2006-06-01", bRemoveData&lt;br /&gt;			PopFieldValue "//my:DIVNum", "3015", bRemoveData&lt;br /&gt;			PopFieldValue "//my:DeptDivNo", "3001", bRemoveData&lt;br /&gt;			PopFieldValue "//my:EMPID", "101256", bRemoveData&lt;br /&gt;			PopFieldValue "//my:EIN", "11-5533667", bRemoveData&lt;br /&gt;			PopFieldValue "//my:SAP_GLCode", "1111-12345678-22668", bRemoveData&lt;br /&gt;			PopFieldValue "//my:PhoneNumber", "(336) 741-5000", bRemoveData&lt;br /&gt;			PopFieldValue "//my:EmpName", "Jane Q Doe", bRemoveData&lt;br /&gt;			PopFieldValue "//my:SISNo", "100111", bRemoveData&lt;br /&gt;			PopFieldValue "//my:SSN", "333-22-3333", bRemoveData&lt;br /&gt;			PopFieldValue "//my:TerritoryNo", "400112", bRemoveData&lt;br /&gt;		Case "REPEAT"&lt;br /&gt;			If bRemoveData = False Then&lt;br /&gt;				AddRepeatingSection 2, "QTYS"&lt;br /&gt;				AddRepeatingSection 2, "PLANNED_MEETS"&lt;br /&gt;				AddRepeatingSection 2, "EMPLOYMENT_HISTORY"&lt;br /&gt;				'AddRepeatingSection 3, "POSITIONS_HELD"&lt;br /&gt;			Else&lt;br /&gt;				RemoveRepeatingSection 1, "QTYS"&lt;br /&gt;				RemoveRepeatingSection 1, "PLANNED_MEETS"&lt;br /&gt;				RemoveRepeatingSection 1, "EMPLOYMENT_HISTORY"&lt;br /&gt;			End If&lt;br /&gt;		case Else&lt;br /&gt;	End Select&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;Sub PopFieldValue(sFieldName, sValue, bRemoveData)&lt;br /&gt;'to populate the value in the field that is off the root node&lt;br /&gt;	Dim oField&lt;br /&gt;	&lt;br /&gt;	Set oField = XDocument.DOM.SelectSingleNode(sFieldName)&lt;br /&gt;	&lt;br /&gt;	'must remove xsi:nil attribute if necessary&lt;br /&gt;	'required for dates and numeric values&lt;br /&gt;	&lt;br /&gt;	&lt;br /&gt;	'add the value or remove it&lt;br /&gt;	If bRemoveData = False then&lt;br /&gt;		If oField.getAttribute("xsi:nil")  Then&lt;br /&gt;			oField.removeAttribute("xsi:nil")&lt;br /&gt;		End If&lt;br /&gt;		oField.Text = sValue&lt;br /&gt;	Else&lt;br /&gt;		If sFieldName &amp;lt;&amp;gt; "//my:DateControl" Then&lt;br /&gt;			oField.Text = ""&lt;br /&gt;		Else&lt;br /&gt;			Dim xmlNil&lt;br /&gt;			Set xmlNil = oField.ownerDocument.createNode(2, "xsi:nil", "http://www.w3.org/2001/XMLSchema-instance")&lt;br /&gt;			xmlNil.text = "true"&lt;br /&gt;			oField.Text = ""&lt;br /&gt;			oField.setAttributeNode(xmlNil)&lt;br /&gt;		End if&lt;br /&gt;&lt;br /&gt;	end If	&lt;br /&gt;&lt;br /&gt;End Sub&lt;br /&gt;&lt;br /&gt;Function AddRepeatingSection(num, elmName)&lt;br /&gt;'Adds specified number of elements to repeating table or section.&lt;br /&gt;'Parameters: &lt;br /&gt;'num is number of sections/rows to add&lt;br /&gt;' elmName is name of repeating area as shown in datasource task pane (without the "my:" prefix).&lt;br /&gt;&lt;br /&gt;	Dim secPath, oSecGrp, oSecItem, oClone&lt;br /&gt;	&lt;br /&gt;	secPath = "//my:" &amp; elmName&lt;br /&gt;	&lt;br /&gt;	Set oSecGrp = XDocument.DOM.selectNodes(secPath)&lt;br /&gt;	&lt;br /&gt;	If oSecGrp.length &amp;gt; 0 Then&lt;br /&gt;	&lt;br /&gt;		Set oSecItem = oSecGrp.Item(0)	&lt;br /&gt;		i = 0&lt;br /&gt;	&lt;br /&gt;		Do Until i = num&lt;br /&gt;			'Clone the first row/section.&lt;br /&gt;			Set oClone = oSecItem.cloneNode(True)&lt;br /&gt;			'Append section at end of nodeset.&lt;br /&gt;			oSecItem.parentNode.insertBefore oClone, oSecGrp.Item(oSecGrp.length + i + 1)				&lt;br /&gt;			i = i + 1&lt;br /&gt;		Loop&lt;br /&gt;		&lt;br /&gt;	End If&lt;br /&gt;&lt;br /&gt;End Function&lt;br /&gt;&lt;br /&gt;Function RemoveRepeatingSection(num, elmName)&lt;br /&gt;'Removes elements to repeating table or section leaving 1 default section or table&lt;br /&gt;'Parameters: &lt;br /&gt;' elmName is name of repeating area as shown in datasource task pane (without the "my:" prefix).&lt;br /&gt;&lt;br /&gt;	Dim secPath, oSecGrp, oSecItem, oClone&lt;br /&gt;	&lt;br /&gt;	secPath = "//my:" &amp; elmName&lt;br /&gt;	&lt;br /&gt;	Set oSecGrp = XDocument.DOM.selectNodes(secPath)&lt;br /&gt;	&lt;br /&gt;	If oSecGrp.length &amp;gt; 0 Then&lt;br /&gt;	&lt;br /&gt;		Set oSecItem = oSecGrp.Item(0)	&lt;br /&gt;		'i = 0&lt;br /&gt;		i = oSecGrp.length&lt;br /&gt;	&lt;br /&gt;		Do Until i = num&lt;br /&gt;			'Remove section at end of nodeset.&lt;br /&gt;			oSecItem.parentNode.removeChild oSecGrp.Item(oSecGrp.length - i + 1)				&lt;br /&gt;			i = i - 1&lt;br /&gt;			&lt;br /&gt;		Loop&lt;br /&gt;&lt;br /&gt;	End If&lt;br /&gt;&lt;br /&gt;End Function</description></item><item><title>Using Set command in vbscript</title><link>https://www.infopathdev.com:443/forums/thread/1520.aspx</link><pubDate>Thu, 24 Aug 2006 16:37:45 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:1520</guid><dc:creator>henscola</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/1520.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=39&amp;PostID=1520</wfw:commentRss><description>I am new to using infopath.  I am looking at converting existing online forms created in Accelio into infopath.  My question concerns the script (object) code.  I noticed that using vbscript with infopath, you have to use &lt;b&gt;Set&lt;/b&gt; commands (i.e. &lt;i&gt;Set txtUid = XDocument.DOM.selectSingleNode("//my:txtUID")&lt;/i&gt;.  It seems that you have to issue this command for each field.  This can get quite cumbersome when you have a form with many fields.  Also I noticed that when you have a lot of forms, you need to use the "SET" statement multiple times in the script code for it to work.  Any suggestions as to how to work successfully with the "SET" command in vbscript?  Any suggestions would be greatly appreciated.</description></item></channel></rss>