Create first form

In order to get your first form up and running, you will need to implement a few functions inside your ninox database.

saveOrUpdateForm

In order to perform updates to your ninox database, Ninoxbee needs a few information so that all its interactions with your ninox instance is bound to the context of that database.

The mandatory fields needed are

  • The Host on which your instance is running. Use app.ninoxdb.com for public cloud databases.

  • The API Key to perform updates on your database

  • The TeamId in which your database is installed

  • The DatabaseId of the application in which you will be performing updates.

Ninoxbee allows you to define a few other extra skinning variables. The code block below shows all the possible values for the form creation api call to ninoxbee.

Adjust the function below to externalise settings into a settings table

function saveOrUpdateForm(form:Form) do
	let _ninoxHost := "anastasia.ninoxdb.com";
	let _ninoxApiKey := "YOUR_NINOX_API_KEY";
	let _captchaProtect := false;
	let _teamId := teamId();
	let _databaseId := databaseId();
	let _askUntilDate := date(2024,1,1);
	let _startAcceptingDate := today();
	let _ninoxbeeHost := "https://app.ninoxbee.com";	
	let _body := {
			host: _ninoxHost,
			apiKey: _ninoxApiKey,
			teamId: _teamId,
			databaseId: _databaseId,
			introFn: "_myIntroFn",
			initFn: "_myInitSessionFn",
			summaryFn: "_myGetSummary",			
			nextFn: "_myGetNextQuestionFn",
			prevFn: "_myGetPreviousQuestionFn",
			answerFn: "_myAnswerQuestionFn",
			buttonTextFn: "_myButtonTextFn",
			captcha: _captchaProtect,
			pinCode: "" + a.'Pin Code',
			askUntil: "" + format(_askUntilDate, "YYYY-MM-DD"),
			enabled: true,
			startDate: "" + format(_startAcceptingDate, "YYYY-MM-DD"),
			introImgUrl: "URL TO A PUBLIC IMAGE TO DISPAY ON INTRO SCREEN",
			basicSkinning: {
				logoUrl: "URL TO FORM LOGO,
				headerTitle: "TITLE OF THE FORM IN HEADER",
				headerBgColor: "#000000",
				headerFgColor: "#FFFFFF"
			},
			languages: [{
					code: "fr",
					name: "Français",
					languageOrder: 1
				}],
			advancedSkinning: null,
			formExpiredMessage: "This form has expired,
			pincodeErrorMessage: "Invalid pincode",
			formNotOpenYetMessage: "Form not open",
			formNotPublishedMessage: "For not published"
		};
	if form._FORM_ID = null then
		let response := do as server
				http("POST", _ninoxbeeHost + "/api/v1/forms", {
					'x-auth': "_YOUR_NINOXBEE_APIKEY",
					'content-type': "application/json"
				}, _body)
			end;
		a.(_FORM_ID := response.result.result.uuid);
		a.(_FORM_URL := response.result.result.publicUrl)
	else
		let response := do as server
				http("PUT", nbHost() + "/api/v1/forms/" + a._FORM_ID, {
					'x-auth': s.'Ninoxbee Api Key',
					'content-type': "application/json"
				}, _body)
			end;
		void
	end
end;

introFn and initFn

This function is responsible of rendering the first card or the landing screen card. It is displayed after the captcha protection.

When this function is invoked by ninoxBee, a card shows on ninoxbee portal displaying the title and the description as well as a start button. Hitting the start button invokes a call on ninox which generates a session object in which all future interactions will be attached.

The submissionId returned above should be generated by your ninox database. It will be submitted by ninoxbee automatically for all the remaining calls. Using this submissionId you should be able to identify which user is attached to this form and submit the answers to the correct record.

Ninoxbee ninox app

Open the downloaded Ninoxbee app from your workspace, and start configuring your API Key. The API key can be found in your Ninoxbee Portal.

Register your new Key in Ninoxbee Ninox app

One you've registered your key, click on the key line. The app will automatically retrieve all active forms for that Api-key.

Forms attached the api key

In the Key view, you can preview the attached forms and Manage your Stripe subscription page.

Create a new form or click on an existing form.

New form creation

A form in Ninoxbee is a scafolding object for generating forms dynamically from your Ninox database. Give your form a title and hit Save. Ninoxbee assigns you a unique ID and a URL to access that form.

A unique ID is auto-generated for your form

At this stage of the process your form is still not accessible; clicking on the generated link should return you a "The form is not published yet" error page.

Ninoxbee features an Intro view securely hosted within its configuration. For enhanced security, API calls to your Ninox database are initiated only after successful completion of the captcha challenge on your form.

The following table lists the available options to get your form up and running

Field
Description
Options
Required

Title

The title of the form which appears on the top bar of the page.

Text

Password Protection

Whether this form is protected or fully public

None : The form is not protected Pin : The form is protected by a unique Pin code OTP : The form is protected by an OTP Pin code sent to the end user directly

Pincode Error Message

The error message that should show up if pin was incorrectly set

Required if a protection is set

Captcha

Protect abuse of this form by enforcing the end user to solve a Captcha question

true | false

Start accepting submissions from

The starting date for accepting answers on this form. Leave blank to start accepting answers as soon as form is published

Datetime

Ask Until

The date after which the form should be considered closed for answers. Leave blank for never ending acceptance forms

Datetime

Published

Whether the form is published or not.

true | false

Form not open yet message

The message that should appear in case form is not yet open

Text

Form Expired message

The message that should appear in case form has expired

Text

Form not published yet message

The message that should appear if the form is not published

Text

Intro Image

Cover image of the form. Appears before the first question is asked and before the captcha is solved (no api calls to your ninox instance at this stage).

Image

Intro Title

Cover image of the form. Appears before the first question is asked and before the captcha is solved (no api calls to your ninox instance at this stage).

Text

Host

The host on which your ninox database is hosted

Text

Ninox API Key

The API key to invoke actions on your ninox database

Text

TeamId

The teamId on which your business ninox database is hosted

Text

DatabaseId

The database id of your ninox business app

Text

Init Session function name *

Name of the function in your business app that will 'init' the session

Text

Next question function name *

Name of the function in your business app that will fetch the next question based on a current questionId

Text

Previous question function name *

Name of the function in your business app that will fetch the previous question based on a current questionId

Text

Answer function name *

Name of the function in your business app that will receive the answer from Ninoxbee and fetch the next question

Text

Logo File

Image of the logo appearing on the top left side of the form

Image

Background color

Color

Foreground color

Color

Now that you've configured your forms let's take a look at the 4 main function you need to implement in your app to interact with this form.

Last updated