Code and Object Required - InfoPath Dev
in

InfoPath Dev

Code and Object Required

Last post 09-05-2006 08:15 AM by mbenbow. 5 replies.
Page 1 of 1 (6 items)
Sort Posts: Previous Next
  • 08-24-2006 08:52 AM

    Code and Object Required

    Hey,

    This has been driving me nuts for some time. And, after examining each file within the XSN, I can fix the problem but the "fix" is not always the same. I am hoping that one of you can shed some light as to why I am having to do the following....

    Background Information:
    InfoPath 2003 - SP2; script language = VBScript

    In all 300+ forms, we have script that overrides the save routine in InfoPath. I never run into a problem with this code or using the eventObj.

    However, there are times when I need to revise forms and access the data elements within the DOM. If the elements of the DOM have not been accessed before in code, 80% of the time when I access a field in code (even though the XPath is 100% correct) I get the error in script that Object is Required.

    'Populate Seq. No. field if empty
    Dim oSeq
    Set oSeq = XDocument.DOM.selectSingleNode("//my:SEQNUM")
    If oSeq.text = "" Then
    'do something
    End If

    It always fails on the Set oSeq line........

    Here is what I have discovered are the possible "fixes"
    1) In the scrip.vbs file ensure that the '<namespacesDefinition> has the following namespace (xmlns:od=""urn:schemas-microsoft-com:officedata""). This is missing in 20% of the cases

    2) In the scrip.vbs file ensure that the '<namespacesDefinition> has the namespace xmlns:my as the one listed in Designer under File/Form Properties/FormID. In 80% of the cases, the namespace "xmlns:my" does not equal the FormID namespace - actually it is missing some of the namespace.

    For instance:

    The script file will state
    xmlns:my=""http://schemas.microsoft.com/office/infopath/2003/myXSD""

    When it needs to be:
    xmlns:my=""http://schemas.microsoft.com/office/infopath/2003/myXSD/2006-05-10T16:28:52""

    3) There has been one instance when the namespace for my in the manifest did not match up with the same namespace in schema (date and/or time were different).

    Is this a bug? Or do I merely need to keep a crib sheet on how to apply the "fix" in order for the code to recognize the elements in the DOM??

    Why isn't InfoPath synching the information when you "extract" the files?

    Am I the only one that has this issue?

    Thanks,
    Mary
  • 08-24-2006 11:42 PM In reply to

    • shekar
    • Not Ranked
      Male
    • Joined on 07-26-2006
    • India
    • Posts 22

    Re: Code and Object Required

    Hi mary
    If your SEQNUM field is in a group(myFields) like("/my:myFields/my:SEQNUM")
    then you wrote the wrong xpath, so correct then you will get it.
    Shekar
    http://www.ggktech.com
  • 08-25-2006 04:26 AM In reply to

    Re: Code and Object Required

    Hey,

    My Xpath is not wrong!

    The code work in more than 30 forms! And SEQNUM is always directly under the main data source.

    If you read my post carefully.....the issue is with the namespace and determining which namespace is incorrect. From rules, the form has no issue with reading the values of the main datasource element. From code (where it has a bad namespace referece), the form does not understand the datasource elements. But once I "fix" the offending namespace, the form "all of a sudden" will accept the same XPATH statement and produce the desired result.

    So it is not an Xpath issue!!!!!

    Mary
  • 08-31-2006 07:55 AM In reply to

    Re: Code and Object Required

    Hey again,

    Since I have not heard from any one of the above issue......perhaps someone can explain to me why Microsoft is appending a namespace with a Date/Time.

    In April I created a form - called 4668. At the time I created the form, the "xmlns:my" namespace was:
    xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD"

    In Aug, I had to revise the form. So I took the 4668.xsn and did a Save As to name is 4668_20060802.xsn. Sometime when I made the revisions to 4668_20060802.xsn, the "xmlns:my" changed to:
    xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2006-05-10T16:28:52"

    This namespace was actually changed in every document (xsl, xml, xsf, etc) within the XSN except for the script.vbs file.

    So, at the end of this month when I needed to make a change to the form yet again and use selectSingleNode in code to reference an element in the DOM, I can to change the namespace in the script.vbs file to the following in order to reference the DOM in code:
    xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2006-05-10T16:28:52"


    My basic question is why is the namespace being being "redefined" and what signifigance is the date/time stamp at the end of the namespace??

    Mary
  • 09-02-2006 12:14 AM In reply to

    Re: Code and Object Required

    Hi Mary,

    Sorry for the delays in responding to you. I guess we need more information about your form. Can you send us the XSN? I'll ask one of our developers to look at it. My guess is that you may bot be setting the namespace in your code and that may be required. Your workarounds are probably not true workarounds. There are many threads that have sample C# code to do exactly what you are doing, so I suggest searching the forum. Lastly, your xpath does look unique. Did you create your schema manually?

    As for the xmlns:my namespace date postfixing, this is to store when the form (and schema) was last saved.

    I hope this helps. Please do not hesitate to send me e-mail with your XSN and we'll debug it for you.

    Cheers!
    Patrick Halstead
    Project Manager at Qdabra
  • 09-05-2006 08:15 AM In reply to

    Re: Code and Object Required

    Hey,

    I could send you an XSN....since it is occurring on all 300 XSNs.

    You are correct in that I have never set a namespace in code. I am doing all the programming via the script.vbs file that is created by InfoPath. It is in this file that Microsoft creates the namespace and what Microsoft creates is not correct.

    The schemas are not created manually.
Page 1 of 1 (6 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.