FSI API: Data Objects

fsi.getDataKey

fsi.getDataKey(); Returns the SystemId of the current row in a data object.

fsi.setDataKey

fsi.setDataKey(<SystemId string>); Sets the current row in a data object to that matching the supplied SystemId.

fsi.selectDataObject

fsi.selectDataObject(<data object name>, <where>, <successCallBack>, <errorCallBack>, <completeCallBack>, <subTenantIds>); Returns an array of data from the data object specified.

Definitions

{String} data object name

{Object} where

{Function} successCallBack, errorCallBack, completeCallBack

{Array} subTenantIds.

Notes

If subTenantIds is not specified, the rows returned will be all of those where the SubTenantId is valid for the user.

Example

This simple example returns data in an array from a data object named 'Apps' for the user's valid SubTenant Id(s).

// success callback
var success = function (data){
                         var myApps = JSON.parse(data.result);
                         //Display the data in a text area for testing:
                         fsi.setById('dataObjData', JSON.stringify(myApps));
};
  
// error callback 
var error = function() {      
  fsi.log('Reading data object Failed');
};

// complete callback
var complete = function() {      
  fsi.log('Reading data object Completed');  
};

// read data from data object
function selectDataObject(){
    fsi.selectDataObject('Apps', '', success,error,complete, ''); 
}

Where condition

This variation introduces a where condition on a data object field called 'name'.

var where={};
where.AppName='MyApplicationName';
// read data from data object
function selectDataObject() {
  fsi.selectDataObject('Apps', where, success, error, complete);
}

Specifying SubTenantId

See also User subtenant information in FSI API: User Details.

This variation returns rows for the specified user's SubTenantIds.

// read data from data object
var SubTenIds = [541,564];
function selectDataObject() {
  fsi.selectDataObject('Apps', '', success, error, complete, SubTenIds);
}

fsi.deleteDataObject

fsi.deleteDataObject(<data object name>,<systemId>,<successCallBack>,<errorCallBack>); Deletes the row specified by systemid from the data object.

Definitions

{String} data object name

{String} systemId

{Function} successCallBack, errorCallBack

fsi.createDataObject

fsi.createDataObject(<data object name>,<values>,<successCallBack>,<errorCallBack>,<subTenantId>); Creates a new row in an existing data object.

Definitions

{String} data object name

{Array} values Name/value pairs specifying the data object columns and values. See example below.

{Function} successCallBack, errorCallBack

{String} subTenantId

Notes

  • If subTenantId is not specified, the user's default will be used.
  • A user can only specify a subTenantId that is assigned to them.
  • If the data object being updated is a child in a one-to-many relationship, or the link object in a many-to-many relationship, the foreign keys must be expressed as SystemID. You cannot use the value that the system displays for convenience ( Parent Display Field or Child Display Field.

Example

var values = [
       { name: 'Surname', value: 'Davis' },
       { name: 'Forename', value: 'James' },
        { name: 'Address_1', value: '4, The Street' },
        { name: 'Address_2', value: 'Romford' },
        { name: 'Address_3', value: 'Essex' },
        { name: 'Postcode', value: 'RM10 9XF' }
      ];

function createDataObj() {
  fsi.createDataObject('MyDataObject', values, successCallBack, errorCallBack, subTenantId);
}

fsi.updateDataObject

This is similar to fsi.createDataObject above, except that you specify the SystemID of the row in the data object that you want to update.

fsi.updateDataObject(<data object name>,<values>,<successCallBack>,<errorCallBack>); Creates a new row in an existing data object.

Definitions

{String} data object name

{Array} values Name/value pairs specifying the data object columns and values. See example below.

{Function} successCallBack, errorCallBack

Notes

If the data object being updated is a child in a one-to-one or one-to-many relationship, the Child Binding Field: (foreign key) must be expressed as the parent object's SystemID. You cannot use the value that the system displays for convenience (the Parent Display Field setting).

Example

In a real world case the SystemID for the row to be updated would be available from preceding operations, and not hard-coded as in this simple example.

var sysid = '10e903a3-2aae-4c5e-91b0-ab44a32490d3';
var values = [
       { name: 'Surname', value: 'Davis' },
       { name: 'Forename', value: 'James' },
        { name: 'Address_1', value: '4, The Street' },
        { name: 'Address_2', value: 'Romford' },
        { name: 'Address_3', value: 'Essex' },
        { name: 'Postcode', value: 'RM10 9XF' },
        {name: 'SystemID', value: sysid}
      ];

function updateDataObj() {
  fsi.updateDataObject('MyDataObject', values, successCallBack, errorCallBack);