Javascript API

Last Updated: 11 Nov 2020

The Javascript API (JS API) asset is used to enable the execution of core-level Squiz Matrix functions using JavaScript, allowing users to create, modify and retrieve content within the system. These functions are handled on the Details screen of the Javascript API asset. For more information, refer to the Details Screen section of this chapter.

Due to cross domain AJAX request and session restrictions, the JavaScript API should not be used if your configuration requires cross domain calls.

Once you have added a Javascript API asset, you can configure its settings on its associated asset screens. The majority of these screens are the same or similar to those for a Standard Page and are described in the Asset Screens manual. In this chapter, we will describe the Details screen, which is different for the Javascipt API.

Bookmarks

Details Screen

The Details screen allows you to configure the operation parameters and restrictions of the Javascript API. For more information about the Status, Future Status, Thumbnail and Details sections, refer to the Details Screen chapter in the Asset Screens manual.

Restrictions

This section allows you to set restrictions for the Javascript API operations.

The fields available are as follows:

  • Root Node: Select a root node to restrict the Javascript API to. This will limit the API's functions to that specific root node. For example, if your system contains two Sites, Site 1 and Site 2, selecting Site 1 in this field will only allow the Javascript API to access the content of that specific Site. To select additional Root Nodes, click the More… button. To delete a root node from the list, click the Clear button. This field is mandatory.
  • Asset Types to Create: Select asset types to restrict the assets that can be created by the createAsset operation. For example, selecting Cart in this field will mean that the createAsset operation will only be able to create Cart assets. To select more than one asset type, click on the More… button. An additional list will appear on the screen. To remove an asset type from the list, click the Clear button and click Commit.
  • Parent Types: Select asset types to restrict the assets that can act as parents when using creation, linking and moving operations. For example, selecting Site in this field will mean that an operation involving a parent asset, such as createAsset or createLink, will only allow the Javascript API to use Site assets as the parent asset.
  • Allow Attributes on Create: Select whether or not additional attributes can be added when creating assets using the createAsset operation. If this field is set to Yes, the attribute parameter of the createAsset operation can be used to define attributes to be added. For example, a News Item asset can be created with the attribute parameter as contact_name=John&contact_phone=01234. This will set the Contact name attribute of the News Item to John and the Contact phone attribute to 01234. By default, this field is set to No.
  • Return JSON: Select whether or not to return result codes via JSON in response to the Javascript API's operations. You may choose to disable the return of JSON to prevent users from being able to view information, such as asset IDs and attribute values, from certain operations. By default, this field is set to Yes.
  • Ignore Permissions: Select whether or not to ignore Permissions when creating assets using the createAsset, cloneAsset and createFileAsset operations. If this field is set to Yes, Permissions will not be checked when performing these functions. This means that a user without the appropriate Write Access would still be able to create an asset within the system. By default, this field is set to No.
  • Force Simple Edit: By default, the function calls of the Javascript API will act as if made on the Administration Interface of Squiz Matrix. This means that any generated URLs, for example, in a workflow email, will contain the _admin suffix. This field allows you to force function calls to act as if made in the Simple Edit Interface, meaning that any URLs generated by these calls would use the _edit suffix instead of the _admin suffix. By default, this field is set to No.
  • Use Enhanced JS API: Leave this as Yes. Setting it to No will use the Standard Mode on the JS API which has been deprecated as of version 5.1.0.0 and is a much inferior version.
  • Allow Batching Requests: The batchRequest operation. This operation allows you to group multiple functions on the JS API into a single request. By default, this field is set to No. For more information, refer to the Batching Requests section in this chapter.

API Settings

This section contains the API Key used for the Javascript API asset. The Squiz_Matrix_API construct defined on the API uses this key in order to allow the Javascript API assets to function.

For more information, refer to the Basic Javascript API Implementation chapter in this manual.

Core

This section displays the available Core operations.

The following operations are displayed in this section:

  • Create Asset: the createAsset and createFileAsset operations. The createAsset operation will create an asset in the system, while the createFileAsset operation will create a blank File type asset (PDF File, MP3 etc.) that users will be able to upload their file to.
  • Clone Asset: the cloneAsset operation. This will clone an asset under a specified parent.
  • Get General Info: The getGeneral and getChildCount operations. The getGeneral operation will return the general information of an asset, while the getChildCount operation will return a count of the number of direct children and/or dependants of an asset
  • Get Asset Types: the getAssetTypes operation. This will return the asset type codes of assets within the system.
  • Get Attributes: the getAttributes operation. This will return the attributes of an asset.
  • Set Attribute: the setAttribute and setMultipleAttributes operations. These will set either a single attribute value or multiple attribute values on an asset.
  • Get Lock Info: the getLocksInfo operation. This will return the general information of locks on an asset.
  • Acquire Lock: the acquireLock operation. This will acquire the lock of an asset screen (or update the lock if it has already been acquired by the user).
  • Release Lock: the releaseLock operation. This will release the lock of an asset screen.
  • Trash Asset: the trashAsset operation. This will send an asset to the Trash.
  • Get Keyword Replacements: the getKeywordsReplacements operation. This will return the standard and global keyword replacements of an asset.
  • Set Asset Status: the setAssetStatus operation. This will set the Status of an asset and its dependants (with the option of cascading the Status to child assets).
  • Get Asset WebPath(s): the getWebPath operation. This will return the web path(s) of an asset.
  • Set Asset WebPath: the setWebPath operation. This will set the web path of an asset.
  • Get Roles Information: the getRoles operation. This will return the roles of an asset.
  • Set File Content: the setContentOfEditableFileAsset operation. This will set the content of an editable File type asset (CSS File, XML File, Text File, XSL File, JS File). Please note that locks need to be acquired on the asset before setting content.
    • Update File Content: the updateFileAssetContent operation. This function is automatically enabled on the JS API details screen together with the Set File Content function. This will update the contents of a File type asset by passing the data in a base64 encoded string. Please note that locks need to be acquired on the asset before setting content.
  • Import Assets from XML: the importAssetsFromXML operation. This will import assets under a specified root node from a structured XML file.
  • Execute HTML Tidy: the executeHTMLTidy operation. This will execute HTML Tidy on the content of a passed string.
  • Show Content Differences: the showDifference operation. This will compare the content of two different assets.
  • Validate Active User: the validateActiveUser operation. This will validate a specified user and can optionally return the asset IDs of user groups the user belongs to.
  • Get File Indexing Components: the getFileIndexingComponents operation. This will fetch indexing contents for file assets that would normally be served by Apache. The returned data includes details about metadata values, file properties and permission details.
  • Sort Asset Children: the sortAssetChildren operation. This will sort child assets of a particular asset in a specific order and sorted by a specific value.

