How to close infopath form through code?

Hi All,
How to close infopath form through code, thanks in advance!

Hi Sam,
Please check if the articles below can be help:
http://www.bizsupportonline.net/browserforms/programmatically-submit-infopath-form-sharepoint-send-email-close-form.htm
http://www.bizsupportonline.net/blog/2009/01/how-to-programmatically-run-code-close-infopath-web-form/
Regards,
Rebecca Tu
TechNet Community Support

Similar Messages

  • Infopath: Rules run before Code...So Can we close the form through Code?

    Hi,
    I have a form with a couple of buttons. Clicking on any of the buttons first executes the RULES and then jumps to execute the code in the FormCode.cs file for the button click event. However, if I have "Close the Form" as one of the Rules for the button, the code does not execute. So, is there a way that I can close my Infopath fom after executing the code instead of closing from the RULES? Also "The form has been closed" is the message which pops up after closing form through rules. Can we redirect to the form library instead of showing this message?
    I tried to execute everything through code in FormEvents_Submit. It works fine if I have a single submit button. But how would i differenciate if there are multiple buttons like Approve, Reject etc.
    Thanks !

    Hi Aanu,
    Thanks for the reply.The proposed solution in the thread is to use;
    this.Application.ActiveWindow.Close();
    or
    thisXDocument.View.Window.Close(true) in order to close the form.
    Both of them don't work when I try to use them in Visual Studio. It complains of a missing namespace.
    Did this approach work for anyone?

  • How to Close InfoPath Form After Submission When Two Buttons Exist?

    I have an browser-enabled InfoPath 2010 form that has two views and a submit button on each view. The form would correctly submit and close the form using one button on the form until the second button was added. After adding the submit button on a second
    view, the second button submitted/closed but the behavior on the first view changed so that the form no longer closes after submission. I’ve researched this and have not yet found a solution to allow closing the form after submission for one of the buttons.
    Things I’ve tried:
     - I’ve attempted creating multiple submit data connections for the different buttons
     - Specifying different Submit Options
     - Try closing the form with the code
     - Add another button to the non-closing view
     - Add duplicate Rule actions to "Close this form: No Prompt"
    Settings:
    Button rules:
     - Submit using data connection: SharePoint Library Submit
     - Close this form: No Prompt
    Button Properties:
     - Action > Rules and Custom Code
    The form Submit Options:
     - Send form to a single destination (a form library)
     - Choose a data connection for submit (SharePoint library submit)
     - Advanced > After Submit: Close the form
    Advanced form options:
     - Filler Features: all items unchecked (not allowing Save, etc.)
     - E-Mail Attachments: uncheck Enable InfoPath e-mail form functionality for this form template
    Resources:
    When considering programmatically submitting and closing the form, I understand from this article that the Rules run before code and I can’t close the InfoPath form programmatically by writing code behind a button that has a rule set on it:
    http://www.bizsupportonline.net/blog/2009/01/how-to-programmatically-run-code-close-infopath-web-form/
    Discussion of creating a custom Save and Submit buttons for InfoPath browser forms:
    http://markhaverty.com/sharepoint/custom-save-and-submit-buttons-for-infopath-browser-forms/

    what if you need to switch views? 
    I have the same problem in a similar situation.  I created a test button to narrow down the cause.  the button submits data & closes the form fine.  however when I add a rule to switch views before the submit & close rule, it
    breaks.  Submit still works but it no longer closes the form.  If I disable the switch-view rule, then it closes fine. 
    I tried added another rule to switch back to the main view but that didn't help. 
    switching views is an integral part of the workflow b/c I want to email the alternate view upon approval & then close the form.  So removing that rule is not a good answer unfortunately. 

  • How to create OIM form through code

    Hi,
    As per requirement, I have to create OIM form by calling createForm(hashmap) method in my code but not sure what parameter i need to paas as hashmap for this method.
    If any one can give me some idea about this or any other way of doing this.
    Thanks

    Hay Martin,
    I think he is talking about creating object and process form on the fly(Thats a weired requirement). To find out the key-value pair for map you need to do following.
    1.Go to the lookup definition and search for structure
    2.You will get lot of field related with structure utility for example: Structure Utility.Table Name,Structure Utility.Description and few more fields.Pass these field as a key in map and put the desired value.
    3.The map should contain all the required field value as it is needed at the time of form creation from design console.
    I have not done it before so I can not tell you exact key value pair needed for createForm () method but th above can be good starting point.Just play with few value and you will get the right combination.
    Hope this will help.
    Regards
    Nitesh

  • How to invoke safari browser through code?

    how to invoke safari browser through code?

    Hi Sam,
    Please check if the articles below can be help:
    http://www.bizsupportonline.net/browserforms/programmatically-submit-infopath-form-sharepoint-send-email-close-form.htm
    http://www.bizsupportonline.net/blog/2009/01/how-to-programmatically-run-code-close-infopath-web-form/
    Regards,
    Rebecca Tu
    TechNet Community Support

  • How to save infopath form in XML file

    How to save InfoPath form in XML file.
    I want every new record in InfoPath form save in XML file and also retrieve these records from XML like databases

    Hi,
    Based on your description, my understanding is that you want to save InfoPath form in XML file.
    I have done a test in my SharePoint, Do the following steps:
    Create an form library and publish an InfoPath form into it, Then when we create new document into the form library, it is by default that InfoPath form is saved in XML file.
    Best Regards,
    Lisa Chen
    Lisa Chen
    TechNet Community Support

  • How to submit InfoPath form data to multiple SharePoint lists at one time?

    Hi,
    I'm looking for a way to submit certain data in InfoPath form to separate SharePoint lists at the same time. I have a form that has two views with many data in them. I want to keep these data in separate SharePoint list besides keeping them in the XML. I know that you can submit to a form library using SharePoint document library data connection, but I'm not sure if you can use several data connections for submitting data to multiple SharePoint lists. Is it only possible to do using code? If yes, can anyone show a sample. I have never coded in InfoPath, though I used C# a lot in .Net.
    Thank you!Regards,
    R.D.M.

    This is an old thread but I tripped over a codeless method to do this with OOB InfoPath 2010 and SP 2010. 
    Assuming your main InfoPath form is published to a document library with the promoted fields that you want to see.
      Publish your form to a new document library to capture the secondary data fields that you want separated out.
    Using the Publishing Wizard do the following:
    Go to – File then Publish
    Select SharePoint Server “ Publish form to a SharePoint Library”
    Enter location of your SharePoint or InfoPath Forms Services Site: 
    accept the default in this field from the first published event
    Next screen, keep the default or change it, Form Library, Site Content Type or Admin Approved
    Next screen, What do you want to do?
    Create a new form library
    Add new document library name and description
    Next screen, Remove all promoted fields not applicable to the new library and add all of the ones you want to see data for.
    Click Next and Publish
    Come back into the form: If you don’t have buttons added directly to the form to submit or update, add them.
    Create a new Action rule on the button
    Label the rule to keep it straight
    Condition, occurs when button clicked
    Add action, Submit data
    Use data connection to the second library created
    Create a second new Action rule on the same button
    Label the rule to keep it straight
    Condition, occurs when button clicked
    Add action, Submit data
    Use original data connection to the library
    Then you can add another action to close the form or do whatever you need.
    Republish the form to both libraries to set the template for both.
    File – Publish – SharePoint Server
    Select Secondary library from drop down follow the rest of the prompts
    Follow step 5a again, select Primary library from drop down, Add back in all of the promoted fields needed for the primary library and follow the prompts.
    DOCUMENT YOUR FORM WELL FOR MAINTENANCE
    Special considerations, your primary library needs a unique ID to reference in your secondary library.
    Your secondary library will need a unique ID that is not related to the primary if you are going to store multiple records for a single primary library reference. 
    Example: One form, multiple updates.

  • How to create Infopath form that auto populate data from one list to be fill by another user?

    hi.  I would like to ask, how to create form that fill by User A, for example, and then the User A assigned task to User B to complete the form. Next, the form will be approved by approver. May I know how to do
    that? and if possible, I do not want to use any programming code.
    Azuaniza Ariffin

    Hi,
    If your SharePoint environment supports InfoPath Forms, then you can customize the form and add rules to make the list items as read only when user A submits the form.
    you can then write a form load event to check the logged in user using username() function. This logic can be implemented in variety of ways, like setting a flag when User A submits the form, or storing user A username in a form variable etc., else comparing
    User A and User B values within form Load event.
    Another way of doing this is using Views or grouping all of the User A fields within a section etc.,
    The above would take care of Form logic, and for the workflow, you can use SharePoint designer to create a custom workflow, where it will run on onItemCreate and onItemChange events.
    The logic for workflow would be if the form Submitted for the first time, the workflow will start and send an email to User B, and when User B submits the Data then onItemChange change event will start the workflow to send an email to approver to approve
    the data.
    here are some links for your reference -
    http://office.microsoft.com/en-us/infopath-help/add-formulas-and-functions-in-infopath-2010-HA101821255.aspx
    http://office.microsoft.com/en-us/videos/video-create-an-approval-workflow-in-sharepoint-designer-2010-VA101897477.aspx
    http://blogs.technet.com/b/meacoex/archive/2010/11/01/get-manager-approval-in-sharepoint-designer-2010-step-by-step.aspx
    Hope this helps!
    Ram - SharePoint Architect
    Blog - SharePointDeveloper.in
    Please vote or mark your question answered, if my reply helps you

  • How to close a Form in LWUIT

    Hi,
    How do I close a form in LWUIT and go back to the form that opened it? There is no close or dispose command. There is a setVisible command
    but I don't seem to know how to use it. It doesn't seem to have any effect when used on a form. I have even tried to call show() on the form that
    opened the form I am trying to close. That doesn't work either.

    altayli wrote:
    I fixed it by converting Vector to Array..Thank you all
    Array -- do you mean java.util.ArrayList object from Java SE? are you going to use it in j2me MIDP application?

  • How to close a form within script

    Hello,
    I'm using Adobe LiveCycle Designer v 8.2 to develop an Order form. I'm fairly new to developing in LiveCycle, and would like to ask the following question that I couldn't find an answer to elsewhere.
    I'd like to know if it is possible to close a form down within a script, if certain conditions are met/not met. Specifically, when my form loads I am testing the user's version of Acrobate Reader. If it is not above the stated version, I would like the form to close down. At the moment, it displays the warning message correctly but then continues to try and load the form.
    I guess the JavaScript equivalent of Me.Close() is what I am after
    if 
    (xfa.host.version < 8.101){
    xfa.host.messageBox("Your version of Adobe Acrobat Reader is not recent enough to use this form.",
    "Wrong version of Adobe Acrobat", 1);//Code to close form to go here
    Can anyone help?
    Thanks
    Matt

    You will be able to close the form but you will not be able to close the Reader application. The command you want is event.target.closeDoc(). This will close the currently active Document. Note that if you are diosplaying in a browser then it will not close the doc ....it will only work form the Reader/Acrobat applications.
    Paul

  • How to close PDF form in Browser

    Hi,
    Does anyone knows if there are any way to close a PDF form that is opened in a browser (Internet Explorer 6)?
    In my form, there is a button that is supposed to close the form when clicked, it is working if I launched the form in Reader but does not work in a browser.
    The script that I used in the click event of the button is:
    event.target.closeDoc();
    Thank you.

    Hi,
    heres the code
    1. Go to <Your Webdynpro project> - WebDynpro - Web Dynpro Components - <your component> - Windows right click and create a window (PdfWindow).
    2. Place the view that contains pdfForm in the window PdfWindow.Create a button in the view say ClosePdf .
    3. Create a context attribute say WindowInstance of type com.sap.tc.webdynpro.clientserver.window.Window (java native type) in the component controller.Map this attribute to the context of both views (view with button and Pdfview)
    3. In the onAction of button
    IWDWindowInfo windowInfo = (IWDWindowInfo) wdComponentAPI.getComponentInfo().findInWindows("PdfWindow");
    IWDWindow window = wdComponentAPI.getWindowManager().createWindow(windowInfo,true);
    window.setWindowPosition(500, 500);
    window.show();
    wdContext.currentContextElement.setWindowInstance(window); // this iwll bw used to destroy the pop up
    4. In Pdfview create a action closepopup and associate with button ClosePdf. In the action write
    IWDWindow window = wdContext.currentContextElement.getWindowInstance();
    window.destroy(); // this will close the popup.
    Note:
    you dont need wdContext.currentContextElement().setPdfVisible(WDVisibility.VISIBLE); as your pdfform is in different view.
    Message was edited by:
            Shriram Kabra

  • How to have Infopath form use Sharepoint Domain credentials

    I have built a for in infopath which is published to a library on Sharepoint 2013. This form is filled out by certain users and when its completed it gets moved into a subfolder. We then provide a link to a client who has a domain account with restricted
    access to just this folder of sharepoint. They can view this form and any others we put in this folder.
    The form has 2 views. The first is the view our staff sees when filling it out. There are some hidden sections in there for us that the client does not need to see. So there is a second view which is read only and I have taken away the option for them to
    switch views so they can't go back to our internal view.
    What I would like to happen is that the form can somehow detect by the domain login info from sharepoint, what user is opening the form and switch views based on that. What I can't figure out how to do it to have the form pull domain credentials from the
    sharepoint site and use those a a variable when opening the form to set the view.
    I believe I am on the right path what trying to setup a data connection but I am just missing something. I found this great guide http://www.pointgowin.com/seethepoint/Lists/Posts/Post.aspx?ID=55 but now when I open the form I get a warning stating "You
    do not have permissions to access a SharePoint list that contains data required for this form to function correctly." Also I still can't seem to pull the username.
    Can someone help me out? Point me in the right direction? Thanks.

    Hi,
    According to your post, my understanding is that you wanted to have Infopath form use Sharepoint Domain credentials.
    When you use Claims-based authentication, your user name is prefaced by “0#.w|”.  So for example, if your user name is SuesDomain\jdoe then your Claims-based user token will be, without
    the quotes:     “0#.w|SuesDomain\jdoe”
    InfoPath can’t handle that, or more specifically, the UserProfile.asmx method GetUserProfileByName method can’t handle that.  InfoPath tries to pass in your Claims-based user token instead
    of your domain\User Name.
    You have an authentication problem where the currently logged in user is not allowed to hit the web service, so you get an Access Denied 401 authentication error
    To resolve the issue, you can refer to the great blog:
    SharePoint 2013, InfoPath and Claims – GetUserProfileByName
    More information:
    InfoPath over Claims Authentication (SharePoint 2010 & 2013)
    SharePoint 2013 Business Connectivity Services Search and Profile PageMetroStar Systems Blog
    Thanks,
    Linda Li
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Linda Li
    TechNet Community Support

  • How to open multiple forms through differnt responsiblity

    I have a 11.5.10.2 system on Linux red hat.
    Business pepole want to open multiple forms through different responsiblities from multiple web brower sessions.
    However when I opened 2 IE brower sessions, log into responsiblity and open one oracle form in one IE session and log into another responsiblity through second IE session. The first opened form disappear and replaced by the second oracle form opened from another IE session. That means only one Oracle form can be open at the same time for this case.
    The current walkaround solution is to open 2 browser sessions using 2 different browsers ( one is IE another is Firefox) to fix this issue. Apparently this is not a good solution.
    Can you please give me some suggestion to fix this issue?

    Thank you very much for the information.
    The note mention:
    The new forms launcher does not support opening multiple forms applets for the same database across different responsibilities. Opening a form in another responsibility will cause any forms currently open to close. This behaviour is standard.
    However it is possible to enable users to open multiple forms sessions for the same database for the same responsibility when using MS Internet Explorer as the client browser. This is made possible with Patch 3293241. This patch is included in Oracle Applications release 11.5.10 as standard.
    My current system is 11.5.10.2. I verified that patch 3293241 has been applied. I have no problem to open mutiple forms with in SINGLE web brower session, within same responsibility. I am aware that you can not open multiple forms through SINGLE web brower session through multiple responsiblity. What I tried to do is to open mutiple forms through multiple web browers sessions. Open one brower session, log into system and open a form, then open another web brower session, log into the sytem and open a form through different responsiblity. The system does not allow me to open multiple forms through multiple web brower sessions. Only the latest form can be displayed. Is this standard design for 11.5.10?
    Can Form Servlet architecture solve this limitation?
    Actually afterI changed some form funcation paramter in Oracle Application Developer responsiblity, I can open 2 form session from 2 different responsiblities through 2 web brower sessions. I can open one form session as Application Developer and another form session through another responsiblity. Then I can switch to other responsiblity through Application Developer responsiblity to open forms.
    Is there any other way I can open multiple form sessions to the same database through multiple web brower sessions?
    Thanks a lot for your help
    Edited by: wcxtao on Nov 3, 2008 9:47 AM
    Edited by: wcxtao on Nov 3, 2008 9:57 AM
    Edited by: wcxtao on Nov 3, 2008 10:08 AM

  • How to enable infopath form service in sharepoint

    Hi,
    I am using Infopath designer 2013.
    When i am opening Sharepoint List, after mentioning its url its giving me following error:
    How can i enable infopath form service.
    please help to solve the issue.
    Thanks in advance!
    Regards
    rajni

    Hello,
    It seems enterprise feature is not activated to your site, not CA. Please go to your site Site Settings/Site Collection Administration/Features and activate the SharePoint Server Enterprise Site Collection features.
    See this thread for your ref:
    http://social.technet.microsoft.com/Forums/sharepoint/en-US/5225cb4a-f981-49b5-ac1c-e3c832bcf79d/this-feature-requires-sharepoint-server-2010-or-greater-with-infopath-forms-services-enabled?forum=sharepointgeneralprevious
    Hope it could help
    Hemendra:Yesterday is just a memory,Tomorrow we may never see
    Please remember to mark the replies as answers if they help and unmark them if they provide no help

  • How to publish infopath forms to open new and old form templates in sharepoint2007

    Hi All,
    My requirement is , we are having a form library with the Infopath form templated(V1) published.
    Then we have added about 300 items using template(v1) into the sharepoint library.
     Then client asked for the changes in form and we deveploped infopath template (V2) and published, able to create the items using the new template(v2).
    But ,the issue is when we open item from the 300 items which are created with template(v1), its is opening using template(v2) and we are loosing the functionality of template(v1).
    Can i know ,how to publish the form template to use both template versions and it should open the form with  wahatever the  template it used for creation.
    Thanks in Advance.
    Anil Kumar K

    Hi,
    If you want the InfoPath forms for displaying the items in the list, then I recommend to click Customize Form button in the ribbon of the list to edit the form in InfoPath and then publish the form back to SharePoint.
    After that, you will see there are three new forms(displayifs.aspx, editifs.aspx, newifs.aspx) when you view the list in SharePoint Designer.
    Then you can create the custom action to navigate to the custom InfoPath form:
    Thanks,
    Victoria
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Victoria Xia
    TechNet Community Support

Maybe you are looking for