Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

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 = ...;
    ApplicationQuery query = service.CreateApplicationQuery(null);
    ApplicationFeed apps = service.Query(query);
    foreach (ApplicationEntry app in apps.Entries)
    {
            Console.WriteLine("App: " + app.Title.Text);
            // ...
    }

...

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?

First get a hold of the corresponding UserEntry for the desired user, and then use the users ApplicationFeed.

...

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

The following additions only exist in the .net client api version 5.1.1 Patch 3

 

How do I rename an application?

...

Code Block
FormsService formsService = ....;          
ApplicationEntry entry = ....;          
string fileName = ....;          
 
Stream contentStream = formsService.QueryContent(entry.Content);   
 
//if the Application needs to be written to a file:
using (FileStream fileStream = File.Create(fileName))
{
    contentStream.CopyTo(fileStream); 
} 

  

After I found a ApplicationEntry for the first time can I get the entry directly?

If you have an entry id you can retrieve the entry directly.

...

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 the correct anformtype entry

NameValueCollection nvc = string 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 src="{formInstanceUrl}"></script> 

This will embed the form instance in your page inside an <iframe/>. 

Note
  • The method FormTypeEntry.CreateFormInstanceEmbed(NameValueCollection, params MediaSource[]) is only available in .Net Client API version 5.1 Patch 3 and later.
  • See this documentation for more information about available URL parameters.

 


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 entry
    string 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)?

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 formtype = formtypes.CreateEntry();
    formtype.Title.Text = name;
    formtype.Summary.Text = description;
    formtype = formtypes.Insert(formtype);
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 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 = ...;
    ApplicationEntry app = ...; // 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 ApplicationEntryformtype app = ...;entry

// findrequest anall applicationdata come back as part FormTypeFeedof formtypesthe = app.FormTypeFeed;submit response 
NameValueCollection linkParams = FormTypeEntry formtype = formtypes.CreateEntrynew NameValueCollection();
    formtype.Title.Text = namelinkParams.Add("_formActionDocs", "true");  
  formtype.Summary.Text = descriptionlinkParams.Add("_data","{FirstName:TestA,LastName:TestB}");

FormEntry formEntry  formtype = formtypesformTypeEntry.Insert(formtype);
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 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 = ...;
    ApplicationEntry app 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 = ...; // findcreated anwith applicationthe _formActionDocs param set to FormTypeFeedtrue
formtypes
= app.FormTypeFeed;
    FormTypeEntry template IList<MultipartContentElement> responseData = formEntry...; // find template formtype entrySubmitInstance();

foreach (MultipartContentElement part //in modifyresponseData)
key{
template properties    string template.Title.TextdispositionType = namepart.ContentDispositionType;
     template.Summary.Textstring name = descriptionpart.Name;
    FormTypeEntry string formtypecontentType = formtypes.Insert(template);

How do I create a form instance?

 Use the code below to create a form instance: 

Code Block
FormsService service = ...;part.ContentType;
     string contentTransferEncoding = part.ContentTransferEncoding;
     string iddata = "_LIAtYHC3EeKVINiYeE5iPA!_qrSmgInoEeKOdqjLR19yFQ!test1"; 
FormTypeEntry formType = service.GetFormType(id); 
FormEntry form = formType.CreateFormEntry(); part.DataPayload;
}
Note
  • The method FormEntry.SubmitInstance() will return null if the FormEntry was not created with the _formActionDocs parameter set to true.
  • The method FormEntry.SubmitInstance() is only available in .Net Client API version 5.1 Patch 3 and later.


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

...

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
  • The method FormTypeEntry.CreateFormEntry(NameValueCollection, Stream) is only available in .Net Client API version 5.1 Patch 3 or later.
  • See this documentation for more information about available URL parameters.

...

Note
  • The method FormTypeEntry.CreateFormEntry(NameValueCollection, params MediaSource[]) is only available in .Net Client API version 5.1 Patch 3 or later.
  • See this documentation for more information about available URL parameters.


How do I edit a form control?

Suppose you have a form with controls named A and B.  Further, suppose the form is initially empty, and you wish to programmatically set the control values to TestA and TestB respectively.  First you have to get a hold of the form instance (see 'How do I create a form instance?).

Code Block
FormEntry form = ...;

ControlEntry controlA = form.FindControlEntry("A");
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.

...