Skip to main content
Kinetic Community

Using Kinetic Objects

The various objects that the Kinetic Runtime API provides has a number of methods and properties. Important: Do not modify any properties. Changing them may have adverse affects on behavior and is not supported!

The Kinetic Object

The Kinetic object, or K provides high-level API access.

  • K(selector) - selects an object based on a selection criteria. See Using Kinetic Selectors for more information.
  • K.select(selector) - an alternative way to execute object selections.
  • K.api(method, path, options) - executes an asynchronous API call and safely updates the form display upon completion. It takes 3 arguments:
    • method - string name of the method, e.g. 'GET'
    • path - the URL or path to access.
    • options - a jQuery-compatible AJAX options config.
  • K.reset() - completely resets the Kinetic object. Useful for kapp-level pages embedding forms dynamically.
  • K.as(form) - given a Kinetic Form object execute API functionality as that form. Used primarily in embedded and child forms.
  • K.use(form) - this advanced method is used to change the current active form to the Form object provided.
  • K.load(options) - asynchronously load an embedded form. See Using Subforms for more information.

Note: The K.ready() function is not the same as the ready function provided in the bundle customization object. This method is a reserved method that should only be called by Core Edition generated code.

The Field Object

The Field object has a number of useful methods defined on it for form and kapp developers.

Important Notes:

Some of the functions which correspond to conditions specified within the builder may cause conflicts. For example if you define a "Visible" condition in the builder of "Hidden" and then call the show method, eventually the form will self-correct and hide the field again. Functions which fall into this criteria are: hideshowdisableenablerequired, and optional. In many cases leaving these conditions to their default state should allow you use the functions in JavaScript event code.

Toggling whether the field is optional or required does not affect the server-side field constraint validations. If you force a required field to be optional on the client-side and then submit the page the server will return with constraint violations.

  • K('field[Field Name]').name() - returns the name of the field.
  • K('field[Field Name]').type() - returns the field type, one of: text, radio, date, datetime, checkbox, dropdown, attachment (note the returned type is all lower case).
  • K('field[Field Name]').form() - returns the Form object that the current field belongs to.
  • K('field[Field Name]').allowsMultiple() - returns true or false for attachments, undefined for non-attachment fields.
  • K('field[Field Name]').element() - returns the DOM element representing the field's input element(s).
  • K('field[Field Name]').wrapper() - returns the DOM element representing the div which contails the field's DOM elements (labelinput, etc.)
  • K('field[Field Name]').value(newValue) - sets the field value to newValue.
  • K('field[Field Name]').value() - returns the current value of the field.
  • K('field[Field Name]').hide() - hides the current field.
  • K('field[Field Name]').show() - displays the current field.
  • K('field[Field Name]').disable() - sets the field to be disabled.
  • K('field[Field Name]').enable() - sets the field to be enabled.
  • K('field[Field Name]').required() - sets the field to be required.
  • K('field[Field Name]').optional() - sets the field to be optional.
  • K('field[Field Name]').options() - returns the options DOM elements list for "dropdown", "checkbox", and "radio" fields. Returns an array of objects where each object contains a "label" and "value" key and the associated values for each key.
  • K('field[Field Name]').options(newOptions) - given an array of objects with a "label" and "value" key create new options DOM elements for the field.
  • K('field[Field Name]').validate() - runs field constraint validations and returns an array of errors (one for each violation) or an empty array if it is a valid field.

The Form Object

The Form object is at the core of the form behavior. It provides a number of useful methods for manipulating the form and properties about the form.

  • K('form').slug() - returns the slug of the current form.
  • K('form').name() - returns the name of the current form.
  • K('form').reviewMode() - returns true if the form is being rendered in review mode.
  • K('form').embeddedMode() - returns true if the form is currently embedded.
  • K('form').element() - returns the form DOM element representing the current form.
  • K('form').find(selector) - given a jQuery-style selector, find DOM elements within this form. Takes subforms into consideration, this find will not return a subform's element(s).
  • K('form').serialize() - returns a serialized object representing the fields and values for the current page.
  • K('form').validate() - executes client-side constraint validation for all fields on the current page. It returns an object with keys representing fields with violations and an array of violation messages.
  • K('form').basePath() - returns the path the base of the REST API.
  • K('form').kappPath() - returns the REST API path for the kapps resource.
  • K('form').formPath() - returns the REST API path for the forms resource.
  • K('form').submissionPath() - returns the REST API path for the current submission.
  • K('form').save() - performs the "Save for Later" action. Note: this does not enforce constraints does not attempt to advance the page.
  • K('form').submitPage() - performs the "Submit Page" action.
  • K('form').previousPage() - performs the "Previous Page" action.

