Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

The FAQs provide some examples and code snippets for common tasks when a third-party application wants to interact with the server.

...

Table of Contents
maxLevel1

Note

In v9.1 and later ' "Applications" are known as "Projects," and "Themes" are known as "Styles." The API objects and methods still use the words application, 'app', and theme.

How do I login and logout to and from a server?

...

Since there is some overhead associated with logging in and out, you need to keep the FormsService instance around for as long as you need to interact with  before logging out.

How do I get the list of all

...

projects for the current user?

Code Block
    FormsService fs = ...;
    URL appFeedUrl = fs.getFeedURL(ApplicationFeed.class);
    ApplicationFeed appFeed = fs.getFeed(appFeedUrl, ApplicationFeed.class);
    for(ApplicationEntry appEntry: appFeed.getEntries()){
        System.out.println("Application Name: " + appEntry.getTitle().getPlainText());
    }

...

Code Block
    FormsService fs = ...;
    URL ftFeedUrl = fs.getFeedURL(FormTypeFeed.class);
    FormTypeFeed ftFeed = fs.getFeed(ftFeedUrl, FormTypeFeed.class);
    for(FormTypeEntry ftEntry: ftFeed.getEntries()){
        System.out.println("FormType Name: " + ftEntry.getTitle().getPlainText());
    }

How do I get the list of all forms for a given

...

project?

The code snippet below prints the name of all forms in the appEntry application:

...

Code Block
    FormsService fs = ...;
    URL schemaFeedUrl = fs.getFeedURL(SchemaFeed.class);
    SchemaFeed schemaFeed = fs.getFeed(schemaFeedUrl, SchemaFeed.class);
    for(SchemaEntry schemaEntry: schemaFeed.getEntries()){
        System.out.println("Schema Name: " + schemaEntry.getTitle().getPlainText());
    }

How do I get the list of all schemas for a given project

...

?

The code snippet below prints the name of all schemas in the appEntry application:

Code Block
    ApplicationEntry appEntry = ...;
    SchemaFeed themeFeedschemaFeed = appEntry.getSchemaFeed();
    for(SchemaEntry schemaEntry: schemaFeed.getEntries()){
        System.out.println("Schema Name: " + schemaEntry.getTitle().getPlainText());
    }

...

This is often needed when you need to relate an  form with another concept your application project (e.g. you application project 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):

...

First you have to get a hold of the form feed from an existing applicationproject. See How do I get the list of all forms for a given applicationproject?

Code Block
    FormsService fs = ...;
    ApplicationEntry appEntry = ...;
    FormTypeFeed ftFeed = appEntry.getFormTypeFeed();
    FormTypeEntry newEntry = ftFeed.createEntry();
    newEntry.setTitle(new PlainTextConstruct("MyForm"));
    newEntry.setSummary(new PlainTextConstruct("MyForm Description"));
    newEntry = ftFeed.insert(newEntry);

...

Note

You can only insert into a feed that has an explicit owner, which is guaranteed above by getting the FormTypeFeed from the ApplicationEntry as opposed to getting a FormTypeFeed containing forms for all applicationsprojects.

 


How do I download an existing form?

...

Code Block
    FormsService fs = ...;
    ApplicationEntry appEntry = ...; // find app entry
    FormTypeEntry ftEntry = ...; // find template form entry 
    MediaContent mc = (MediaContent) ftEntry.getContent();
    MediaSource ms = getService().getMedia(mc);
    OutputStream formStream = new FileOutputStream("myform_form.zip");
    saveFormToDisk(ms.getInputStream(), formStream);

How do I upload a form into an existing

...

project?

You can also upload a form that was previously downloaded using the following code snippet:

...

      3. Upload the users csv file:  

Code Block
curl http://host:port/frevvo/web/tn/tenant.id/allUsers  -F notificationEmailAddress=some_email_address -F usersFile=@users_file.csv  -X POST  -b cookies -H Content-Type:multipart/form-data

...

You can specify who receives an email reporting the upload status when it is done through the API. The email is sent to the "notificationEmailAddress" that is passed in the API. The email may say something like this if there are errors during the upload:

Code Block
Validation occurred with errors. Users data NOT loaded. Refer to attached CSV data file for validation and/or loading result details.

...