From Managed Code back to script mode - InfoPath Dev
in

InfoPath Dev

From Managed Code back to script mode

Last post 10-30-2005 06:34 PM by franck. 8 replies.
Page 1 of 1 (9 items)
Sort Posts: Previous Next
  • 10-25-2005 04:49 AM

    • amek
    • Not Ranked
    • Joined on 04-11-2005
    • Sweden
    • Posts 6

    From Managed Code back to script mode

    I would like to change code mode in a InfoPath form from Managed C# code to original script mode/code.
    Is it possible and does anyone know how to do this? Of course the code have to be translated ;-)
    The form have rich design and I don't like the idéa to start all over...
  • 10-25-2005 10:58 AM In reply to

    Re: From Managed Code back to script mode

    Hi,

    yes you can...
    Create a blank IP project with scripting. Extract the files. Copy the 2 .js files.
    Copy your xsn (generated with VS.Net) into a folder. Extract the files and copy the 2 .js files from above.
    Next, open your manifest.xsf and do the following:

    replace:
    <xsf:file name="InfoPathProject1.dll">
    <xsf:fileProperties>
    <xsf:property name="fileType" type="string" value="rootAssembly"></xsf:property>
    </xsf:fileProperties>
    </xsf:file>
    by:
    <xsf:file name="script.js">
    <xsf:fileProperties>
    <xsf:property name="scriptType" type="string" value="userEvents"></xsf:property>
    </xsf:fileProperties>
    </xsf:file>
    <xsf:file name="internal.js">
    <xsf:fileProperties>
    <xsf:property name="scriptType" type="string" value="internal"></xsf:property>
    </xsf:fileProperties>
    </xsf:file>

    At the end of the manifest, replace:
    </xsf:xDocumentClass>
    by:
    <xsf:scripts language="jscript">
    <xsf:script src="internal.js"></xsf:script>
    <xsf:script src="script.js"></xsf:script>
    </xsf:scripts>
    </xsf:xDocumentClass>

    Next, save your xsn back.

    and Voila....


    Regards,

    Franck Dauché
  • 10-25-2005 11:43 AM In reply to

    Re: From Managed Code back to script mode

    I have posted this before, check out this article as well. http://www.kbalertz.com/kb_828853.aspx
    Jason
    http://www.k2distillery.com/
  • 10-25-2005 12:31 PM In reply to

    Re: From Managed Code back to script mode

    Didn't know you had posted that. Would have referenced yours (would have been easier and faster)...
    Cheers

    Franck
  • 10-28-2005 07:32 AM In reply to

    • amek
    • Not Ranked
    • Joined on 04-11-2005
    • Sweden
    • Posts 6

    Re: From Managed Code back to script mode

    The link above doesn't work!
    Server Application Unavailable
  • 10-28-2005 07:34 AM In reply to

    • amek
    • Not Ranked
    • Joined on 04-11-2005
    • Sweden
    • Posts 6

    Re: From Managed Code back to script mode

    If I do like the instructions above then I can't reach the nodes in my DOM.
    selectSingleNode always return null.
    Is it something with SelectionNamespaces?
  • 10-28-2005 11:39 AM In reply to

    Re: From Managed Code back to script mode

    Yes, probably. Here is a code snippet from the very top of my JScript file. You MUST declare your namespaces and reference them any time you are using XPath in any function or anything else, at least from my experience. Anyway the xmlns:xsi and xmlns:xd are standard and should be included in your file. The other namespaces can be found by double-clicking on a control and going to the "advanced" tab. You should find the namespace there.


    // The following line is created by Microsoft Office InfoPath to define the prefixes
    // for all the known namespaces in the main XML data file.
    // Any modification to the form files made outside of InfoPath
    // will not be automatically updated.
    //<namespacesDefinition>
    XDocument.DOM.setProperty("SelectionNamespaces", 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns2="http://www.w3.org/1999/xhtml" xmlns:ns1="http://schemas.microsoft.com/office/infopath/2003/myXSD/2005-08-22T14:26:27" xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2005-08-23T19:14:40" xmlns:xd="http://schemas.microsoft.com/office/infopath/2003"');
    //</namespacesDefinition>




    If all else fails, you could copy all your JScript code from you .js file, put it in notepad for a second, extract your form to files, delete the .js file there, re-publish into XSN and then go to Tools -> Programming -> Microsoft Script Editor. This should get you back to an original .js file with all the MS auto-generated stuff in it.

    ---------------
    Matt Faus
    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
  • 10-30-2005 05:13 PM In reply to

    Re: From Managed Code back to script mode

    The link seems to be working for me right now.
    Jason
    http://www.k2distillery.com/
  • 10-30-2005 06:34 PM In reply to

    Re: From Managed Code back to script mode

    Yep, it is now, but it wasn't working for a couple of days.
Page 1 of 1 (9 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.