For the parameters required for each operation, refer to the Operation Parameters section of this chapter.

Linking

This section displays the available Linking operations.

The following operations are displayed in this section:

  • Create Link: the createLink operation. This will create a link in the system.
  • Remove Link: the removeLink and removeMultipleLinks operations. These will remove either a single link or multiple links between a parent and child asset.
  • Move Link: the moveLink operation. This will move a link from one parent to another.
  • Update Link: the updateLink and updateMultipleLinks operations. These will update either a single link or multiple links in the system.
  • Get Link Id: the getLinkId operation. This will return the link id between a parent and child asset.

For the parameters required for each operation, refer to the Operation Parameters section of this chapter.

Permissions

This section displays the available Permissions operations.

The following operations are displayed in this section:

  • Get Permissions: the getPermissions operation. This will return the permissions of an asset.
  • Set Permissions: the setPermission operation. This will set a User or User Group permission on a specified asset.

For the parameters required for each operation, refer to the Operation Parameters section of this chapter.

Workflow

This section displays the available Workflow operations.

The following operations are displayed in this section:

  • Get Workflow Schema: the getWorkflowSchema operation. This will return any applied or denied workflow schemas on an asset.

For the parameters required for each operation, refer to the Operation Parameters section of this chapter.

Traversing

This section displays the available Traversing operations.

The following operations are displayed in this section:

  • Get Parents: the getParents operation. This will return the parents of an asset.
  • Get Children: the getChildren operation. This will return the dependant, non-dependant and NOTICE linked children of an asset.
  • Get Asset Tree: the getAssetTree operation. This will return tree information for children of an asset.
  • Get Lineage: the getLineage operation. This will return the asset lineages of an asset.
  • Get Lineage From URL: the getLineageFromUrl operation. This will return the asset lineage of a specified URL.
  • Get URL From Lineage: the getUrlFromLineage operation. This will return the URL of an asset lineage.

For the parameters required for each operation, refer to the Operation Parameters section of this chapter.

Metadata

This section displays the available Metadata operations.

The following operations are displayed in this section:

  • Get Metadata: the getMetadata operation. This will return the metadata values of an asset.
  • Set Metadata: the setMetadata and SetMetadataAllFields operations. The SetMetadata operation will set a metadata value for an asset while the SetMetadataAllFields operation will set the metadata values of multiple fields for an asset.
  • Get Metadata Schema: the getMetadataSchema operation. This will return the details of the metadata schema(s) configured on an asset, including metadata fields and their attributes.
  • Edit Metadata Schema: the editMetadataSchema operation. This will set or unset a metadata schema on a specified asset.

For the parameters required for each operation, refer to the Operation Parameters section of this chapter.

Contexts

This section displays the Contexts operations.

The following operations are displayed in this section:

  • Get Contexts: the getAlternateContext, getCurrentContext and getAllContexts operations. These operations will return information on the Contexts configured on your system.
  • Set Context: the setContext and restoreContext operations. These operations will set the current Context on the system to either a specified context or to that which was previously set.
  • Sync Contexts: enabling this option will allow the Javascript API to correctly synchronise Context changes on both the frontend and backend, facilitating context-aware functionality from the API's operations.
  • Contextualise Asset: Enables the contextualiseAsset function which lets you contextualise an asset's attributes or metadata for a specific Context.

For the parameters required for each operation, refer to the Operation Parameters section of this chapter.

Google Analytics

This sections displays the Google Analytics operations.

The following operations are displayed in this section:

  • Get Google Analytics Statistics: the getGoogleAnalyticsStatistics function. This will allow you to make a request to a Google Analytics application to retrieve analytics data.

System Information

This sections displays the System Information operations, allowing you to retrieve information on your Squiz Matrix system, including user preferences and the Maintenance Mode status of your system. For more information, refer to the Global Preferences chapter in the System Configuration manual, and the Maintenance Mode chapter in the Concepts manual.

In this section, select Yes for the functions you want to make available on the API. You can use the Set All Field to either enable or disable all the functions in this section.

The following operations are displayed in this section:

  • Get System Information: the getSystemInformation function. This will allow you to retrieve the information on your system.

Form Questions

This section displays the Form Questions operations.

The following operations are displayed in this section:

  • Create Questions: the createQuestion function. This will allow you to create a new question on a Custom Form.
  • Update Questions: the updateQuestion function. This will allow you to update the field information of an existing question on a Custom Form.
  • Remove Questions: the removeQuestion function. This will allow you to remove a question from a Custom Form.
  • Update Question Order: the updateQuestionOrder function. This will allow you to update the order of the questions on a Custom Form.

For the parameters required for each operation, refer to the Operation Parameters section of this chapter.

Operation Parameters

The parameters of the operations managed by the Javascript API are detailed below.

createAsset

 ParameterCommentType
Requestparent_id
type_code
asset_name
link_type
link_value
sort_order
is_dependant
is_exclusive
extra_attributes
attributes
dataCallback
Parentid of the new parent
Type code of the new asset
Name for the new asset
Type of link to create*
Value of the link
Order in the tree
Dependant to parent
Exclusive to parent
Allows additional attributes
String of additional query string containing key/pair values** 
Custom callback function
integer
string
string
string/integer
string
integer
integer
integer
integer
string
function
Responsename
id
link_id
  

*NOTE: The link_type parameter can accept the value as a string or its integer value:

StringInteger
"SQ_LINK_TYPE_1"1
"SQ_LINK_TYPE_2"2
"SQ_LINK_TYPE_3"4
"SQ_LINK_NOTICE"8

**NOTE: This parameter requires the Allow Attributes on Create field enabled. For more information, refer to the Restrictions section of this chapter.

Example
js_api.createAsset({
   "parent_id":100,
   "type_code":"comment",
   "asset_name":"blog comment",
   "link_type":"SQ_LINK_TYPE_1",
   "link_value":"link value",
   "sort_order":1,
   "is_dependant":0,
   "is_exclusive":0,
   "extra_attributes":1,
   "attributes":"comment=comment goes here&rating=5.0",
   "dataCallback":customDataCallbackFunc
}) 

createFileAsset

 ParameterCommentType
RequestparentID
type_code
friendly_name
link_type
link_value
dataCallback
Parentid of the new parent
Type code of the new asset (defaults to 'File')
Name of the asset being created
Type of link to create for File asset*
Value of the link to create to parent for this new asset
Custom callback function
string
string
string
string/integer
string
function
Response
Example
{"123":"New File Asset (#123) 'File' of type_code 'pdf_file' created successfully"} 

*NOTE: The link_type parameter can accept the value as a string or its integer value:

