Object cannot be created - InfoPath Dev
in

InfoPath Dev

Object cannot be created

Last post 01-22-2009 03:01 AM by paralyzedcitizen. 6 replies.
Page 1 of 1 (7 items)
Sort Posts: Previous Next
  • 01-16-2009 02:42 AM

    Object cannot be created

    I'm having problems with the following code. It worked yesterday but does not work now. What's going on?! I get an error informing me the the object can not be created.

    function XDocument::OnLoad(eventObj)
    {
        var wshshell=new ActiveXObject("wscript.shell");
        var username=wshshell.ExpandEnvironmentStrings("%username%");
        XDocument.DOM.selectSingleNode("/my:myFields/my:CustomFields/my:CurrentUser")=username;

    }

     

  • 01-16-2009 04:02 AM In reply to

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

    Re: Object cannot be created

    Hello,

    Can you check once, are you getting the username or not? You have to modify code as below,

    XDocument.DOM.selectSingleNode("/my:myFields/my:CustomFields/my:CurrentUser").text = username;

  • 01-16-2009 04:05 AM In reply to

    Re: Object cannot be created

     ah, thank you. that was going to be my next question. No, I'm actually getting the username, the error is in the first line

    var wshshell=new ActiveXObject("wscript.shell");

     Is there something I need to reference or declare? I'm very new to javascript. :(

  • 01-16-2009 07:03 AM In reply to

    Re: Object cannot be created

     Hi,

     Thanks wsathip, but I didn't really extract anything useful from those links. One had a solution but it involed using VBScript instead of JScript and that's not really an option for me.

     Am I not making a simple mistake? such as not declaring something or something equally as silly as that? Although that wouldn't explain why it worked once and then not the second time.

     

    EDIT: im also now getting problems with this line

    XDocument.DOM.selectSingleNode("/my:myFields/my:CustomFields/my:CurrentUser").text=username;

    it says its null or not an object! ???

  • 01-16-2009 08:54 AM In reply to

    Re: Object cannot be created

    Hi --

    Did you change the trust level on your form? In a quick test, my template had to be full trust to create the Active X object. As far as the error for the line in your edit -- did you change or modify the data structure in your form at all such that the XPath "/my:myFields/my:CustomFields/my:CurrentUser" is no longer pointed to a valid data source node?

    Hilary Stoupa

  • 01-22-2009 03:01 AM In reply to

    Re: Object cannot be created

     Hi guys,

     Thanks to everyone who's replyed to this thread, your help is greatly appreciated. I have however, figured out the root of the problem. Before publishing the form all is well and the username can be read and wonderful things done with it. But after the form is published my work security steps in and disables ActiveX components within InfoPath forms. If I then try and edit the form further it will pop up an error message about the ActiveX object.

     How irritating.

     Thanks again everyone.

    -Tom

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