• No results found

Creating a folder in a library and submitting a form

N/A
N/A
Protected

Academic year: 2021

Share "Creating a folder in a library and submitting a form"

Copied!
9
0
0

Loading.... (view fulltext now)

Full text

(1)

PDF SHARE FORMS

Online, Offline, OnDemand

PDF forms and SharePoint are better together

Creating a folder in a library

and submitting a form

(2)

Content

PDF Share Forms Enterprise for SharePoint 2013 ... 2

Static (Acro) and Dynamic (XFA) forms ... 2

PDF Share Forms Enterprise for SharePoint 2010 ... 5

Static (Acro) form ... 5

Dynamic (XFA) form ... 7

“Execute C# script” action’s script in the Form Submit rules ... 9

This guide shows how to create a folder with a user-selected name and submit a form into this folder. Method contains server-side and client-side scripting.

PDF Share Forms Enterprise for SharePoint 2013

Static (Acro) and Dynamic (XFA) forms

This approach works both for static and dynamic forms. Step 1. Template

“Submit” – button for form submitting;

(3)

Step 2. Add “Execute C# script” action before “Save Form” action in Form Submit rules. Navigate to Developer → Form Submit

Script

if (form.IsNew()) {

var unsafeUpdate = currentWeb.AllowUnsafeUpdates; currentWeb.AllowUnsafeUpdates = true;

var folderName = data.resolveNode("TextField2").Value; var getExisting =

currentWeb.GetFolder(String.Format("{0}/YourListName/"+data.resolveNode("TextField2").Value, currentWeb.Url)); //this line of code searches for a folder by its name

//. If the folder does not exist then a new folder is created and the form will be submitted into it

if(!getExisting.Exists){

SPList list = currentWeb.Lists["YourListName"];//list name should be specified for a proper case

SPListItem folder = list.AddItem(list.RootFolder.ServerRelativeUrl, SPFileSystemObjectType.Folder, folderName);

folder.Update();

data.GetSystemField("FolderID").Value= folder.UniqueId.ToString(); }

//if the folder exists then the form issubmitted into it

else data.GetSystemField("FolderID").Value= getExisting.UniqueId.ToString(); currentWeb.AllowUnsafeUpdates = unsafeUpdate;

(4)

Step 4. Open new form and add value to “TextField2”.

Click submit.

(5)

PDF Share Forms Enterprise for SharePoint 2010

Static (Acro) form

Step 1. Template

“SubmitButton1” – button for form submitting;

“TextField2” – value from this field is used to set a name of the target folder.

Step 2. Add “Execute C# script” action before the “Save Form” action in Form Submit rules. Navigate to Developer → Form Submit

(6)

Step 3. Add “JavaScript action” to the submit button. Choose the button and navigate to PDF Form Tools → Properties → Actions → place “JavaScript action” above “Submit to SharePoint” action.

Script

this.getField("PDFSPSystemData").value =

this.getField("PDFSPSystemData").valueAsString.replace("\\\"RootFolder\\\":\\\"/YourRootFolder\\\" ","\\\"RootFolder\\\":\\\"/YourRootFolder/"+this.getField("TextField2").value+"\\\"");

This code changes submit URL to save form into newly created folder.

NOTE: “YourRootFolder” is a part of your site`s library URL. For example: /sites/demo/Guides Step 4. Deploy the template.

Step 5. Create a new form and fill in the “TextField2”.

Submit the form.

(7)

Dynamic (XFA) form

Step 1. Create template

“SubmitButton1” – button for form submitting;

“TextField2” – value from this field is used to set the name of a target folder.

Step 2. Add “Execute C# script” action before the “Save Form” action in Form Submit rules. Navigate to Developer → Form Submit

(8)

Step 3. Add “Execute script” action to the submit button. Choose button and navigate to PDF Form Tools → Properties → Actions → place “Execute script” action above “Submit to SharePoint” action.

Script

xfa.resolveNode("$data..SPSupportData").value=xfa.resolveNode("$data..SPSupportData").value.replac e(/"RootFolder":(["'])(\\?.)*?\1/g,"\"RootFolder\":\"/YourRootFolder/"+xfa.resolveNode("$data..Tex tField2").value+"\"");

This code changes submit URL to save form into newly created folder.

NOTE: “YourRootFolder” is a part of your site`s library URL. For example: /sites/demo/Guides Step 4. Deploy the template.

Step 5. Create a new form and fill in “TextField2”.

Submit the form.

(9)

“Execute C# script” action’s script in the Form Submit rules

if (form.IsNew()) {

var unsafeUpdate = currentWeb.AllowUnsafeUpdates; currentWeb.AllowUnsafeUpdates = true;

var folderName = data.resolveNode("TextField2").value; var getExisting =

currentWeb.GetFolder(String.Format("{0}/YourListName/"+data.resolveNode("TextField2").Value, currentWeb.Url));//this line of searches for a folder by its name

// If the folder does not exist then a new folder is created and the form will be submitted into it

if(!getExisting.Exists){

SPList list = currentWeb.Lists["YourListName"];//list name should be specified for a proper case

SPListItem folder = list.AddItem(list.RootFolder.ServerRelativeUrl, SPFileSystemObjectType.Folder, folderName);

folder.Update();

data.GetSystemField("FolderID").Value= folder.UniqueId.ToString(); }

//if the folder exists then form is submitted into it

else data.GetSystemField("FolderID").value= getExisting.UniqueId.ToString(); currentWeb.AllowUnsafeUpdates = unsafeUpdate;

}

This script checks if the folder with the name that is taken form “TextField2” already exists. If the folder exists then the form will be submitted to the existing folder. If the folder does not exist then a new folder is created and the form will be submitted into it.

Back to guide – static form Back to guide – dynamic form

References

Related documents

• the name, business address, telephone number, facsimile number and e-mail address of each office or location of the Firm that engages in the practice of public accounting,

In furtherance thereof, the undersigned will not sell, hypothecate or otherwise transfer the undersigned's Shares unless the Shares are registered under the Act and qualified

[r]

4 More recently, witch- iconography present in Andrew Chumbley’s grimoire Azoëtia utilises several ancient magical forms, notably the stele of the Near Eastern

Is going to a file for any values submitted via a form submit button to strings for online google forms... Event and web form result in our own cgi program running on script to

Press the shared folders across libraries you select some more libraries and artificial intelligence, just files and a name for each update the library; they cannot upload a

Submit the IELTS Academic Module Test Report Form, TOEIC Official Score Certificate (photo attached) or TOEFL Examinee Score Record (photo attached) at the time of application.

relative to 100% thrust at takeoff, (ii) analyse the relationship between thrust setting and aircraft TOW in order to quantify the distribution of engine thrust settings adopted