FAQ - .Net Client API

onPhase Forms latest - This documentation is for onPhase Forms v11.3. Not for you? Earlier documentation is available too.

FAQ - .Net Client API

On this page:

In v9.1 and later frevvo's "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/logout to/from a Form server?

The direct method for an existing user: See the C# code snipped below:

FormsService service = new FormsService("http://localhost:8082", "yourappname"); service.Login("myuser", "mypassword"); UserEntry user = service.GetUser(“myuser”); // interact with frevvo service.Logout();

Note that when you log in, 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 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 useful when you want to log in using the same user that is logged into your project without having to know their password.

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.

IDictionary<string,string> customParams = new Dictionary<string, string>(); customParams.Add("autoLogin", "true"); //customParams.Add("updateNonDesigners", "true"); //if user is not a frevvo.Designer, this must be set for user to be officially 'created' otherwise user is truly virtual/temporary string[] roles = { "frevvo.Designer" }; FormsService service = new FormsService("http://localhost:8082", "yourappname"); service.LoginAs( "newUserName", "tenantAdminUserName@myTenantName", "tenantAdminPassword", true, roles, //optional param – may be null. Specified roles will be created if necessary. When null, a non-designer user (able to participate in workflows but not create workflows/forms) will be created if necessary. "newUserFirstName", //optional param – may be null "newUserLastName", //optional param – may be null "newUserEmailName@EmailServer.com", //optional param – may be null customParams); UserEntry user = service.GetUser("newUserName"); // interact with frevvo service.Logout();

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 projects for the current user?

FormsService service = ...; ApplicationQuery query = service.CreateApplicationQuery(null); ApplicationFeed apps = service.Query(query); foreach (ApplicationEntry app in apps.Entries) { Console.WriteLine("App: " + app.Title.Text); // ... }

How do I get the list of all themes for the current user?

All references to Themes have been removed in version 5.3. This example does not pertain to frevvo 5.3 or later.

FormsService service = ...; ThemeQuery query = service.CreateThemeQuery(null); ThemeFeed themes = service.Query(query); foreach (ThemeEntry theme in themes.Entries) { Console.WriteLine("Theme: " + theme.Title.Text); }

How do I get the list of all forms for the current user?

FormsService service = ...; FormTypeQuery query = service.CreateFormTypeQuery(null); FormTypeFeed formTypes = service.Query(query); foreach (FormTypeEntry formType in formTypes.Entries) { Console.WriteLine("Form Type: " + formType.Title.Text); }

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:

ApplicationEntry app = ...; // find the right application FormTypeFeed formTypes = app.FormTypeFeed; foreach(FormTypeEntry formType in formTypes.Entries) { Console.WriteLine("Form Type: " + formType.Title.Text); }

How do I get the list of all schemas for the current user?

SchemaQuery query = service.CreateSchemaQuery(null); SchemaFeed schemas = service.Query(query); foreach (SchemaEntry schema in schemas.Entries) { Console.WriteLine("Schema: " + schema.Title.Text); }

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:

ApplicationEntry app = ...; // find the right application SchemaFeed schemas = app.SchemaFeed; foreach (SchemaEntry schema in schemas.Entries) { Console.WriteLine("Schema: " + schema.Title.Text); }

How do I create a project?

FormsService fs = ....; ApplicationQuery query = fs.CreateApplicationQuery(null); ApplicationFeed apps = fs.Query(query); ApplicationEntry app = apps.CreateEntry(); app.Title.Text = "My First App"; app = apps.Insert(app);

How do I find an existing project?

At this point you have to manually filter the entries in an ApplicationFeed. See the following snippet:

FormsService fs = ....; ApplicationQuery query = fs.CreateApplicationQuery(null); ApplicationFeed apps = fs.Query(query); foreach(ApplicationEntry app in apps.Entries) { if( app.Title.Text == "My First App" ) return app.Id.Uri; }

How do I delete a project?

ApplicationEntry app = ...; // find the right application   app.Delete();

How do I upload a project for a specific user?

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

string fileName = ....; UserEntry user = ....;   MediaFileSource source = new MediaFileSource(fileName, ApplicationFeed.MEDIA_SOURCE_TYPE);   ApplicationFeed apps = user.ApplicationFeed; ApplicationEntry app = apps.CreateEntry();   app.MediaSource = source; app = apps.Insert(app);

How do I upload a project?

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);

How do I rename a project?

String filename = ...; ApplicationEntry app = ...; // find the right application app.Title.Text = appName; app.Update();

The method ApplicationEntry.Update() is only available in .Net Client API version 5.1 Patch 3 and later.

How do I download a project?

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 an ApplicationEntry for the first time can I get the entry directly?

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

string appId = ...; FormsService fs = ....; ApplicationEntry app = fs.GetApplication(appId);

How do I get the URL to a form so it can be embedded in my HTML pages?

First get a hold of the corresponding FormTypeEntry, then get the form URL as shown in the snipped below:

FormTypeEntry formType = ...; // find the correct formtype entry string formTypeUrl = formType.FormTypeEmbedLink.AbsoluteUri;