...
Note that when you login, the .NET client API initializes a local security token based on your credentials. It does not actually make a call however, until you make your first request. At that time, the forms service will attempt to authorize you based on your token. In the above example, the first call is for the user entry.
The LoginAs method for an existing user:
This new method allows you to login as any of the existing tenant users provided you can pass in the tenant's admin user and password. This is quite convenient when you want login using the same user that is logged into your application without having to know their password.
Code Block |
---|
IDictionary<string, string> customParams = new Dictionary<string, string>(); customParams.Add("autoLogin", "true"); FormsService service = new FormsService("http://localhost:8082", "yourappname"); service.LoginAs( "myuser", "tenantAdminUserName@myTenantName", "tenantAdminPassword", false, null, null, null, null, customParams); UserEntry user = service.GetUser(“myuser”); // interact with frevvo service.Logout(); |
The LoginAs method for a new/undefined user:
When your tenant is configured with the Delegating Security Manager, you can use the loginAs() method to automatically create new/virtual users.
...
Note |
---|
When you login, the .NET client API initializes a local security token based on the supplied credentials. It does not actually make a call however, until the first request is executed. At that time, the forms service will attempt to authorize the user based on the provided token. In the above examples, the first call is for the user entry. |
How do I get the list of all applications for the current user?
...
Code Block |
---|
FormsService service = ...; FormTypeQuery query = service.CreateFormTypeQuery(null); FormTypeFeed themesformTypes = service.Query(query); foreach (ThemeEntryFormTypeEntry formType in formTypes.Entries) { Console.WriteLine("Form Type: " + formType.Title.Text); } |
...
Code Block |
---|
ApplicationEntry app = ...; // find the right application app.Delete(); |
How do I upload an Application for a specific user?
...
Code Block |
---|
string fileName = ....; string appName = ....; FormsService formsService = ....; MediaFileSource source = new MediaFileSource(fileName, ApplicationFeed.MEDIA_SOURCE_TYPE); ApplicationQuery query = formsService.CreateApplicationQuery(null); ApplicationFeed apps = formsService.Query(query); ApplicationEntry app = apps.CreateEntry(); app.MediaSource = source; app = apps.Insert(app); |
Note |
How do I rename an application?
...
Then using the formInstanceUrl above you can generate the following script iframe tag in your html page:
Code Block |
---|
<script type="text/javascript" <iframe src="{formInstanceUrl}"></script>> |
This will embed the form instance in your page inside an <iframe/>.
How do I get
...
This is often needed when you need to relate a form with another concept your application (e.g. you application has the concept of a report that has an associated form). In this case you will store the form id somewhere and when needed fetch the form entry to embed it in your page, delete it, etc.
Here is how you get the for a form entry (in fact any entry):
...
the url to return the form instance embed java script?
First get a hold of the corresponding FormTypeEntry and then get the url as shown in the snippet below:
Code Block |
---|
FormTypeEntry formType = ...; // find anthe entrycorrect formtype entry NameValueCollection stringnvc formTypeId = formType.Id.Uri; |
Here you can associate the formtype id with your application objects and retrieve the corresponding entry at any time as follows:
Code Block |
---|
string formtypeId = "....";
FormTypeEntry formtype = service.GetFormType(formtypeId); |
How do I delete a form (or any other entry)?
...
new NameValueCollection();
nvc.Add("_data", "{TextArea3:TestTestTest}");
Uri formInstanceEmbedUri = formType.CreateFormInstanceEmbed(nvc, null);
String formInstanceUrl = formInstanceEmbedUri.AbsoluteUri; |
Then using the formInstanceUrl above you can generate the following script tag in your html page:
Code Block |
---|
<script FormTypeEntry formType = ...;type="text/javascript" formType.Delete; |
How do I create a new form?
First you have to get a hold of the form feed from an existing application. See How do I get the list of all forms for a given application?.
Code Block |
---|
FormsService service = ...; ApplicationEntry app src="{formInstanceUrl}"></script> |
This will embed the form instance in your page inside an <iframe/>.
Note |
---|
|
How do I get a form entry based on a known id?
This is often needed when you need to relate a form with another concept your application (e.g. you application has the concept of a report that has an associated form). In this case you will store the form id somewhere and when needed fetch the form entry to embed it in your page, delete it, etc.
Here is how you get the for a form entry (in fact any entry):
Code Block |
---|
FormTypeEntry formType = ...; // find an applicationentry FormTypeFeedstring formtypesformTypeId = appformType.Id.FormTypeFeed;Uri; |
Here you can associate the formtype id with your application objects and retrieve the corresponding entry at any time as follows:
Code Block |
---|
string FormTypeEntry formtypeformtypeId = formtypes.CreateEntry(); formtype.Title.Text = name"...."; formtype.Summary.Text = description; FormTypeEntry formtype = formtypesservice.InsertGetFormType(formtypeformtypeId); |
Note |
How do I delete a form (or any other entry)?
By calling the delete method on the FormTypeEnty.
Code Block |
---|
FormTypeEntry formType = ...;
formType.Delete; |
How do I create a new form
...
?
First you have to get a hold of the form feed from an existing application. See How do I get the list of all forms for a given application?.
Code Block |
---|
FormsService service = ...; ApplicationEntry app = ...; // find an application FormTypeFeed formtypes = app.FormTypeFeed; FormTypeEntry templateformtype = formtypes...CreateEntry(); // find template formtype entry // modify key template properties template.Title.Text = name; templateformtype.Summary.Text = description; FormTypeEntry formtype = formtypes.Insert(templateformtype); |
Note |
---|
When inserting the original formtype variable will not' be updated and the updated entry will be returned by the Insert method. |
How do I create a
...
Use the code below to create a form instance:
...
new form using an existing one as a template?
The only difference between creating a new form and creating a new one based on an existing form is that instead of using the entry created by calling 'ftFeed.createEntry()' you will be using an existing form entry. Find an existing form entry, update its name and description and use that entry to insert into a feed. Do not override the entry id otherwise the insert will fail.
Code Block |
---|
FormsService service = ...; string ApplicationEntry idapp = "_LIAtYHC3EeKVINiYeE5iPA!_qrSmgInoEeKOdqjLR19yFQ!test1"; FormTypeEntry formType = service.GetFormType(id); FormEntry form = formType.CreateFormEntry(); |
How do I pre-populate values when creating an instance?
When creating a form instance, you can supply data to pre-populate fields. There are a couple of ways to do this. The first way is to supply a name value collection, which holds control names and values. The second way is to supply an XML document, with control names and values. Suppose your form has two text fields, named A and B respectively. Also, suppose you wish to prefill these 2 controls with values, as shown:
Example 1 – using a name value collection
This example uses a special parameter named _data. The value carries a formatted string containing the form values, as shown below.
Code Block |
---|
...; // find an application
FormTypeFeed formtypes = app.FormTypeFeed;
FormTypeEntry template = ...; // find template formtype entry
// modify key template properties
template.Title.Text = name;
template.Summary.Text = description;
FormTypeEntry formtype = formtypes.Insert(template); |
How do I create a form instance?
Use the code below to create a form instance:
Code Block |
---|
FormsService service = ...;
string id = "_LIAtYHC3EeKVINiYeE5iPA!_qrSmgInoEeKOdqjLR19yFQ!test1";
FormTypeEntry formType = service.GetFormType(id);
FormEntry form = formType.CreateFormEntry(); |
How do I create a form instance in edit mode?
Code Block |
---|
FormsService service = ...;
string id = "_LIAtYHC3EeKVINiYeE5iPA!_qrSmgInoEeKOdqjLR19yFQ!test1";
FormTypeEntry formType = service.GetFormType(id);
FormEntry formEntry = formType.CreateEditingFormEntry(); |
Note |
---|
The method FormTypeEntry.CreateEditingFormEntry is only available in .Net Client API version 5.1 Patch 3 and later. |
How do I save edits to a form instance that was created in edit mode?
Code Block |
---|
FormTypeEntry formType = ...;
FormEntry formEntry = formType.CreateEditingFormEntry();
//make edits to form
formEntry.SubmitEdit(); |
Note |
---|
The method FormEntry.SubmitEdit is only available in .Net Client API version 5.1 Patch 3 and later. |
How do I cancel edits to a form instance that was created in edit mode?
Code Block |
---|
FormTypeEntry formType = ...;
FormEntry formEntry = formType.CreateEditingFormEntry();
//make edits to form
formEntry.SubmitEdit(false); |
Note |
---|
The method FormEntry.SubmitEdit is only available in .Net Client API version 5.1 Patch 3 and later. |
How do I create a form such that the document set is returned when the form is submitted?
First get a hold of the corresponding FormTypeEntry and then specify the _formActionDocs parameter as true when creating the FormEntry.
Code Block |
---|
FormTypeEntry formTypeEntry = ...; // find the correct formtype entry
// request all data come back as part of the submit response
NameValueCollection linkParams = new NameValueCollection();
linkParams.Add("_formActionDocs", "true");
linkParams.Add("_data","{FirstName:TestA,LastName:TestB}");
FormEntry formEntry = formTypeEntry.CreateFormEntry(linkParams); |
Note |
---|
The _formActionDocs parameter is only supported by .Net Client API version 5.1 Patch 3 and later. |
How do I receive the document set (including attachments) for the Form when submitted?
Code Block |
---|
FormEntry formEntry = ...; // created with the _formActionDocs param set to true
IList<MultipartContentElement> responseData = formEntry.SubmitInstance();
foreach (MultipartContentElement part in responseData)
{
string dispositionType = part.ContentDispositionType;
string name = part.Name;
string contentType = part.ContentType;
string contentTransferEncoding = part.ContentTransferEncoding;
string data = part.DataPayload;
} |
Note |
---|
|
How do I pre-populate values when creating an instance?
Example 1 – using a name value collection
This example uses a special parameter named _data. The value carries a formatted string containing the form values, as shown below.
Code Block |
---|
FormsService service = ...;
NameValueCollection nvc = new NameValueCollection();
nvc.Add("_data", "{A:TestA,B:TestB}");
string id = "_LIAtYHC3EeKVINiYeE5iPA!_qrSmgInoEeKOdqjLR19yFQ!test1";
FormTypeEntry formType = service.GetFormType(id);
FormEntry form = formType.CreateFormEntry(nvc);
|
Example 2 – using an XML document
This example uses an XML document. The document structure contains the form values which are to be applied, as shown below.
Code Block |
---|
<ns:form xmlns:ns="http://www.frevvo.com/schemas/_lvxDAF_vEd2bxNL8keLevQ"
name="FormTypeAtomTest">
<A>TestA</A>
<B>TestB</B>
</ns:form>
FormsService service = ...;
using (FileStream docStream = File.Open(@"C:\temp\_data.xml", FileMode.Open))
{
string id = "_LIAtYHC3EeKVINiYeE5iPA!_qrSmgInoEeKOdqjLR19yFQ!test1";
FormTypeEntry formType = service.GetFormType(id);
FormEntry form = formType.CreateFormEntry(docStream);
}
|
Example 3 – using link parameters and an XML document
Code Block |
---|
<ns:form xmlns:ns="http://www.frevvo.com/schemas/_lvxDAF_vEd2bxNL8keLevQ"
name="FormTypeAtomTest">
<A>TestA</A>
<B>TestB</B>
<C>2013-06-30</C>
</ns:form>
FormsService service = ...;
NameValueCollection nvc = new NameValueCollection();
nvc.Add("_formTz", "Asia/Kolkata");
using (FileStream docStream = File.Open(@"C:\temp\_data2.xml", FileMode.Open))
{
string id = "_LIAtYHC3EeKVINiYeE5iPA!_qrSmgInoEeKOdqjLR19yFQ!test1";
FormTypeEntry formType = service.GetFormType(id);
FormEntry form = formType.CreateFormEntry(nvc, docStream);
}
|
Note |
---|
|
Example 4 – using link parameters and multiple files
Code Block |
---|
<ns:form xmlns:ns="http://www.frevvo.com/schemas/_lvxDAF_vEd2bxNL8keLevQ" name="FormTypeAtomTest"> <A>TestA</A> <B>TestB</B> <C>2013-06-30</C> </ns:form> <p0:form xmlns:p0="http://www.frevvo.com/schemas/_RErWMNR6EeKYJfUGgkkEjg"> <Section518> <Name>test1</Name> </Section518> </p0:form> FileStream customerDataXml = new FileStream(file1_path,FileMode.Open); FileStream signText = new FileStream(file2_path, FileMode.Open); FormsService service = ...; NameValueCollection nvc = new NameValueCollection(); nvc.Add("_data", "{A:TestA,B:TestB}formTz", "Asia/Kolkata"); string id = "_LIAtYHC3EeKVINiYeE5iPA!_qrSmgInoEeKOdqjLR19yFQ!test1test2"; FormTypeEntry formType = service.GetFormType(id); FormEntry formformEntry = formType.CreateFormEntry(nvc); |
Example 2 – using an XML document
This example uses an XML document. The document structure contains the form values which are to be applied, as shown below.
Code Block |
---|
<ns:form xmlns:ns="http://www.frevvo.com/schemas/_lvxDAF_vEd2bxNL8keLevQ"formTypeEntry.CreateFormEntry(nvc, name="FormTypeAtomTest"> <A>TestA</A> <B>TestB</B> </ns:form> FormsService service = ...; using (FileStream docStream =new File.Open(@"C:\temp\_data.xml", FileMode.Open)) {MediaFileSource(customerDataXml, "customer", "application/xml"), string id = "_LIAtYHC3EeKVINiYeE5iPA!_qrSmgInoEeKOdqjLR19yFQ!test1"; FormTypeEntry formType = service.GetFormType(id); new FormEntryMediaFileSource(signText, "form = formType.CreateFormEntry(docStream); } ", "application/xml")); customerDataXml.Dispose(); signText.Dispose(); |
Note |
---|
|
How do I edit a form control?
...
Code Block |
---|
FormEntry form = ...; ControlEntry controlA = form.FindControlEntry("A"); controlA.Value = "TestA"; ControlEntry controlB = form.FindControlEntry("B"); controlB.Value = "TestB"; "); controlA.Value = "TestA"; ControlEntry controlB = form.FindControlEntry("B"); controlB.Value = "TestB"; |
Warning |
---|
Objects, of any kind, that are part of a Flow cannot access the list of controls for the Flow. Attempted access of FormTypeEntry.ControlTypeFeed, FormTypeEntry.ControlTypeFeedLink, FormEntry. ControlFeed, or FormEntry.ControlFeedLink will result in a NotSupportedException. |
How do I submit a form?
First you have to get a hold of the form instance (see 'How do I create a form instance?). When you are finished editing your form, you may submit it as follows:
...
Code Block |
---|
FormEntry form = ...; SubmissionEntry submission = form.Submit(); using (Stream file = File.OpenWrite("C:\temp")) { submission.PrintFormInstance(file); } |
Warning |
---|
Printing objects of any kind that are part of a Flow is not supported and will result in a NotSupportedException. |
How can I save a form for working on later?
...
Now you have a new form named My Purchase Order Form and you have the purchase order element added to the Data Source pane in the Designer. Using the designer, expand the Data Source pane and click the plus button to auto-generate the form controls (note that the API will be expanded to support auto generating controls).
I added a DocumentType from a Schema to my FormType
...
. Why do I see two
...
DocumentTypes?
Every FormType always has 1 default DocumentType that cannot be removed. This is the DocumentType managed by and updated when controls from the palette are added or removed from the form. For this DocumentType the Delete() method will fail (you can check whether a DocumentType can be deleted or not using the entry's ReadOnly property).
...
Code Block |
---|
FormTypeEntry ft = ...; ft.DeployState = DeployState.Production; // or ft.DeployState = DeployState.Development; |
How
...
do I copy a form?
Copying entails inserting an existing entry into a feed. The key difference between this case and a regular feed insert() is that the entry being inserted already has an id: this will trigger a copy.
...