I am working on a fairly complex system right now, and the task I am currently stuck on is the creation of a document using JavaScript. I have a form library created with Infopath, and I would like to be able to create a semi-blank form from my JavaScript code. I don't need to do much with it- essentially just copy the template and alter some metadata. Does anyone know how to do this? I have been searching online for information, but I haven't come up with much.


I wouldn't recommend trying to manipulate the SharePoint InfoPath viewer, I would insert any code needed directly into the InfoPath form template before publishing to SharePoint. From there you can setup your pre-populate conditions among other things. Beware however, web enabled InfoPath forms cannot do everything that regular InfoPath forms can do. It all depends on what exactly you are trying to accomplish.

  • Btw - The reason I wouldn't recommend manipulating the InfoPath using java-script this way is because I believe that if your form changes or gets updated, keeping your code and your form working together will get messy over time. Aug 16 '13 at 16:58
  • For Example <input type="text" onfocus="return (TextBox.OnFocus(this, event));" onblur="return (TextBox.OnBlur(this, event));" oninput="return (TextBox.OnInput(this, event));" id="ctl00_ctl29_g_6f49e1c8_c19d_4d31_91a8_1a70eff54cc9_FormControl0_V1_I1_S3_I1_T3" scriptclass="TextBox" class="am_RhRPkLWFeQkVhSbL_0 bk_RhRPkLWFeQkVhSbL_0 fh_RhRPkLWFeQkVhSbL_0" wrapped="true" aria-invalid="true" "="" direction="ltr" viewdatanode="8" formid="ctl00_ctl29_g_6f49e1c8_c19d_4d31_91a8_1a70eff54cc9_FormControl0" originalid="V1_I1_S3_I1_T3" tabindex="0" title="" value="" style="position: relative;" -- etc Aug 16 '13 at 17:02
  • I'm actually not trying to work with the InfoPath viewer- I am working on a scheduling system. When a manager schedules a user, it should create a travel request form for them, which they will then need to fill out. I am simply trying to create a blank form automatically from my JS code.
    – Crash
    Aug 16 '13 at 17:49
  • Okay, What I would do is create a page with an Info-path form web part, we can call it "Page B". This will give you a blank form for the travel request. From the page where the manager schedules a user, "Page A", you have the JavaScript redirect them to "Page B". Since you want it to be "semi-blank" you will have to pass the data from "Page A" via some global variables or through the query string. I still see the same problem however, your InfoPath <input> tags get auto id's, this will become problematic in the future. Aug 16 '13 at 18:32
  • I would use, instead of javascript to pass the value, code in the InfoPath form to read from the query string. Like the following example: blogs.msdn.com/b/infopath/archive/2010/06/03/… Aug 16 '13 at 18:34

It could be done also in workflow initiation form, but be carufull. By modifications to IniWrkflIP.aspx page you make changes globally. If you need to get the ID of the current item, your hit on this page makes sense, so what do you give and what does not make sense is on your consideration...
Get context data at the Workflow Start form

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.