The Bridged Resource Object

The Bridged Resource object provides access to dynamically load data from bridges.

The bridged resource load method takes an options object as an argument. This object has the following properties:

  • attributes - an array of attributes that you want returned.
  • values - a map of values referenced by your bridged resource parameters.
  • success - a function called when the bridged resource request is complete.
    • Takes one argument, the bridged data.
  • error - a function called when there is an error encountered while processing the bridged resource request.
    • Takes one argument, the error response from the server.

Here is an example bridged resource load:

    // Load a bridged resource named 'People' that has no parameters:
    K('bridgedResource[People]').load({
        attributes: ['First Name', 'Last Name', 'Login Id']
        success: function(bridgedData) {
            // Do something with the bridged data response.
            // For example:
            console.log(bridgedData.records);
        }
    });

    // Load a bridged resource named 'Person' that has a parameter. The
    // parameter is configured to reference the value of the Login ID field,
    // which is defined in the Form Builder:
    K('bridgedResource[Person]').load({
        attributes: ['First Name', 'Last Name'],
        values: {'Login ID' : 'Allen'},
        success: function(bridgedData) {
            console.log(bridgedData.record);
        }
    });

In addition to the load method you can call these other methods:

  • K('bridgedResource[People]').name() - returns the name of the bridged resource.
  • K('bridgedResource[People]').type() - returns the bridged resource type, either "Single" or "Multiple"
  • K('bridgedResource[People]').dependencies() - returns an array of field names which are used in parameters.
  • K('bridgedResource[People]').attributes() - returns an array of values which will be returned from the bridge.

The Page Object

The page object provides information about the current form page. It has the following functions:

  • K('page').id() - returns the current page ID.
  • K('page').name() - returns the current page name.

The Section Object

The section object provides information about a section on the current page. It has the following functions:

  • K('section[Section Name]').name() - returns the name of the section.
  • K('section[Section Name]').element() - returns the DOM element representing the section.
  • K('section[Section Name]').hide() - hides the section, respecting the omit values behavior.
  • K('section[Section Name]').show() - shows the section, respecting the omit values behavior.

As documented with other object types the hide and show behavior is conditional and may be superseded by the form's behavior.

The Button Object

The button object provides information about a button on the current page. It has the following functions:

  • K('button[Submit Button]').name()- returns the button name.
  • K('button[Submit Button]').element() - returns the DOM element representing the button.
  • K('button[Submit Button]').hide() - hides the button.
  • K('button[Submit Button]').show() - shows the button.
  • K('button[Submit Button]').disable() - enables the button.
  • K('button[Submit Button]').enable() - disables the button.

As documented with other object types the hideshowenable, and disable behavior is conditional and may be superseded by the form's behavior.

The Content Object

The content object provides information about a content field on the current page. It has the following functions:

  • K('content[Content Name]').name() - returns the content field’s name.
  • K('content[Content Name]').element() - returns the DOM element representing the content field.
  • K('content[Content Name]').show() - shows the content field.
  • K('content[Content Name]').hide() - hides the content field.

As documented with other object types the hide and show behavior is conditional and may be superseded by the form's behavior.

The Kapp Object

  • K('kapp').name() - returns the kapp name.
  • K('kapp').slug() - returns the kapp slug.

The Space Object

  • K('space').name() - returns the space name.
  • K('space').slug() - returns the space slug.

The Submission Object

  • K('submission').id() - returns the submission ID or null if a new submission.
  • K('submission').value(fieldName) - returns the value from a field that was on a previous page.