StringInteger
"SQ_LINK_TYPE_1"1
"SQ_LINK_TYPE_2"2
"SQ_LINK_TYPE_3"4
"SQ_LINK_NOTICE"8
Example
js_api.createFileAsset({
   "parentID":"100",
   "type_code":"pdf_file",
   "friendly_name":"my-file",
   "link_type":"SQ_LINK_TYPE_1",
   "link_value":"link value",
   "dataCallback":customDataCallbackFunc
}) 

cloneAsset

 ParameterCommentType
Requestasset_id
new_parent
clone_name
clone_num
new_position
link_type
 
 
link_value
dataCallback
Asset ID of the asset to clone
Asset ID of the parent to clone under
Name for the new clone asset
Number of clones to create
Position to place newly created assets under the parent|
Link type of the cloned asset (SQ_LINK_TYPE_1, SQ_LINK_TYPE_2, SQ_LINK_TYPE_3, or SQ_LINK_NOTICE)
Link value of the cloned asset
Custom callback function
string
string
string
integer
integer
string
 
 
string
function
Response
Example
success => Home Page (#100) has been successfully cloned to #200, #204
assetid => 100
newParent => 200
clonedAssets => [object Object],[object Object]
0 => [object Object]
id => 200
link_id => 8463
name => Home Page
1 => [object Object]
id => 204
link_id => 8467
name => Home Page
 
Example
js_api.cloneAsset({
   "asset_id":"100",
   "new_parent":"240",
"clone_name":"name",   "clone_num":2,
   "new_position":1,
   "link_type":"SQ_LINK_TYPE_2",
   "link_value":"new value",
   "dataCallback":customDataCallbackFunc
})

getGeneral

 ParameterCommentType
Requestasset_id
get_attributes 
 
dataCallback
Id of the asset we are getting info for
If we are getting non standard attribute values of the assets (FALSE by default)
Custom callback function
string
boolean 
 
function
Responsename
short_name
id
type_code
type
icon_path
data_path
web_path
status
created
created_userid
created_username
updated
updated_userid
updated_username
published
published_userid
published_username
status_changed
status_changed_userid
status_changed_username
  
Example
js_api.getGeneral({
   "asset_id":"100",
   "get_attributes":1,
   "dataCallback":customDataCallbackFunc
}) 

getChildCount

 ParameteCommentType
Requestasset_id
level
dataCallback
Id of the asset to get children of
Number of levels to return, default all
Custom callback function
string
number
function
Responsechild_count  
Example
js_api.getChildCount({
   "asset_id":"100",
   "level":5,
   "dataCallback":customDataCallbackFunc
}) 

getAssetTypes

 ParameterCommentType
RequestdataCallbackCustom callback functionfunction
Response"asset_type" {
           type_code
           version
           name
           instantiable
            allowed_access
           parent_type
           dir
           customisation
           description
           lvl
                              }, ...
  
Example
js_api.getAssetTypes({
   "dataCallback":customDataCallbackFunc
}) 

getAttributes

 ParameterCommentType
Requestasset_id
dataCallback
Id of the asset we are getting info for
Custom callback function
string
function
Response
Example
{"name":"Home Page","short_name":"Home"} 
Example
js_api.getAttributes({
   "asset_id":"100",
   "dataCallback":customDataCallbackFunc
}) 

setAttribute

 ParameterCommentType
Requestasset_id
attr_name
attr_val
dataCallback
Id of the asset we are getting info for
Name of the attribute to change
Value to change the attribute to
Custom callback function
string
string
string
function
Response
Example
["Attribute "short_name" has been successfully set to "Home" for Asset "Home Page" (#1234)"] 
Example
js_api.setAttribute({
   "asset_id":"100",
   "attr_name":"name",
   "attr_val":"new title",
   "dataCallback":customDataCallbackFunc
}) 
js_api.setAttribute({
   "asset_id":"100",
   "attr_name":"html",
   "attr_val":"content",
   "dataCallback":customDataCallbackFunc
}) 

setMultipleAttributes

 ParameterCommentType
Requestasset_id
field_info (attr_name, attr_val)
dataCallback
Id of the asset we are getting info for
Attribute name and their respect value
Custom callback function
string
array
function
Response
Example
["Attribute "short_name" has been successfully set to "Home" for Asset "Home Page"(#1234)","Attribute ... ] 
Example
js_api.setMultipleAttributes({
   "asset_id":"100",
   "field_info":{
      "name":"New Name",
      "short_name":"New Short Name"
   },
   "dataCallback":customDataCallbackFunc
}) 

getLocksInfo

 ParameterCommentType
Requestasset_id
screen_name
dataCallback
Id of the asset to get locks for
The screen lock type to get locks for
Custom callback function
string
string
function
Response
Example
[""settings" locks are held by User "Root User" (#12) for Asset "Home" (#1234). This is due to expire in 3 minutes and 25 seconds"] 

Available screen name (lock types) that you can get lock info for are:

StringInteger
"settings"1
"attributes"2
"permissions"4
"links"8
"workflow"16
"metadata"32
"lookups"64
"roles"256
Example
js_api.getLocksInfo({
   "asset_id":"100",
   "screen_name":"settings",
   "dataCallback":customDataCallbackFunc
}) 

acquireLock

 ParameterCommentType
Requestasset_id
screen_name
dependants_only
force_acquire
 
dataCallback
Id of the asset to get locks for
The screen to get locks for
whether dependants only or all children, defaults to true
whether to attempt to forcibly acquire the lock of not, defaults to false
Custom callback function
string
string
boolean
boolean
 
function
Response
Example
[""settings" locks are now acquired for Asset "Home" (#1234)"] 
Example
js_api.acquireLock({
   "asset_id":"100",
   "screen_name":"metadata",
   "dependants_only":0,
   "force_acquire":1,
   "dataCallback":customDataCallbackFunc
}) 

The Details Screen of an Asset consists of both the Attributes and Links locks.

releaseLock

 ParameterCommentType
Requestasset_id
screen_name
dataCallback
Id of the asset to release locks for
The screen to release locks for
Custom callback function
string
string
function
Response
Example
[""settings" locks are now released for Asset "Home" (#1234)"] 
Example
js_api.releaseLock({
   "asset_id":"100",
   "screen_name":"links",
   "dataCallback":customDataCallbackFunc
}) 

trashAsset

 ParameterCommentType
Requestasset_ids
dataCallback
Id of the asset(s) to delete
Custom callback function
array / string
function
Response
Example
["Asset "Home" (#1234) successfully moved to Trash"] 
Example
js_api.trashAsset({
   "asset_ids":[
      "100",
      "101",
      "102"
   ],
   "dataCallback":customDataCallbackFunc
}) 

getKeywordsReplacements

 ParameterCommentType
Requestasset_id
keywords_array
null_if_empty 
 
dataCallback
Id of the asset to get replacements for
Array of keywords to get replacements for
Wether or not to return null for non-replaced keywords
Custom callback function
string
array
boolean 
function
Responsekeyword
      (e.g. "asset_assetid":"1234")
  
Example
js_api.getKeywordsReplacements({
   "asset_id":"100",
   "keywords_array":[
      "%asset_name%",
      "%asset_assetid%"
   ], "null_if_empty":true,
   "dataCallback":customDataCallbackFunc
}) 

setAssetStatus

 ParameterCommentType
Requestasset_id
status
cascade
 
workflow_stream
userlog
dataCallback  
Id of the asset to set the status of
The status the asset is to be set to
If to cascade the status to non-dependant children (false by default)
Workflow stream to be passed in
The user workflow log message
Custom callback function
string
integer
boolean
 
string
string
function
Response
Example
["Status for Asset "Home" (#1234) has been changed successfully to Live"] 

You can view the status numbers for the status parameter on the Squiz Matrix Concepts chapter of the Concepts manual.

Example
js_api.setAssetStatus({
   "asset_id":"100",
   "status":32,
   "cascade":1,
   "workflow_stream":"altstream",
"userlog":"log message",   "dataCallback":customDataCallbackFunc
}) 

getWebPath

 ParameterCommentType
Requestasset_id
dataCallback
Id of the asset to get web paths for
Custom callback function
string
function
Responsewebpath  
Example
js_api.getWebPath({
   "asset_id":"100",
   "dataCallback":customDataCallbackFunc
}) 

setWebPath

 ParameterCommentType
Requestasset_id
paths
auto_remap
dataCallback
Id of the asset to get web paths for
New web paths to be assigned to asset
If to auto-remap (default to True)
Custom callback function
string
array
boolean
function
Responsewebpath  
Example
js_api.setWebPath({
   "asset_id":"100",
   "paths":[
      "about-us",
      "about",
      "info"
   ],
   "auto_remap":1,
   "dataCallback":customDataCallbackFunc
}) 

getRoles

 ParameterCommentType
Requestasset_id
role_id
user_id
include_assetid
include_globals
 
expand_groups
 
 
inc_dependants
include_parents

 
type_codes
 
strict_type_code
 
dataCallback
The assetid of the asset the role is applied to
The assetid of the roles that is applied
The assteid of the user performing the role
Whether to include the assetid in the returned array
Whether to query the role view which includes expanded Global roles as individual users
When TRUE, any groups defined within a role will be replaced with the userids in that group; If FALSE, return the groupids
If FALSE, filter out dependant assets
When userid is specified; this will return role information for roles that a user has inherited from its parent groups, as well as those directly applied on the user.
When include_assetid is TRUE; filter the returned asset IDs by a specified type code.
Whether to use strict type code for type code filter, i.e. type codes not inherited.
Custom callback function
integer
integer
integer
boolean
boolean
 
boolean
 
 
boolean
boolean
 
 
array
 
boolean
 
function
Responseroleid ==> userid 
Example
js_api.getRoles({
   "asset_id":100,
   "role_id":150,
   "user_id":70,
   "include_assetid":1,
   "include_globals":1,
   "expand_groups":1,
   "inc_dependants":0,
   "include_parents":0,   "type_codes":"page",   "strict_type_code":0,   "dataCallback":customDataCallbackFunc
})  

setContentOfEditableFileAsset

 ParameterCommentType
Requestasset_id
content
dataCallback
Id of the asset to update content for
New content of the asset
Custom callback function
string
string
function
Response["Content of Asset "File" (#1234) successfully updated"] 
Example
js_api.setContentOfEditableFileAsset({
   "asset_id":"100",
   "content":"content of file",
   "dataCallback":customDataCallbackFunc
}) 

updateFileAssetContent

 ParameterCommentType
Requestasset_id
content
dataCallback
Id of the File asset to update content for
Base64 encoded string of content for the File asset
Custom callback function
string
string
function
Response{success: "Content of the file asset file.jpg(#100) successfully updated", assetid: "100"} 
Example
js_api.updateFileAssetContent({
   "asset_id":"100",
   "content":"/9j/4QDGRXhpZgAASUkqAAgAA...",
   "dataCallback":customDataCallbackFunc
}) 

importAssetsFromXML

 ParameterCommentType
Requestasset_id
filePath
dataCallback  
Asset under which the assets are to be imported under
Path to file on the file system
Custom callback function
string
string
function
Response[{"success":"Assets successfully imported under Asset #1234"}] 
Example
js_api.importAssetsFromXML({
   "asset_id":"100",
   "filePath":"/path/to/our/xml/file/import_from_this_file.xml",
   "dataCallback":customDataCallbackFunc
}) 

executeHTMLTidy

 ParameterCommentType
Requestcontent
dataCallback
String content to be cleaned up
Custom callback function
string
function
Response["<h1>heading<\/h1>\n"] 
Example
js_api.executeHTMLTidy({
   "content":"<h1>heading</h2>",
   "dataCallback":customDataCallbackFunc
}) 

showDifference

 ParameterCommentType
Requestassetid_1
assetid_2
paint_layout_1
paint_layout_2
dataCallback
Asset ID of the first asset to compare
Asset ID of the second asse to compare
Asset ID of the Paint Layout to apply to Asset 1
Asset ID of the Paint Layout to apply to Asset 2
Custom callback function
string
string
string
string
function
Response
Example
{"success": Show Diff Content... } 
Example
js_api.showDifference({
   "assetid_1":"100",
   "assetid_2":"200",
   "paint_layout_1":"340",
   "paint_layout_2":"350",
   "dataCallback":customDataCallbackFunc
}) 

validateActiveUser

 ParameterCommentType
Requestusername
get_groups
dataCallback
The user to validate
Whether or not to return the user groups the user belongs to
Custom callback function
string
boolean
function
Response
Example
{User: "Found"}
 
OR

['100,'101,'11']
 
Example
js_api.validateActiveUser({
   "username":"User",
"get_groups":1,   "dataCallback":customDataCallbackFunc
}) 

getFileIndexingComponents

 ParameterCommentType
Requestasset_urls
dataCallback
The URL of the file to return indexing content for
Custom callback function
string
function
Response
Example
{
        metadata => {
            date => 2015-10-2410:53:13,
        }
        security_locks => '7',
        SQUIZASSETYPE => thumbnail,
        last_modified => 2015-04-27T13:38:05,
        file_title => thumbnail_for_user,
        file_name => img.jpg,
        author_name => Root User,
        author_id => 12,
        created => 2015-04-23T10:44:34,
}
 
Example
js_api.getFileIndexingComponents({
   "asset_urls":"http://www.example.com/__data/assets/thumbnail/0019/955/img.jpg",
   "dataCallback":customDataCallbackFunc
}) 

sortAssetChildren

 ParameterCommentType
Requestparent_id
sort_by 
sort_direction 
sort_type 
dataCallback
Asset ID you want to sort the child assets for
Standard asset fields or keywords to sort by
Direction to sort by, either "ascending" or "descending" 
The sorting type to use
Custom callback function
string / int
string 
string 
int 
function

The sort_type options are based on the PHP sort() function's sort_flags parameter and are passed in as int values representing the type. The values are as follows:

TypeValue
Regular0
Numeric1
String2
Natural6
Example
js_api.sortAssetChildren({
   "parent_id":     "100", "sort_by": "type_code", "sort_direction: "ascending", "sort_type": 0,
   "dataCallback":  customDataCallbackFunc
})
 ParameterCommentType
Requestparent_id
child_id
link_type
link_value
sort_order
is_dependant
is_exclusive
dataCallback
Major asset id we are linking
Minor asset id we are linking
Type of link to create* 
Value of the link
Order in the tree
Dependant to parent
Exclusive to parent
Custom callback function
integer
integer
string/integer 
string
integer
integer
integer
function
Responselink_id  

*NOTE: The link_type parameter can accept the value as a string or its integer value:

StringInteger
"SQ_LINK_TYPE_1"1
"SQ_LINK_TYPE_2"2
"SQ_LINK_TYPE_3"4
"SQ_LINK_NOTICE"8
Example
js_api.createLink({
   "parent_id":100,
   "child_id":120,
   "link_type":"SQ_LINK_TYPE_2",
   "link_value":"link_value",
   "sort_order":1,
   "is_dependant":1,
   "is_exclusive":0,
   "dataCallback":customDataCallbackFunc
}) 
 ParameterCommentType
Requestparent_id
child_id
link_type
 
 
link_value
dataCallback
Id of the parent
Id of the child
Type of link we are looking for (SQ_LINK_TYPE_1, SQ_LINK_TYPE_2, SQ_LINK_TYPE_3, or SQ_LINK_NOTICE)
Value of link we are looking for ('' by default)
Custom callback function
string
string
string
 
 
string
function  
Response
Example
["success":"Link #"500 " between Asset "Home" (#123) and Asset "Contact" (#456) has been successfully removed"] 
Example
js_api.removeLink({
   "parent_id":"100",
   "child_id":"120",
   "link_type":"SQ_LINK_TYPE_1",
   "link_value":"link value",
   "dataCallback":customDataCallbackFunc
}) 
 ParameterCommentType
Requestlink_info (parent, child, link_type,
link_value)
dataCallback
Array of link_info
 
Custom callback function
json object
 
function
Response
Example
[{"success":"Link #"500 " between Asset "Home" (#123) and Asset "Contact" (#456) has been successfully removed"},{"success":"Link ... ] 
Example
js_api.removeMultipleLinks({
   "link_info":{
      "links":[
         {
            "parent":"100",
            "child":"120",
            "link_type":"SQ_LINK_TYPE_1",
            "link_value":"link value"
         },
         {
            "parent":"200",
            "child":"220",
            "link_type":"SQ_LINK_TYPE_1",
            "link_value":"link value"
         }
      ]
   },
   "dataCallback":customDataCallbackFunc
})
 ParameterCommentType
Requestold_parent_id
child_id
old_link_type
 
 
old_link_value
 
new_parent_id
new_link_type
  

new_link_value
new_position
dataCallback      
Id of the old parent
Id of the child
Type of link we are search for between given assets (SQ_LINK_TYPE_1, SQ_LINK_TYPE_2, SQ_LINK_TYPE_3, or SQ_LINK_NOTICE)
Value of link we are searching for between given assets ('' by default)
Id of the new parent
Type of link to use (SQ_LINK_TYPE_1, SQ_LINK_TYPE_2, SQ_LINK_TYPE_3, or SQ_LINK_NOTICE)
Value of link to use ('' by default)
The new position
Custom callback function
string
string
string
 
 
string
 
string
string
 
 
string
string
function
Responselink_id  
Example
js_api.moveLink({
   "old_parent_id":"100",
   "child_id":"120",
   "old_link_type":"SQ_LINK_TYPE_1",
   "old_link_value":"old link value",
   "new_parent_id":"200",
   "new_link_type":"SQ_LINK_TYPE_1",
   "new_link_value":"new link value",
   "new_position":"1",
   "dataCallback":customDataCallbackFunc
}) 
 ParameterCommentType
Requestparent_id
child_id
existing_link_type
 
 
existing_link_value
link_type

 
link_value
sort_order
locked
dataCallback
Id of the parent
Id of the child
Existing link type between the assets (SQ_LINK_TYPE_1, SQ_LINK_TYPE_2, SQ_LINK_TYPE_3, or SQ_LINK_NOTICE)
Existing link value between the assets  ('' by default)
Link type to be updated to (SQ_LINK_TYPE_1, SQ_LINK_TYPE_2, SQ_LINK_TYPE_3, or SQ_LINK_NOTICE)
Link value to be updated to ('' by default)
The new position
The asset link lock status (locked by default)
Custom callback function
string
string
string
 
 
string
string
 
 
string
string
string
function
Response
Example
["success":"Link #"500 " between Asset "Home" (#123) and Asset "Contact" (#456) has been updated"] 
Example
js_api.updateLink({
   "parent_id":"100",
   "child_id":"120",
   "existing_link_type":"SQ_LINK_TYPE_1",
   "existing_link_value":"current link value",
   "link_type":"SQ_LINK_TYPE_2",
   "link_value":"new link value",
   "sort_order":"10",
   "locked":"1",
   "dataCallback":customDataCallbackFunc
}) 
 ParameterCommentType
Requestlink_info (parent, child,
existing_link_type, existing_link_value,
link_type, link_value, sort_order, link_lock)
dataCallback
Array of link_info
 
 
Custom callback function
json object
 
 
function
Response
Example
[{"success":"Link #"500 " between Asset "Home" (#123) and Asset "Contact" (#456) has been updated"},{"success":"Link ... ] 
Example
js_api.updateMultipleLinks({
   "link_info":{
      "links":[
         {
            "parent":"100",
            "child":"120",
            "existing_link_type":"SQ_LINK_TYPE_1",
            "existing_link_value":"old link value",
            "link_type":"SQ_LINK_TYPE_2",
            "link_value":"new link value",
            "sort_order":"5",
            "link_lock":"1"
         },
         {
            "parent":"200",
            "child":"220",
            "existing_link_type":"SQ_LINK_TYPE_2",
            "existing_link_value":"old link value",
            "link_type":"SQ_LINK_TYPE_1",
            "link_value":"new link value",
            "sort_order":"2",
            "link_lock":"0"
         }
      ]
   },
   "dataCallback":customDataCallbackFunc
}) 

getLinkId

 ParameterCommentType
Requestparent_id
child_id
link_type
 
 
link_value
all_info
dataCallback
Id of the parent
Id of the child
Type of link we are looking for (SQ_LINK_TYPE_1, SQ_LINK_TYPE_2, SQ_LINK_TYPE_3, or SQ_LINK_NOTICE)
Value of link we are looking for ('' by default)
If we want all the link information or just linkid
 Custom callback function
string
string
string
 
 
string
boolean
function
Responselink_id  
Example
js_api.getLinkId({
   "asset_id":"100",
   "child_id":"120",
   "link_type":"SQ_LINK_TYPE_!",
   "link_value":"link_value",
   "all_info":1,
   "dataCallback":customDataCallbackFunc
}) 

getPermissions

 ParameterCommentType
Requestasset_id
level
dataCallback
Id of the asset to get permissions from
Permission level: 1=READ 2=WRITE 3=ADMIN
Custom callback function
string
string
function  
Response"granted/denied" : {
    "user_id" : {
        id
        name
        user_name
        type
            },
    "group_id" : {
        id
        name
        type
        users {
            "user_id" : {
                 id
                 name
                 user_name
                 type
                     }, …
 
            }, ….
  
Example
js_api.getPermissions({
   "asset_id":"100",
   "level":"3",
   "dataCallback":customDataCallbackFunc
}) 

setPermission

 ParameterCommentType
Requestasset_id
user_ids
 
granted
 
level
 
cascades
 
dependants_only
 
dependant_parents
 
dataCallback
The ID of the asset to set permissions on
The Id of the user or user group to apply permissions for
The permission type to apply: 1 (Grant), 0 (Deny), or -1 (Revoke)
The permissions level to apply: 1 (Read), 2 (Write), or 3 (Admin)
Whether or not to automatically cascade permissions to newly created child assets
Whether or not to apply permission changes to dependant assets only
Whether or not to apply permission changes to dependant parents instead
Custom callback function
string/int
string/int
 
integer
 
integer
 
boolean
 
boolean
 
boolean
 
function
Response{"success":"Permission changes made successfully","assetids":["123"],"permission":"3","granted":"1","cascades":true} 
Example
js_api.setPermission({
   "asset_id":"123",
   "user_ids":"456",
   "granted":"1",
   "level":"3",
   "cascades":"true",
   "dependants_only":"true",
   "dependants_parents":"false",
   "dataCallback":customDataCallbackFunc
})

getWorkflowSchema

 ParameterCommentType
Requestasset_id
granted
 
 
running
dataCallback
Id of the asset to get workflow for
What is the status of workflow we are trying to get (default to Null)
True = granted  False = denied Null = get all
If to only get workflows that are running (default to False)
Custom callback function
string
boolean
 
 
boolean
function
Responsegranted / running  
Example
js_api.getWorkflowSchema({
   "asset_id":"100",
   "granted":1,
   "running":0,
   "dataCallback":customDataCallbackFunc
}) 

getParents

 ParameterCommentType
Requestasset_id
levels
type_codes
link_types
 
 
link_values
get_attributes
 
dataCallback
Id of the asset to get parents of
Number of levels to return
Asset type code that we want back
Link type of links we are looking for (SQ_LINK_TYPE_1, SQ_LINK_TYPE_2, SQ_LINK_TYPE_3, or SQ_LINK_NOTICE)
Link values allowed on the asset returned
If we are getting non standard attribute values of the assets (FALSE by default)
Custom callback function
string
number
array
array
 
 
array
boolean
 
function
Response"0" {
     name
     short_name
     id
     type_code
     type
     icon_path
     data_path
     web_path
     status
     created
     created_userid
     created_username
     updated
     updated_userid
     updated_username
     published
     published_userid
     published_username
     status_changed
     status_changed_userid
     status_changed_username
     link_id
     link_type
     is_dependant
     is_exclusive
     sort_order
     link_value
     locked
 
   }, ...
  
Example
js_api.getParents({
   "asset_id":"100",
   "levels":3,
   "type_codes":[
      "page_standard",
      "site"
   ],
   "link_types":[
      "SQ_LINK_TYPE_1",
      "SQ_LINK_TYPE_2"
   ],
   "link_values":[
      "value1",
      "value2"
   ],
   "get_attributes":1,
   "dataCallback":customDataCallbackFunc
}) 

getChildren

 ParameterCommentType
Requestasset_id
levels
type_codes
link_types
 
 
 
 
link_values

get_attributes
 
 
dataCallback
Id of the asset to get children of
Number of levels to return
Asset type code that we want back
Link type of links we are looking for (SQ_LINK_TYPE_1, SQ_LINK_TYPE_2, SQ_LINK_TYPE_3, or SQ_LINK_NOTICE)
Link values allowed on the asset returned
If we are getting non standard attribute values of the assets (FALSE by default)
Custom callback function
string
number
array
array
 
 
 
 
array

boolean
 
 
function
Response"0" {
     name
     short_name
     id
     type_code
     type
     icon_path
     data_path
     web_path
     status
     created
     created_userid
     created_username
     updated
     updated_userid
     updated_username
     published
     published_userid
     published_username
     status_changed
     status_changed_userid
     status_changed_username
     link_id
     link_type
     is_dependant
     is_exclusive
     sort_order
     link_value
     locked
     direct_dependant_children
     direct_non_dependant_children
     direct_notice_linked_children
 
  }, ...
  
Example
js_api.getChildren({
   "asset_id":"100",
   "levels":2,
   "type_codes":[
      "page_standard",
      "comment"
   ],
   "link_types":[
      "SQ_LINK_TYPE_1",
      "SQ_LINK_TYPE_2"
   ],
   "link_values":[
      "value1",
      "value2"
   ],
   "get_attributes":1,
   "dataCallback":customDataCallbackFunc
}) 

getAssetTree

 ParameterCommentType
Requestasset_id
levels
link_types
dataCallback
Id of the asset to get tree information of
Number of levels to return
The link types to return
Custom callback function
string
integer
integer
function
Response"asset_id":{
     "asset_id":{
          assetid
          majorid
          type_code
          page_standard
          status
          name
          short_name
          path
          sort_order
                            }, ...
  
Example
js_api.getAssetTree({
   "asset_id":"100",
   "levels":2,
"link_types":1,   "dataCallback":customDataCallbackFunc
})

getLineage

 ParameterCommentType
Requestasset_url
significant_link_only
 
dataCallback
URL or asset ID of the asset to get the lineage of
If to return significant links only (TYPE 1 and TYPE 2 links)
Custom callback function
string
boolean

function
Response"0" {
     tree_id
     assetid
     name
     type_code
     link_type
     link_value
     linkid
     parent_assetid
     parent_type_code
 
  }, ...
  
Example
js_api.getLineage({
   "asset_url":"http://www.example.com/site",
   "significant_links_only":1,
   "dataCallback":customDataCallbackFunc
}) 
js_api.getLineage({
   "asset_url":"100",
   "significant_links_only":0,
   "dataCallback":customDataCallbackFunc
})  

getLineageFromUrl

 ParameterCommentType
Requestasset_url
dataCallback
URL of the asset to get the lineage of
Custom callback function
string
function
Response"0" {
     url
     assetid
     name
     short_name
     type_code
     status
     protocol
     link_type
  }, ... 
  
Example
js_api.getLineageFromUrl({
   "asset_url":"http://www.example.com/site",
   "dataCallback":customDataCallbackFunc
})

getUrlFromLineage

 ParameterCommentType
Requestlineage
 
root_url
protocol
dataCallback
An array of asset IDs in lineage order, e.g. ["80","85","200"] or [{"assetid":"80"},{"assetid":"85"}]
A root URL to filter the results against multiple roots
A protocol to filter the results, e.g. http, https
Custom callback function
array

string
string
function
Response[ "http://www.example.com" ] 
Example
js_api.getUrlFromLineage({
   "lineage":["4206", "4437"],
"root_url":"http://www.example.com/site ",   "protocol":"https",
   "dataCallback":customDataCallbackFunc
})

getMetadata

 ParameterCommentType
Requestasset_id
dataCallback
Id of the asset we are getting info for
Custom callback function
string
function
Response
Example
{"Title":"Home","Description":"The home page of the site","Date Created":"14/06/2010 09:43:22"} 
Example
js_api.getMetadata({
   "asset_id":"100",
   "dataCallback":customDataCallbackFunc
}) 

setMetadata

 ParameterCommentType
Requestasset_id
field_id
field_val
dataCallback
Id of the asset we are setting info for
Id of the metadata field we are setting info for
The value set as metadata*
Custom callback function
string
string
string
function
Response
Example
{"success":["Metadata field #456 has been successfully set to "author" for Asset "Home" (#123)"]} 

*NOTE: The formats for setting the various metadata field types are outlined below. Please note that you can pass a value of null to use the default metadata value on the specified field.

  • Text: a simple text string, e.g. Squiz Matrix.
  • Select: the key(s) for the option(s) to select, separated by semicolons, e.g. a; b; c.
  • Multiple Text: simple text strings, separated by semicolons for each item, e.g. Squiz; Matrix.
  • Date: the date and time in the format yyyy-MM-dd hh:mm:ss, e.g. 2012-06-14 09:12:40.
  • Thesaurus: the name of the Thesaurus Term, e.g. Matrix.
  • Hierarchy: the key(s) for the option(s) to select, separated by semicolons, e.g. a; a1; b2.
  • WYSIWYG: HTML content, e.g. <strong>lorem ipsum...</strong>
  • Related Asset: the asset ID of the related asset, e.g. 123.

For more information on the metadata field types available, refer to the Metadata Schemas manual.

Example
js_api.setMetadata({
   "asset_id":100,
   "field_id":900,
   "field_val":"metadata",
   "dataCallback":customDataCallbackFunc
}) 
js_api.setMetadata({
   "asset_id":100,
   "field_id":900,
   "field_val":null,
   "dataCallback":customDataCallbackFunc
}) 

setMetadataAllFields

 ParameterCommentType
Requestasset_id
field_info
dataCallback
Id of the asset we are setting info for
Field Ids and their values
Custom callback function
string
array
function
Response
Example
{"success":["Metadatafield #456 has been successfully set to "author" for Asset "Home" (#123)","Metadata field ... ]} 
Example
js_api.setMetadataAllFields({
   "asset_id":"100",
   "field_info":{
      "900":"Metadata1",
      "901":"Metadata2"
   },
   "dataCallback":customDataCallbackFunc
})   

getMetadataSchema

 ParameterCommentType
Requestassetid
granted
 
cascades
 
dataCallback
The ID of the asset to get the metadata schema info of
If to return metadata schemas that have been applied (TRUE) or denied (FALSE)
If to return metadata schemas that cascade to newly created child assets (TRUE) or schemas that do not (FALSE)
Custom callback function
string
boolean

boolean
 
function
Example
js_api.getMetadataSchema({
   "assetid":"150",
"granted":1, "cascades":0,   "dataCallback":customDataCallbackFunc
})  

editMetadataSchema

 ParameterCommentType
Requestassetid
schemaid
set
granted
 
cascades
 
dataCallback
The asset to set/unset the metadata schema on
The metadata schema to be set/unset on the asset
Whether the metadata schema is being set (1) or unset (0)
whether the metadata schema is being applied (TRUE) or denied (FALSE)
whether or not the schema should be cascaded to newly created assets
Custom callback function
string
string
boolean
boolean
 
boolean
 
function
Example
js_api.editMetadataSchema({
"assetid":"612",
"schemaid":"405",
"set":1,
"granted":0,
"cascades":0,   "dataCallback":customDataCallbackFunc
})  

getAlternateContext

 ParameterCommentType
Requestall_info
dataCallback
If to return all information of returned contexts
Custom callback function
boolean
function
Example
js_api.getAlternateContext({
   "all_info":1,
   "dataCallback":customDataCallbackFunc
})

getCurrentContext

 ParameterCommentType
Requestall_info
dataCallback
If to return all information of returned contexts
Custom callback function
boolean
function
Example
js_api.getCurrentContext({
   "all_info":1,
   "dataCallback":customDataCallbackFunc
})

getAllContexts

 ParameterCommentType
Requestall_info
dataCallback
If to return all information of returned contexts
Custom callback function
boolean
function
Example
js_api.getAllContexts({
   "all_info":1,
   "dataCallback":customDataCallbackFunc
}) 

setContext

 ParameterCommentType
Requestcontext_id
dataCallback
Id of the context you want to activate
Custom callback function
string
function
Example
js_api.setContext({
   "context_id":"160",
   "dataCallback":customDataCallbackFunc
})

restoreContext

 ParameterCommentType
RequestdataCallbackCustom callback functionfunction
Example
js_api.restoreContext({
   "dataCallback":customDataCallbackFunc
})

contextualiseAsset

ParameterTypeDescription
asset_idstring/intThe ID of the asset to contextualise.
context_idstring/intThe ID of the Context you want to contextualise for.
contextualisebooleanChoose either to contextualise or un-contextualise the component for the asset.
component_typestringAsset component to contextualise. Either "attribute" or "metadata" or null (contextualises both).
dataCallbackfunctionCustom callback function
Example
js_api.contextualiseAsset({
  "asset_id":"100"
  "context_id":"1"
  "contextualise":true
  "component_type":"metadata"
"dataCallback":customDataCallbackFunc
})

getGoogleAnalyticsStatistics

 ParameterCommentType
Requestassetid
end_date
 
start_date
duration
 
 
dimensions
 
metrics
 
sort_by
filter
 
force_cache
 
 
dataCallback
The asset ID of the Google Analytics View asset.
The end date of analytics data to return. Can be specified as a plain date (e.g. 2014-11-18) or as a relative date.
The start date of the analytics data to retuen.
The duration of analytics data to return, worked back from the end_date, inclusive. For instance P1M indicates one-month duration.
Specify the dimenstions to use on the request. For more information, refer to the Google Analytics site.
Specify the dimenstions to use on the request. For more information, refer to the Google Analytics site.
Array of fields to sort results by.
Filter analytics data according to the filter expressions defined on the Google Analytics site.
Specify whether or not to hit Google Analytics for data if a cached entry is not available. If set to to TRUE, when no content is available, a "noContent" error will be returned.
Custom callback function
string
string
 
string
string
 
 
array / string
 
array / string
 
array / string
array / string
 
boolean
 
 
function
Example
js_api.getGoogleAnalyticsStatistics({
   "assetid":"100",
   "dimensions":["ga:date"],
   "metrics":["ga:sessions", "ga:pageviews"],
   "duration":"P1M",
   "end_date":"-P1D",
   "sort_by":["-ga:sessions"],   "dataCallback":customDataCallbackFunc
})

getSystemInformation

 ParameterCommentType
RequestdataCallbackCustom callback functionfunction
Example
js_api.getSystemInformation({
   "dataCallback":customDataCallbackFunc
})

createQuestion

 ParameterCommentType
Requestassetid
type_code
units
dataCallback
The asset of the form or form section to add the question asset
The type of question to be added (default: Text)
The number of questions to add of a certain type (default: 1)
Custom callback function
string
string
integer
function
Example
js_api.createQuestion({
"assetid":"100",
"type_code":"Country", "units":2,
"dataCallback":customDataCallbackFunc
}) 

updateQuestion

 ParameterCommentType
Requestassetid
question_id
field_info
dataCallback
The asset of the form or form section to update
The asset ID of the question to update
The object containing data that needs to be updated
Custom callback function
string
string
json
function
Example
var field_info = {
'cust_required_error': 'This is custom Text',                                                     //text type
'is_required': 1,                                                                                 // boolean type
'default':  '2014-10-10 10:59:39',                                                                // datetime type
'name': 'Date Time Question',                                                                     // text type
'show': show_array,                                                                               // serialise type
'text': 'a:3:{s:1:"d";s:9:"date text";s:1:"m";s:10:"month text";s:1:"y";s:9:"year text";}'        // also serialise type
};

js_api.updateQuestion({
"assetid":"100",
"question_id":"q35",
"field_info":field_info,
"dataCallback":customDataCallbackFunc})

removeQuestion

 ParameterCommentType
Requestassetid
 
question_id
dataCallback
The asset of the form or form section to remove a question from
Question that needs to be removed
Custom callback function
string
 
string
function
Example
js_api.removeQuestion({
"assetid":"100",
"question_id":"q35",
"dataCallback":customDataCallbackFunc})

updateQuestionOrder

 ParameterCommentType
Requestassetid
sort_order
dataCallback
The asset of the form or form section to update
New order of the questions
Custom callback function
string
array
function
Example
question_order = ['100:q52', '100:q51', '100:q50', '100:q49''];
js_api.updateQuestionOrder({
assetid:"100",
sort_order:question_order,
dataCallback:customDataCallbackFunc})

getAvailablePersonas

 ParameterCommentType
Requestassetid
 
dataCallback
ID of the asset for which to get available personas. 

Custom callback function
string
 
function
Response

{

"personas":{

"persona_id":{

assetid,

name

}

},

"applied_personas":

[persona_id]

},...

  
Example
js_api.getAvailablePersonas({
  "asset_id":"100",
  "dataCallback":customDataCallbackFunc<br>
})

assignPersonas

 ParameterCommentType
Request

assetid

variation_id

persona_ids

dataCallback

Id of the asset that has the Variation

Id of the Variation asset

Ids of the Personas to apply to the Variation

Custom callback function

string

string

array

function

Responsenull  
Example
js_api.assignPersona({
  "asset_id":"100",
  "variation_id":"101"
  "persona_ids": ["200"]
  "dataCallback":customDataCallbackFunc
})

Batching Requests

The batchRequest operation allows you to group multiple functions on the JS API into a single batched request. The response of this operation will include all the data returned from each executed function.

The output of functions on this operation can be used as the input for subsequent functions using the following keyword replacement format:

%results_0_<param>%

For example, the keyword replacement %results_0_1_name% would print the value of the name parameter returned on the second element of the first array of the response.

Please note that Squiz Matrix will attempt to replace this keyword when used within page content returning a blank value. In such cases, the following format for this keyword can be employed:

"%" + "results_0_<param>" + "%"

A blocking parameter (type: boolean) is available for use on each operation to stop the execution of subsequent operations if an error is returned. Usage of this parameter is as follows:

{ 
    function :"getGeneral",
    args : {
        asset_id : "100",
        get_attributes : 0
    }
"blocking":1
}

Example

In the following example, we are using the batchRequest operation to run the getChildren and setAttribute operations on a single request.

The getChildren operation will retrieve the top level child assets of our Site (#100) that are of type page_standard. The setAttribute operation will use this information to change the short_name of the first returned asset on this response.

To do this, we have used the %results_0_0_id% keyword replacement in the asset_id paramater. This will retrieve the id value of the first element of the first array of the response (i.e. the first returned asset on the data returned on the getChildren operation).

The blocking property has also been used on the getChildren operation. This means that if an error is returned, the following operation (setAttribute) will not be run.

Request (Enhanced)

js_api.batchRequest({
   "functions":{
      "0":{
         "function":"getChildren",
         "args":{
         "asset_id":"100",
         "levels":1,
         "type_codes":"page_standard",
         "get_attributes":0
         },
         "blocking":1
      },
      "1":{
         "function":"setAttribute",
         "args":{
         "asset_id":"%results_0_0_id%",
         "attr_name":"short_name",
         "attr_val":"new short name"
         }
      }
   },
   "dataCallback":customDataCallbackFunc
}); 

Response

[["0" { 
        "name" : Home Page
        "short_name" : Home
        "id" : 150
        "type_code" : page_standard
        "type" : Page Standard
        ...

   },

["Attribute "short_name" has been successfully set to "new short name" for Asset "Home Page" (#150)"]]  

As shown in the above response, the batchRequest operation has used the returned id value on getChildren (first element) as the asset ID passed in the setAttribute operation.


Previous Chapter Next Chapter