Example Code for OnClick Print Button - InfoPath Dev
in

InfoPath Dev

Example Code for OnClick Print Button

Last post 12-20-2006 02:18 AM by FordFiestaST150. 9 replies.
Page 1 of 1 (10 items)
Sort Posts: Previous Next
  • 12-19-2006 10:16 PM

    Example Code for OnClick Print Button

    Print button placed on form, double-click and selected Edit Form Code. Microsoft Script Editor opens and requires code to print on click with js coding.

    This is what I see at the moment:

    "// 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:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2006-12-19T13:12:04"');
    //</namespacesDefinition>


    //=======
    // The following function handler is created by Microsoft Office InfoPath.
    // Do not modify the name of the function, or the name and number of arguments.
    //=======
    function CTRL1_5::OnClick(eventObj)
    {
    //write your code here
    }"

    What code do I put in there enabling user to print the form when selecting the print button?
  • 12-19-2006 10:45 PM In reply to

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

    Re: Example Code for OnClick Print Button

    Hi Ford,

    Try XDocument.PrintOut();

    Note: It can be accessed only by fully trusted forms.
  • 12-19-2006 11:24 PM In reply to

    Re: Example Code for OnClick Print Button

    Hi Shiva

    How do I go about entrusting my forms fully?
  • 12-19-2006 11:32 PM In reply to

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

    Re: Example Code for OnClick Print Button

    Hi Ford again,

    Follow the below steps to give full trust permissions,
    1. Go to Tools -> form Options
    2. Open the security Tab
    3. Unselect the checkbox at "Automatically determine security level ...."
    4. Select Full trust radio button
    5. Check "Sign this Form" checkbox
    6. Click on Create certificate -> this creates a personal certificate.
    7. Now click on Ok and then publish the solution to Sharepoint

    When the solution user opens the form from sharepoint they get a dialog box, in which they have a details button. On clicking of this button they can install the certificate. After installing certificate close and open the InfoPath form again to start using it.
  • 12-19-2006 11:36 PM In reply to

    Re: Example Code for OnClick Print Button

    Hi Silva

    Apologies for being such a nag, completely new at this and appreciating your patience and assistance. One last question ....
    How and where do I publish the solution to sharepoint and it is necessary to have Office Sharepoint Server installed on my system?
  • 12-19-2006 11:49 PM In reply to

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

    Re: Example Code for OnClick Print Button

    Hi Ford,

    No, You can publish it into your local machine also and try it once.
  • 12-20-2006 12:19 AM In reply to

    Re: Example Code for OnClick Print Button

    Shiva

    I am receiving a runtime error in the following script. Please help
    "//=======
    // The following function handler is created by Microsoft Office InfoPath.
    // Do not modify the name of the function, or the name and number of arguments.
    //=======
    function CTRL1_5::OnClick(eventObj)
    {
    XOwnerMemberBenefits.PrintOut();
    }"
  • 12-20-2006 01:21 AM In reply to

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

    Re: Example Code for OnClick Print Button

    Hi Ford,

    You can write the below code for print in OnClick event,

    XDocument.PrintOut();
  • 12-20-2006 02:04 AM In reply to

    Re: Example Code for OnClick Print Button

    sorry but I am still having problems either understanding what you just wrote or a complete ID10t
  • 12-20-2006 02:18 AM In reply to

    Re: Example Code for OnClick Print Button

    Cancel that - I just got it to work.

    Thanks for all your help Shiva
Page 1 of 1 (10 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.