The Context Object is a Javascript object available throughout the Swing Extensions. In every extension point, the context object can be accessed and its methods called.
The Context Object is composed of public methods (see Public methods), object-specific methods (see Object class methods), and user-specific methods (see User class methods). If the context object is referred to a specific object, an activeObject property is available (see activeObject). To support object panel bulk mode use activeObjects instead. If the context object is inside a supported Editor, the activeDocument property is available (see activeDocument). Starting from version 5.2020.11 if the context object is inside a supported Editor, the activeDocumentV2 property is available (see activeDocumentV2)
Through a new shared object will be available a set of api(s) to handle the document with new logics to support the report case. These api(s) will be supported among Swing, Prime and Swing Mobile.
Public methods
List of methods
Name |
Description |
Obtains the application info. |
|
Obtains the area info. |
|
Returns an array containing the string XML fragments obtained from the evaluation in the siteConfig.cfg file of the provided xpath. |
|
Obtains the communication status. |
|
Obtains the component info. |
|
Reads a file given its filename, and returns it in a particular format. |
|
Executes a Methode query. |
|
Reads a user data content given its filename. |
|
Adds a new JSON object to the specified user data content. |
|
Set a new JSON array to the specified user data content. |
|
Obtains a content of a document, given its path |
|
Obtains the current user |
|
Obtains a Methode object, given its id |
|
Obtains a Methode object, given its path |
|
Obtains the Platform information |
|
Obtains a user, given its name |
|
Obtains the list of member names, given a group name |
|
Open a Methode document, given its id |
|
Open the new content dialog, with the selected options |
|
Open a Methode document, given its id, in readonly mode |
|
Opens a popup panel |
|
return the last selected element in the editor context in the form of Object Class instances. |
getApplicationInfo
Retrieves the application info and returns a JSON object containing the context and the name of the application.
{
context: "/swing",
name: "Swing"
}
Syntax
ctx.getApplicationInfo()
Returns
Type |
Description |
{JSON Object} |
A json object containing the context and the name of the application. |
Example
var applicationInfo = ctx.getApplicationInfo();
getAreaInfo
Retrieves the area info and returns a JSON object containing the area type and the area name.
{
name: "story",
type: "editor"
}
Syntax
ctx.getAreaInfo()
Returns
Type |
Description |
{JSON Object} |
A json object containing the area type, the area name and the area context. |
Example
var areaInfo = ctx.getAreaInfo();
getSiteConfigFragment
Returns an array containing the string XML fragments obtained from the evaluation in the siteConfig.cfg file of the provided xpath.
Syntax
ctx.getSiteConfigFragment(xpath);
Parameters
Name |
Type |
Required |
Description |
|
{String} |
Yes |
|
Example
var presetCropsArray = ctx.getSiteConfigFragment('/siteConfiguration/presetCrops');
/*
presetCropsArray:
[ "<presetCrops>
<crop channel="Globe-Web,Globe-Print,Globe-WireNews" favorite="yes" height="719px" name="Homepage-Main" width="107px"/>
<crop height="667px" name="iPhone 6" width="375px"/>
<crop height="512px" name="iPad 4" width="384px"/>
</presetCrops>" ]
*/
getCommunicationStatus
Retrieves the communication status of the application (useful when working in offline mode). The object returned contains the following fields:
-
applicationOnline: true if the application is in online mode, false otherwise.
-
isOnline: true if the application reaches the server and the application is in online mode, false otherwise.
-
offlineServer: enabled : true if the offline server is available, enabled: false otherwise.
-
serverReachable: true if the server is reachable, false otherwise.
{
applicationOnline: true,
isOnline: true,
offlineServer: {
enabled: false
},
serverReachable: true
}
Syntax
ctx.getCommunicationStatus()
Returns
Type |
Description |
{JSON Object} |
A json object containing the communication status of the application. |
Example
var communicationStatus = ctx.getCommunicationStatus();
getComponentInfo
Retrievest the conponent info and returns a JSON object containing the type and the subType of the current component. e.g.
{
type: "objectpanel",
subType: ""
}
Syntax
ctx.getComponentInfo()
Returns
Type |
Description |
{JSON Object} |
A json object containing the type and the subType of the current component. |
Example
var componentInfo = ctx.getComponentInfo();
readFile
Reads a file given its filename, and returns it in a particular format. The readFile method is intend to be used only for XML files with two format as response: XML or JSON.
Syntax
ctx.readFile( options, callback )
Parameters
Name |
Type |
Required |
Description |
|
{Object} |
Yes |
A list of options. See below |
|
{Function} |
No |
A callback function. See Callback definition for further information. |
|
The options object is a Javascript object with the following properties:
|
Returns
Type |
Description |
{JSON} or {XML} |
The content of the object in the format specified in the options parameter. |
Example
var file = ctx.readFile( { 'filename': '/SysConfig/Common/Data/Sections.xml',
'format': 'xml',
'resolveEntities': true
});
executeQuery
Executes a Methode query given the query content as String, and returns a query result as JSON.
Syntax
ctx.executeQuery( settings, callback )
Parameters
Name |
Type |
Required |
Description |
|
{String or Object} |
Yes |
If a string is passed, it represents the query content to be executed. Else, represents a set of arguments. |
|
{Function} |
No |
A callback function. See Callback definition for further information. |
|
settings can be either a string or a Javascript Object. If it is a string, it represents the query content to be executed. Elsewhere, if a Javascript object is passed, the following properties are supported:
|
Returns
Type |
Description |
{JSON Object} |
The query execution result. |
Example
var settings = {
"limit":70,
"query":"<?xml version=\"1.0\" encoding=\"utf-8\"?><!DOCTYPE EOMSearch><EOMSearch version=\"1.0\" xmlns=\"http://EidosMedia.com/EOM/SearchEngine\" xmlns:se=\"http://EidosMedia.com/EOM/SearchEngine\" xmlns:q=\"http://EidosMedia.com/EOM/SearchEngine/query\" xmlns:qm=\"http://EidosMedia.com/EOM/SearchEngine/query/macro\" xmlns:qa=\"http://EidosMedia.com/EOM/SearchEngine/query/alias\" xmlns:qui=\"http://EidosMedia.com/EOM/SearchEngine/query/UI\" xmlns:i=\"http://EidosMedia.com/query/interpolate\"><q:Query type=\"INDEX\"><q:Properties><q:MaxResultItems value=\"70\"/><q:Sort on=\"ObjectInfo/created\" type=\"NDESCENDING\"/><q:Index name=\"@meth01_eomjse1\"/></q:Properties><q:Boolean><q:OR><se:Content q:op=\"INC\" xmlns=\"\">obama</se:Content><se:Attributes q:op=\"INC\">obama</se:Attributes></q:OR></q:Boolean></q:Query></EOMSearch>"
}
var result = ctx.executeQuery(settings);
getUserData
Reads a user data content given its filename. If the file does not exist the system creates it in the following path "eomfs:/Configurations/Profiles/{currentUserName}/{filename}.json", and returns an empty JSON array.
Syntax
ctx.getUserData( filename, callback )
Parameters
Name |
Type |
Required |
Description |
|
{String} |
Yes |
The user data file’s name without extension. |
|
{Function} |
No |
A callback function. See Callback definition for further information. |
Returns
Type |
Description |
{JSON Array} |
The content of user’s data in JSON format or an empty JSON array if is a new file. |
Example
var friends = ctx.getUserData('friends');
addUserData
Adds a new JSON object to the specified user data content, denoted by the filename input parameter.
Syntax
ctx.addUserData( filename, data, callback )
Parameters
Name |
Type |
Required |
Description |
|
{String} |
Yes |
The user data file’s name without extension. |
|
{JSON Object} |
Yes |
The data object to be added to the user data file. |
|
{Function} |
No |
A callback function. See Callback definition for further information. |
Returns
Type |
Description |
{JSON Array} |
The updated list with the new added data object. |
Example
var friends = ctx.addUserData('friends', {
'fullName': 'Carroll Walke'
});
setUserData
Set a new JSON array to the specified user data content, denoted by the filename input parameter.
Syntax
ctx.setUserData( filename, list, callback )
Parameters
Name |
Type |
Required |
Description |
|
{String} |
Yes |
The user data file’s name without extension. |
|
{JSON Array} |
Yes |
The JSON array to replace the current user data content. |
|
{Function} |
No |
A callback function. See Callback definition for further information. |
Returns
Type |
Description |
{JSON Array} |
The updated list with the specified JSON array |
Example
var friends = ctx.setUserData('friends', [
{
"fullName": "Mitchell Henson"
},
{
"fullName": "Carroll Walker"
},
{
"fullName": "Carla Sargent"
},
{
"fullName": "Sara Savage"
},
{
"fullName": "Beach Workman"
},
{
"fullName": "Courtney Roberts"
},
{
"fullName": "Abby Hood"
},
{
"fullName": "Belinda Acosta"
}
]);
getContentByPath
Obtains a content of a document, given its path.
Syntax
ctx.getContentByPath( path, options, callback )
Parameters
Name |
Type |
Required |
Description |
|
{String} |
Yes |
The path of the object. E.g. 199$/SysConfig/columnCatalogCfg.swing.xml |
|
{Object} |
No |
An optional list of options. See below |
|
{Function} |
No |
A callback function. See Callback definition for further information. |
|
The options object is a Javascript object with the following properties:
|
Returns
Type |
Description |
{string} |
The content of the object as a string. |
Example
ctx.getContentByPath('199$/SysConfig/columnCfgCatalogs.swing.xml', { cached: true }, function(err, content) {
if (err) {
ctx.showError(err);
return;
}
console.log(content);
});
Note
The method can also be called synchronously, but this usage is not recommended.
getCurrentUser
Obtains the current user.
Syntax
ctx.getCurrentUser( callback )
Parameters
Name |
Type |
Required |
Description |
|
{Function} |
Yes |
A callback function. See Callback definition for further information. |
Returns
Type |
Description |
{User object} |
An instance of the User Class. See User class methods for further information on the methods available. |
Example
ctx.getCurrentUser(function(err,User) {
if (err) {
ctx.showError(err);
return;
}
// Do something with the user...
alert(User.getName());
});
Note
The method can also be called synchronously, but this usage is not recommended.
getObject
Obtains a Methode object, given its id
Syntax
ctx.getObject( id, callback );
Parameters
Name |
Type |
Required |
Description |
|
{String} |
Yes |
The document id. Format is [<databaseId>$]<loid>. |
|
{Function} |
Yes |
A callback function. See Callback definition for further information. |
Returns
Type |
Description |
{Object class} |
An instance of the Object Class. See Object class methods for further information on the methods available. |
Example
ctx.getObject('199$1.0.893734064', function(err, Obj) {
if (err) {
ctx.showError(err);
return;
}
// Do something with the object...
Obj.openReadonly();
});
Note
The method can also be called synchronously, but this usage is not recommended.
getObjectByPath
Obtains a Methode object, given its path
Syntax
ctx.getObjectByPath( path, callback );
Parameters
Name |
Type |
Required |
Description |
|
{String} |
Yes |
The document path. |
|
{Function} |
Yes |
A callback function. See Callback definition for further information. |
Returns
Type |
Description |
{Object class} |
An instance of the Object Class. See Object class methods for further information on the methods available. |
Example
ctx.getObjectByPath('/Globe/Stories/Test.xml', function(err, Obj) {
if (err) {
ctx.showError(err);
return;
}
// Do something with the object...
Obj.openReadonly();
});
Note
The method can also be called synchronously, but this usage is not recommended.
getPlatformInfo
Obtains the Platform information
Syntax
ctx.getPlatformInfo();
Parameters
No parameters required.
Returns
Type |
Description |
{Object} |
A generic Javascript Object containing the platform information. |
Example
var platformInfo = ctx.getPlatformInfo();
if (platformInfo.application.indexOf('Swing') > -1) {
// Do something only if it's Swing/Swing Mobile
}
getUserByName
Obtains a user, given its name.
Syntax
ctx.getUserByName( name, callback )
Parameters
Name |
Type |
Required |
Description |
|
{String} |
Yes |
The user name to look for. |
|
{Function} |
Yes |
A callback function. See Callback definition for further information. |
Returns
Type |
Description |
{User object} |
An instance of the User Class. See User class methods for further information on the methods available. |
Example
ctx.getUserByName( 'user.test1', function(err,User) {
if (err) {
ctx.showError(err);
return;
}
// Do something with the user...
alert(User.getName());
});
Note
The method can also be called synchronously, but this usage is not recommended.
getGroupMembers
Obtains the list of member names, given a group name
Syntax
ctx.getGroupMembers( groupName, callback )
Parameters
Name |
Type |
Required |
Description |
|
{String} |
Yes |
The group name to look for. |
|
{Function} |
Yes |
A callback function. See Callback definition for further information. |
Returns
Type |
Description |
{JSON Array} |
The callback function will be called with the list of users belonging to the requested group, as an array of user names. |
Example
ctx.getGroupMembers( 'group.test1', function(err, members) {
if (err) {
ctx.showError(err);
return;
}
// Do something with the user names...
for (var i = 0; i < members.length; i++) {
console.log(members[i]);
}
});
openDocument
Open a Methode document, given its id
Syntax
ctx.openDocument( id, callback )
Parameters
Name |
Type |
Required |
Description |
|
{String} |
Yes |
The document id to open. Format is [<databaseId>$]<loid>. |
|
{Function} |
Optional |
A callback function. See Callback definition for further information. |
Returns
The methods does not return any information. The callback is called when the document is opened.
Example
ctx.openDocument( '199$1.0.893734064', function(err,User) {
if (err) {
ctx.showError(err);
return;
}
// Document has opened correctly
});
openNewContentDialog
Open the new content dialog, with the selected options
Syntax
ctx.openNewContentDialog( options, callback )
Parameters
Name |
Type |
Required |
Description |
|
{Object} |
Yes |
The options with which the dialog is loaded. |
|
{Function} |
Optional |
A callback function. See Callback definition for further information. |
|
The options parameter is a javascript object in which it is possible to define:
|
Returns
The methods does not return any information. The callback is called when the document is created.
Example
ctx.openNewContentDialog( {
template: '/SysConfig/Globe/Templates/poll.xml',
contentType: 'story'
}, function(err,data) {
if (err) {
ctx.showError(err);
return;
}
// Document has been created correctly
alert( data.name );
});
openReadonly
Open a Methode document, given its id, in Readonly mode
Syntax
ctx.openReadonly( id, callback )
Parameters
Name |
Type |
Required |
Description |
|
{String} |
Yes |
The document id to open. Format is [<databaseId>$]<loid>. |
|
{Function} |
Optional |
A callback function. See Callback definition for further information. |
Returns
The methods does not return any information. The callback is called when the document is opened.
Example
ctx.openReadonly( '199$1.0.893734064', function(err,data) {
if (err) {
ctx.showError(err);
return;
}
// Document has opened correctly
});
openPopupPanel
Opens a custom HTML panel developed and specified by the user.
Syntax
ctx.openPopupPanel( panelName );
Method |
|
Parameter |
|
Returns |
|
Example
var panelName = 'myTestPanel';
ctx.openPopupPanel( panelName );
getSelection
Retrieves the last selected element in the editor context, for example DWP and Report editor.
Syntax
ctx.getSelection()
Returns
Type |
Description |
{JSON Object} |
A json object containing the last selected element in the contex editor in the form of Object Class instances. |
Example
var selection = ctx.getSelection();
Registration of the custom panel
The custom panel must be registered via Javascript. The namespace of reference is the following:
eidosmedia.webclient.extensions.popups
A call to the register method must be done as follows:
eidosmedia.webclient.extensions.popups.register( name, settings );
-
{String} name: the name of the custom popup ( same as the one called from thectx.openPopupPanel()method. -
{Object} settings: a javascript object with the settings. It has the following parameters:-
{String} icon: the icon css class. -
{String} title: the title of the custom dialog. -
{String} containerStyle: the style of the container. See info box below. -
{String} template: the path to the HTML file. It is relative to the application context. -
{Function} ready: a function which is called when the popup is loaded. The function is called with two parameters:-
ctx- the Context Object ( with the activeDocument if you are in the Story Editor context ) -
$modal- the jQuery reference to identify the modal. The example below will show some possible uses.
-
-
eidosmedia.webclient.extensions.popups.register('testpopup', {
icon: 'icon-plus',
title: 'Custom panel title',
containerStyle: 'background-color:red;',
template: '/config/templates/customTemplates/testpopup.html',
ready: function( ctx, $modal ) {
// Popup is visible.
console.log( ctx );
// CUSTOM EXAMPLE
/*
In the footer example, we added a 'data-modal-action' to the OK button.
We now intercept the click inside the modal.
*/
// Add modal listeners.
$modal.on('click', '[data-modal-action]', function( event ) {
var action = $(this).attr('data-modal-action');
switch(action) {
case 'ok':
alert('Button clicked!');
// To close the modal, use $modal.modal('hide');
$modal.modal('hide');
break;
}
event.preventDefault();
event.stopPropagation();
});
}
});
|
The popup panel is built around a classical Bootstrap Modal.
In particular, the HTML code in your template will be placed INSIDE the So, the modal will be basically created as follows:
No predefined style is given for the footer, but it is recommended to be as follows:
So, considering that your code is wrapped inside the modal-body, if you want to use a footer,
close a Example:
IMPORTANT: as it is a bootstrap modal, by adding |
Shared Object
A set of api(s) to handle the document supporting the report case. These api(s) will be available among Swing, Prime and Swing Mobile.
Document
The shared document object contains a set of api(s) to operate with the document\report editor. These api(s) will refer to the single story editor or the full report stories editor depening on each case.
List of methods
Name |
Description |
Add the specified tags in the document \ report |
|
Add specific tags based on the provided xpaths list |
|
Insert an annotation into a document’s element |
|
Clear all occurrences of a set of tags in the document \ report, preserving content |
|
Close the document \ report |
|
Get the document \ report outline |
|
Get the document \ report text content |
|
Get the text content of a document based on the xpaths provided \ for report the results will be divided by section |
|
Get the document \ report xml content |
|
Notify the document \ report that the metadata has been modified |
|
Save the document \ report |
|
Select an element from the editor |
addTags
Add the specified tags in a document or report.
Accept an object parameter specifying the list of tags with related tag name, start, size, attributes (optional) and virtual flag (optional). If the optional virtual flag (true by default) is set to false, the tag will be saved in the document / report. An optional lock flag can be specified. An optional hash parameter can be specified (the one retrieved by the getTextContent api), it will be used to verify if the document / report changed, in case of changes the api will fail. The api returns a promise. If the promise succeeds, it returns a boolean indicating wether any tag has been added.
Parameters
Name |
Type |
Required |
Description |
|
{Array} |
Yes |
An array of object specifying the tag name, the start and size of text to be tagged and an optional attributes object. |
|
{Boolean} |
No |
To lock the document, true by default. |
|
{String} |
No |
To verify the document / report changes since the hash retrieval via getTextContent api. |
Syntax
ctx.shared.document.addTags({tags: [{tag: 'mark1', start:0, size:2}, {tag: 'mark2', start:4, size:6, attributes: {class: 'highlight'}}] })
Returns
A promise resolved when the operation is finished
Example
ctx.shared.document.addTags({tags: [{tag: 'mark', start:0, size:2}]})
.then( result => {
console.log(result)
})
.catch( err => {
console.err(err);
});
addTagsByXpath
Apply tags based on the xpath list provided.
Accept an options object containing an array of documentList where to apply the tags. An optional lock flag can be specified. For each tag element: If the optional virtual flag (true by default) is set to false, the tag will be saved in the document / report. An optional hash parameter can be specified (the one retrieved by the getTextContentByTags api), it will be used to verify if the document / report changed, in case of changes the api will fail. The api returns a promise. If the promise succeeds, it returns an array with the id of the section and and teh result of the operation for each xpath.
Parameters
Name |
Type |
Required |
Description |
|
{Array} |
Yes |
An array of document where to apply the tags. |
|
{String} |
No |
If true each document will be locked, if not already locked, default true. |
Syntax
ctx.shared.document.addTagsByXpath({ documentList: ['/doc/story/grouphead', '/doc/story/summary', '/doc/story/text'], lock: false})
Returns
A promise resolved when the operation is finished
Example
ctx.shared.document.addTagsByXpath({ {
"lock": false,
"documentList": [
{
"storyId": "33$1.0.1468130003",
"xpaths": [
{
"xpath": "/doc/section/text",
"tags": [
{
"tag": "mask",
"start": 1,
"size": 4
},
{
"tag": "mask",
"start": 10,
"size": 3
}
],
"hash": true
}
]
},
{
"storyId": "33$1.0.1470737318",
"xpaths": [
{
"xpath": "/doc/section/text",
"tags": [
{
"tag": "mask",
"start": 5,
"size": 8
},
{
"tag": "mask",
"start": 20,
"size": 4
}
],
"hash": true
},
{
"xpath": "/doc/story/text",
"tags": [
{
"tag": "mask",
"start": 1,
"size": 10
}
],
"hash": true
}
]
}
]
})
.then( result => {
console.log(result)
})
.catch( err => {
console.err(err);
});
/* example of return value */ result =
[
{
storyId: '33$1.0.1468130003',
addTagsResult: {
"/doc/section/text": {
success: true
}
}
},
{
storyId: '33$1.0.1470737318',
addTagsResult: {
"/doc/section/text": {
"success": true
},
"/doc/story/text": {
success: false,
errorCode: 404,
errorMessage: 'node element not found'
}
}
]
annotateElement
Add an annotation to an element from the story editor\report.
Accepts parameters to define where add the annotation and returns a promise with information on the annotation operation.
Parameters
Name |
Type |
Required |
Description |
|
{Object} |
Yes |
An object with the (optional) property tag for the tag name and an (optional) object property attributes to define the key\values attributes to look up for the annotation. If more than one element match the selection criterias the first one will be annotated. |
|
{String} |
Yes |
The annotation string |
|
{Object} |
Optional |
Additional parameters (see the table below) |
Name |
Type |
Required |
Description |
|
{Boolean} |
Optional |
If true the selected text element is unwrapped from its parent tag before adding the annotation |
Syntax
ctx.shared.document.annotateElement(element, text, options)
Returns
A promise resolved if one element was annotated. The promise is rejected if no elements for annotation are found.
Example
const element = { tag: "mark", attributes: { type: "player" } };
const options = { unwrap: true };
ctx.shared.document
.annotateElement(element, "This is my annotation", options)
.then((res) => {
console.log(res);
})
.catch((err) => {
console.error(err);
});
clearTags
Remove all the occurrences of the specified set of tags preserving their content, in a document or report.
Accept an object parameter specifying the list of tags and optionally a lock flag, returns a promise. If the promise succeeds, it returns a boolean indicating wether any occurrence of the tags has been matched and cleared.
Parameters
Name |
Type |
Required |
Description |
|
{Array} |
Yes |
An array of object specifying the tag name. |
|
{Boolean} |
No |
To lock the document, true by default. |
Syntax
ctx.shared.document.clearTags({tags: [{tag: 'mark'}, {tag:'highlight'}] })
Returns
A promise resolved when the operation is finished
Example
ctx.shared.document.clearTags({tags: [{tag: 'mark'}]})
.then( result => {
console.log(result)
})
.catch( err => {
console.err(err);
});
close
Close the current report \ document.
Returns a promise.
Syntax
ctx.shared.document.close()
Returns
A promise resolved when the operation is finished. The promise is rejected if the closing operation is cancelled (for example if the user choose "cancel" on save dirty document alert)
Example
ctx.shared.document.close()
.then( result => {
// The window is closing, no operation execution granted here
console.log(result)
})
.catch( err => {
// Closing operation cancelled
console.error(err);
});
getOutline
Returns information on the whole document or report. The information returned is ObjectInfo and optionally text and xml. In case of report an array of object is returned.
Parameters
Name |
Type |
Required |
Description |
|
{Boolean} |
No |
To get document xml, false by default. |
|
{Boolean} |
No |
To get document text, false by default. |
Syntax
ctx.shared.document.getOutline({xml: true, text: false})
Returns
A promise resolved when the operation is finished
Example
ctx.shared.document.getOutline()
.then( result => {
console.log(result)
})
.catch( err => {
console.error(err);
});
getTextContent
Returns the complete text content of the document or report. The text has newline at end of each paragraph. Accept an object parameter specifying the hash optional flag.
Parameters
Name |
Type |
Required |
Description |
|
{Boolean} |
false |
To return a hash of the document / report. To be specified in the addTags api to verify the document changed since getTextContent invocation. |
Syntax
ctx.shared.document.getTextContent()
Returns
A promise resolved when the operation is finished
Example
ctx.shared.document.getTextContent()
.then( result => {
console.log(result)
})
.catch( err => {
console.error(err);
});
getTextContentByXpath
Get text content based on the xpath list provided.
Accept an options object containing an array of xpath to collect the text content. The text has newline at end of each paragraph. In the options object it’s possible to specify the hash optional flag. The api returns a promise. If the promise succeeds, it returns an array with the id of the section and an object containing the text content, the attributes of the objects are the list of xpaths provided.
Parameters
Name |
Type |
Required |
Description |
|
{Array} |
Yes |
An array of object specifying the xpath. |
|
{String} |
No |
To return a hash of text content for each single xpath. To be specified in the addTagsByXpath api to verify the document changed since getTextContentByXPath invocation. |
Syntax
ctx.shared.document.getTextContentByXpath({ xpaths: ['/doc/story/grouphead', '/doc/story/summary', '/doc/story/text'], hash: true})
Returns
A promise resolved when the operation is finished
Example
ctx.shared.document.getTextContentByXpath({ xpaths: ['/doc/story/grouphead', '/doc/story/summary', '/doc/story/text'], hash: true})
.then( result => {
console.log(result)
})
.catch( err => {
console.err(err);
});
getXmlContent
Returns the xml content of the document or report. In case of report an array of objects with id and xml attributes is returned.
Syntax
ctx.shared.document.getXmlContent()
Returns
A promise resolved when the operation is finished
Example
ctx.shared.document.getXmlContent()
.then( result => {
console.log(result)
})
.catch( err => {
console.error(err);
});
notifyMetadataChange
Notify the document or the report that the metadata are changed.
Accept a single object parameter and returns a promise.
Parameters
Name |
Type |
Required |
Description |
|
{Object} |
Optional |
If not empty the object can contains the attribute dataId to indentify the metadata field and the attribute newValue to specifiy the new value of the metadata field. |
Syntax
ctx.shared.document.notifyMetadataChange(options)
Returns
A promise resolved when the operation is finished
Example
ctx.shared.document.notifyMetadataChange(options)
.then( result => {
console.log(result)
})
.catch( err => {
console.error(err);
});
save
Save the document in a single editor story case. Save all the report’s documents in the report case.
Accept a single object parameter and returns a promise.
Parameters
Name |
Type |
Required |
Description |
|
{Boolean} |
Optional |
If true close all the report’s documents after save. Ignored in single story editor case. |
Syntax
ctx.shared.document.save({ close })
Returns
A promise resolved when the operation is finished
Example
ctx.shared.document.save({close: true})
.then( result => {
console.log(result)
})
.catch( err => {
console.error(err);
});
selectElement
Select an element from the story editor\report.
Accepts an object parameter to define the selection and returns a promise with information on the selection operation.
Parameters
Name |
Type |
Required |
Description |
|
{Object} |
Yes |
An object with the (optional) property tag for the tag name and an (optional) object property attributes to define the key\values attributes to look up in the selection. If more than one element match the selection criterias the first one will be selected. |
Syntax
ctx.shared.document.selectElement(element)
Returns
A promise resolved when the operation is finished and at least one element is selected. The promise is rejected if no elements are selected.
Example
const element = { tag: "byline", attributes: { id: "U77274655343ool" } };
ctx.shared.document.selectElement(element)
.then((res) => {
console.log(res);
})
.catch((err) => {
console.error(err);
});
Object class methods
List of methods
Name |
Description |
Add the collaborators to an object |
|
Execute an EOMDB action for the current object |
|
Returns the collaborators of an object |
|
Returns the correlations of an object |
|
Returns the object id |
|
Returns the object info |
|
In case of a report or a DWP returns the container of the selected object |
|
In case of a report or a DWP, returns the documents linked. |
|
In case of a report or a DWP, returns the zones and eventually the documents linked to each zone. |
|
Returns the object locker |
|
Returns the metadata of the object |
|
Returns the object name |
|
Returns the object status information |
|
Returns the system attributes of the object, in XML format |
|
Returns the object type |
|
Checks if the object is typeof the given type |
|
Returns the usage tickets of the object |
|
Returns the role information of the object |
|
Returns the virtual attributes of the object, in XML format |
|
Open the current object |
|
Open the current object in Readonly mode |
|
Lock the current object |
|
Unlock the current object |
|
Register to all the EOMDB events of an item |
|
Refresh the current object information |
|
Remove the collaborators of an object |
|
Set the metadata of an object |
|
Update the status of the current object |
|
Set the system attributes of an object |
|
Gets the bundle information of the current object |
|
Unset a metadata field of the current object |
|
Gets the channel copies list of the current object - Restricted for EOM::CompoundStory objects |
|
Create a channel copy of the current object - Restricted for EOM::CompoundStory objects |
addCollaborators
Add the collaborators to an object
Parameters
Name |
Type |
Required |
Description |
|
{String or Array} |
Yes |
A list made of user names. |
|
{Function} |
Optional |
A callback function. See Callback definition for further information. |
Syntax
Object.addCollaborators(collaborators, callback)
Returns
The method returns the an array of collaborators as string.
Example
ctx.getObject('199$1.0.893734064', function(err, Obj) {
if (err) {
ctx.showError(err);
return;
}
Obj.addCollaborators(['user.3', 'user.4'], function(err, data){
if (err) {
ctx.showError(err);
return;
}
// data is now ['user.1', 'user.2', 'user.3', 'user.4'];
var User = ctx.getUserByName(data[0]).getInfo()
});
});
The method can also be called synchronously, but this usage is not recommended.
executeAction
Execute an EOMDB action for the current object
Syntax
Object.executeAction( settings, callback )
Parameters
Name |
Type |
Required |
Description |
|
{String or Object} |
Yes |
If a string is passed, it represents the name of the action to execute. Else, represents a set of arguments. |
|
{Function} |
Yes |
A callback function. See Callback definition for further information. |
|
settings can be either a string or a Javascript Object. If it is a string, it will interpreted as the actionId, and the action will be executed with no other params. Elsewhere, if a Javascript object is passed, the following properties are supported:
|
Returns
The method returns the action response.
Example
ctx.getObject('199$1.0.893734064', function(err, Obj) {
if (err) {
ctx.showError(err);
return;
}
// Or... Obj.executeAction({ actionId: 'postToTwitter', args: 'arguments here');
Obj.executeAction('postToTwitter', function(err, data) {
//.. Do something here.
});
});
The method can also be called synchronously, but this usage is not recommended.
getId
Returns the object id
Syntax
Object.getId()
Returns
The method returns the object id as a string.
Example
ctx.getObject('199$1.0.893734064', function(err, Obj) {
if (err) {
ctx.showError(err);
return;
}
// Well, we already knew that...
var objectId = Obj.getId();
});
getCollaborators
Get the collaborators of an object
Syntax
Object.getCollaborators(callback)
Returns
The method returns the an array of collaborators as string.
Example
ctx.getObject('199$1.0.893734064', function(err, Obj) {
if (err) {
ctx.showError(err);
return;
}
Obj.getCollaborators(function(err, data){
if (err) {
ctx.showError(err);
return;
}
// data is now ['user.1', 'user.2'];
var User! = ctx.getUserByName(data[0]).getInfo()
});
});
The method can also be called synchronously, but this usage is not recommended.
getCorrelations
Get the correlations of an object
Syntax
Object.getCorrelations(linkName, callback)
Parameters
Name |
Type |
Required |
Description |
|
{String} |
Optional |
The name of the linkName to show. |
|
{Function} |
Optional |
A callback function. See Callback definition for further information. |
Returns
The method returns the an array of correlations as Ctx Objects.
Example
ctx.getObject('199$1.0.893734064', function(err, Obj) {
if (err) {
ctx.showError(err);
return;
}
// Without linkName
Obj.getCorrelations(function(err, data){
/*
* With linkName,
* Obj.getCorrelations('see_also', function(err, data){
*/
if (err) {
ctx.showError(err);
return;
}
// data is an array of Objects
for (var j = 0; j < data.length; j++) {
console.log(data.getName());
}
});
});
The method can also be called synchronously, but this usage is not recommended.
getInfo
Returns the object info
Syntax
Object.getInfo()
Returns
The method returns the object information as JSON.
Example
ctx.getObject('199$1.0.893734064', function(err, Obj) {
if (err) {
ctx.showError(err);
return;
}
var objInfo = Obj.getInfo();
// Obj info is now a JSON containing all the information.
});
getContainer
In the context of DWP and Report editor returns the container of the selected object (activeObject).
Syntax
Object.getContainer()
Returns
The method returns the container in the form of Object Class instances.
Example
var container = ctx.activeObject.getContainer();
// container is an Object Class instance.
});
getLinks
In case of a report or a DWP, returns the documents linked.
Syntax
Object.getLinks(callback)
Returns
The method returns the an array of links in the form of Object Class instances.
Example
ctx.getObject('199$1.0.893734064', function(err, Obj) {
if (err) {
ctx.showError(err);
return;
}
Obj.getLinks(function(err, links){
if (err) {
ctx.showError(err);
return;
}
// Each link is an Object Class instance.
// So, it is possible to do so.
for (var j = 0, ln = links.length; j < ln; j++) {
console.log( links[j].getLocker() );
}
});
});
getZones
In case of a report or a DWP, returns the zones and eventually the documents linked to each zone.
Syntax
Object.getZones(options, callback)
Name |
Type |
Required |
Description |
|
{Object} |
Yes |
An optional list of options. See below |
|
{Function} |
Optional |
A callback function. See Callback definition for further information. |
|
The options object is a Javascript object with the following properties:
|
Returns
The method returns an array of zones in the form of Object Class instances.
Example
ctx.getObject('199$1.0.893734064', function(err, Obj) {
if (err) {
ctx.showError(err);
return;
}
Obj.getZones({includeLinks: true}, function(err, zones){
if (err) {
ctx.showError(err);
return;
}
// Each link is an Object Class instance.
// So, it is possible to do so.
for (var j = 0, ln = zones.length; j < ln; j++) {
console.log( zones[j].getInfo() );
var links = zones[j].getLinks();
for (var z = 0, ll = zones.length; z < ll; z++) {
console.log( links[z].getInfo() );
}
}
});
});
getLocker
Returns the object locker
Syntax
Object.getLocker()
Example
ctx.getObject('199$1.0.893734064', function(err, Obj) {
if (err) {
ctx.showError(err);
return;
}
var lockerBy = Obj.getLocker();
});
getMetadata
Returns the metadata of the object
Syntax
Object.getMetadata()
Returns
The method returns the metadata information as String
Example
ctx.getObject('199$1.0.893734064', function(err, Obj) {
if (err) {
ctx.showError(err);
return;
}
var objMetadata = Obj.getMetadata();
var $objMetadata = $.parseXML(objMetadata);
});
getName
Returns the object name
Syntax
Object.getName()
Example
ctx.getObject('199$1.0.893734064', function(err, Obj) {
if (err) {
ctx.showError(err);
return;
}
var name = Obj.getName();
});
getStatusInfo
Returns the object statusInformation
Syntax
Object.getStatusInfo()
Example
ctx.getObject('199$1.0.893734064', function(err, Obj) {
if (err) {
ctx.showError(err);
return;
}
var statusInfo = Obj.getStatusInfo();
// Now
// statusInfo.name is the status name
// statusInfo.comment
// statusInfo.identifier is the RGB color
});
getSystemAttributes
Returns the system attributes of the object, in XML format (as string)
Syntax
Object.getSystemAttributes()
Example
ctx.getObject('199$1.0.893734064', function(err, Obj) {
if (err) {
ctx.showError(err);
return;
}
var objSysAttr = Obj.getSystemAttributes();
var $sysAttr = $.parseXML(objSysAttr);
});
Use the refresh method to get up to date object information before call this method.
getType
Returns the object type
Syntax
Object.getType()
Example
ctx.getObject('199$1.0.893734064', function(err, Obj) {
if (err) {
ctx.showError(err);
return;
}
var type = Obj.getType();
});
isType
Checks if the object is typeof the given type
Syntax
Object.isType(testtype)
Parameters
Name |
Type |
Required |
Description |
|
{String} |
Yes |
The type to test against the object type. |
Returns
The method returns true if and only if the object type is type of the testtype else the method returns false.
Example
ctx.getObject('199$1.0.893734064', function(err, Obj) {
if (err) {
ctx.showError(err);
return;
}
var type = Obj.isType('EOM::Story');
});
getUsageTicket
Returns the usage tickets of the object, as an XML String
Syntax
Object.getUsageTicket()
Example
ctx.getObject('199$1.0.893734064', function(err, Obj) {
if (err) {
ctx.showError(err);
return;
}
var usageTicket = Obj.getUsageTicket();
var $usageTicket = $.parseXML(usageTicket);
});
Use the refresh method to get up to date object information before call this method.
getRoles
Returns the roles information of the object, as an XML String
Syntax
Object.getRoles(settings, callback)
Parameters
Name |
Type |
Required |
Description |
|
{JSON} |
Yes |
The roles settings to retrieve:
|
|
{Function} |
Optional |
A callback function. See Callback definition for further information. |
Returns
The method returns the roles information as XML String.
Example
ctx.getObject('199$1.0.893734064', function(err, Obj) {
if (err) {
ctx.showError(err);
return;
}
Obj.getRoles({roleType: 'EOM::WebContainerLinks', roleName: '1.0.232702264'}, function(err, role){
if (err) {
ctx.showError(err);
return;
}
console.log(role);
});
});
getVirtualAttributes
Returns the virtual attributes of the object, as an XML String
Syntax
Object.getVirtualAttributes()
Example
ctx.getObject('199$1.0.893734064', function(err, Obj) {
if (err) {
ctx.showError(err);
return;
}
var virtualAttributes = Obj.getVirtualAttributes();
var $virtualAttributes = $.parseXML(virtualAttributes);
});
Use the refresh method to get up to date object information before call this method.
open
Open the current object in editing mode
Syntax
Obj.open( id, callback )
Parameters
Name |
Type |
Required |
Description |
|
{Function} |
Optional |
A callback function. See Callback definition for further information. |
Returns
The methods does not return any information. The callback is called when the document is opened.
Example
ctx.getObject('199$1.0.893734064', function(err, Obj) {
if (err) {
ctx.showError(err);
return;
}
Obj.open(function(err, data) {
// Callback after the document is opened
});
});
lock
Lock the current document
Syntax
Obj.lock( callback )
Parameters
Name |
Type |
Required |
Description |
|
{Function} |
Optional |
A callback function. See Callback definition for further information. |
Returns
The methods does not return any information. The callback is called when the document is locked.
Example
ctx.getObject('199$1.0.893734064', function(err, Obj) {
if (err) {
ctx.showError(err);
return;
}
Obj.lock(function(err, data) {
// Callback after the document is locked
});
});
unlock
Unlock the current document
Syntax
Obj.unlock( callback )
Parameters
Name |
Type |
Required |
Description |
|
{Function} |
Optional |
A callback function. See Callback definition for further information. |
Returns
The methods does not return any information. The callback is called when the document is unlocked.
Example
ctx.getObject('199$1.0.893734064', function(err, Obj) {
if (err) {
ctx.showError(err);
return;
}
Obj.unlock(function(err, data) {
// Callback after the document is unlocked
});
});
openReadonly
Open the current document in Readonly mode
Syntax
Obj.openReadonly( callback )
Parameters
Name |
Type |
Required |
Description |
|
{Function} |
Optional |
A callback function. See Callback definition for further information. |
Returns
The methods does not return any information. The callback is called when the document is opened.
Example
ctx.getObject('199$1.0.893734064', function(err, Obj) {
if (err) {
ctx.showError(err);
return;
}
Obj.openReadonly(function(err, data) {
// Callback after the document is opened
});
});
registerToEvents
Register to all the EOMDB events of an item
Syntax
Obj.registerToEvents(eventCallback)
Parameters
Name |
Type |
Required |
Description |
|
{Function} |
Yes |
A callback function which is called at any event. See the example for further information. |
Example
ctx.getObject('199$1.0.893734064', function(err, Obj) {
if (err) {
ctx.showError(err);
return;
}
// Register to all the events.
Obj.registerToEvents(function(eventName, data) {
// eventName contains the name of the event
// "unlock", "lock", "check in"...
// data contains the information regarding the event.
// Eventually, if needed, call a refresh for the object.
Obj.refresh().getLocker();
});
});
refresh
Refresh the current object information and returns a new Object class.
Syntax
Obj.refresh()
Returns
Type |
Description |
{Object class} |
An instance of the Object Class. See Object class methods for further information on the methods available. |
Example
ctx.getObject('199$1.0.893734064', function(err, Obj) {
if (err) {
ctx.showError(err);
return;
}
// Perform very complex operations
// Such as saving the document or setting the document metadata
// To obtain the new metadata... do this.
Obj = Obj.refresh();
Obj.getMetadata();
});
removeCollaborators
Remove the collaborators from an object
Parameters
Name |
Type |
Required |
Description |
|
{String or Array} |
Yes |
A list made of user names. |
|
{Function} |
Optional |
A callback function. See Callback definition for further information. |
Syntax
Object.removeCollaborators(collaborators, callback)
Returns
The method returns the an array of collaborators as string.
Example
ctx.getObject('199$1.0.893734064', function(err, Obj) {
if (err) {
ctx.showError(err);
return;
}
Obj.removeCollaborators(['user.1'], function(err, data){
if (err) {
ctx.showError(err);
return;
}
// data is now ['user.1'];
var User = ctx.getUserByName(data[0]).getInfo()
});
});
The method can also be called synchronously, but this usage is not recommended.
setMetadata
Set the metadata of an object
Syntax
Obj.setMetadata(options, callback);
Parameters
Name |
Type |
Required |
Description |
|
{Object or Array} |
Yes |
An object made of xpath and content properties. Can be an array of those properties. |
|
{Function} |
Optional |
A callback function. See Callback definition for further information. |
Example
ctx.getObject('199$1.0.893734064', function(err, Obj) {
if (err) {
ctx.showError(err);
return;
}
var request = { xpath: '/ObjectMetadata/General/Priority', content: 'High title'};
// Or an array
// var request = [ { xpath: '/ObjectMetadata/General/Priority', content: 'High title'},
{ xpath: '/ObjectMetadata/General/Priority2', content: 'High title2'}
{ xpath: '/ObjectMetadata/General/Priority3', content: 'High title3'} ];
Obj.setMetadata(request, function(err, data) {
if (err) {
ctx.showError(err);
return;
}
// Success...
});
});
The method can also be called synchronously, but this usage is not recommended.
setStatus
Update the status of the current object
Syntax
Obj.setStatus('NewsFlow/Editing', callback);
Obj.setStatus({ name: 'NewsFlow/Editing', comment: 'My comment'}, callback)
Returns
Type |
Description |
{Object class} |
An instance of the Object Class. See Object class methods for further information on the methods available. |
Example
ctx.getObject('199$1.0.893734064', function(err, Obj) {
if (err) {
ctx.showError(err);
return;
}
Obj.setStatus('NewsFlow/Editing', function(err, data) {
if (err) {
ctx.showError(err);
return;
}
// Success...
});
});
The method can also be called synchronously, but this usage is not recommended.
setSystemAttributes
Set the system attributes of an object
Syntax
Obj.setSystemAttributes(options, callback);
Parameters
Name |
Type |
Required |
Description |
|
{Object or Array} |
Yes |
An object made of xpath and content properties. Can be an array of those properties. |
|
{Function} |
Optional |
A callback function. See Callback definition for further information. |
Example
ctx.getObject('199$1.0.893734064', function(err, Obj) {
if (err) {
ctx.showError(err);
return;
}
var request = { xpath: '/props/title/', content: 'High title'};
// Or an array
// var request = [ { xpath: '/props/title/', content: 'High title'},
{ xpath: '/props/summary/', content: 'Summary'} ];
Obj.setSystemAttributes(request, function(err, data) {
if (err) {
ctx.showError(err);
return;
}
// Success...
});
});
The method can also be called synchronously, but this usage is not recommended.
cleanMetadataField
Unset a metadata field of the current object
Syntax
Obj.cleanMetadataField(xpath, callback);
Parameters
Name |
Type |
Required |
Description |
|
{String} |
Yes |
A metadata field xpath to remove. |
|
{Function} |
Optional |
A callback function. See Callback definition for further information. |
Example
ctx.getObject('199$1.0.893734064', function(err, Obj) {
if (err) {
ctx.showError(err);
return;
}
Obj.cleanMetadataField('/ObjectMetadata/General/Priority', function(err, data) {
if (err) {
ctx.showError(err);
return;
}
// Success...
});
});
The method can also be called synchronously, but this usage is not recommended.
getBundleInfo
Gets the bundle information of the current object
Syntax
Obj.getBundleInfo(callback);
Parameters
Name |
Type |
Required |
Description |
|
{Function} |
Optional |
A callback function. See Callback definition for further information. |
Returns
The bundle information:
[
{
"id": "99$1.0.287059148",
"name": "Obama.xml",
"baseName": "Obama",
"path": "/Globe/Stories/Globe/Stories/Politics/2019-03-18/Politics/Obama.xml",
"channel": "Globe-Web",
"edition": null,
"section": null,
"issueDate": "20190318",
"subFolder": null,
"workFolder": "/Globe/Politics",
"channelIdentifier": "Globe-Web"
},
{
"id": "99$1.0.287059376",
"name": "Obama@Globe-Print-USA.xml",
"baseName": "Obama@Globe-Print-USA",
"path": "/Globe/Stories/Globe/Stories/Politics/2019-03-18/Politics/Obama.xml/Obama@Globe-Print-USA.xml",
"channel": "Globe-Print",
"edition": "USA",
"section": null,
"issueDate": "20190318",
"subFolder": null,
"workFolder": "/Globe/Politics",
"channelIdentifier": "Globe-Print/USA"
}
]
Example
ctx.activeObject.getBundleInfo(function(err, list) {
if (err) {
ctx.showError(err);
return;
}
//Success
});
The method can also be called synchronously, but this usage is not recommended.
getChannelCopiesList
Gets the channel copies list of the current object - Restricted for EOM::CompoundStory objects
Syntax
Obj.getChannelCopiesList(callback);
Parameters
Name |
Type |
Required |
Description |
|
{Function} |
Optional |
A callback function. See Callback definition for further information. |
Returns
The list of the created channel copies:
[
{
"id": "41$1.0.107332121",
"channel": null,
"info": {
"id": "41$1.0.107332121",
"name": "story.xml",
"baseName": "story",
"path": "/Globe/Stories/Art/story.xml",
"channel": null,
"edition": null,
"section": null,
"issueDate": "20190111",
"subFolder": null,
"workFolder": "/Globe/Art",
"channelIdentifier": "none"
},
"master": true
},
{
"id": "41$1.0.107314527",
"channel": "Globe-Print",
"info": {
"id": "41$1.0.107314527",
"name": "story@Globe-Print.xml",
"baseName": "story@Globe-Print",
"path": "/Globe/Stories/Art/story.xml/story@Globe-Print.xml",
"channel": "Globe-Print",
"edition": null,
"section": null,
"issueDate": "20190111",
"subFolder": null,
"workFolder": "/Globe/Art",
"channelIdentifier": "Globe-Print"
}
}
]
Example
ctx.activeObject.getChannelCopiesList(function(err, list) {
if (err) {
ctx.showError(err);
return;
}
//Success
});
The method can also be called synchronously, but this usage is not recommended.
createChannelCopy
Create a channel copy of the current object - Restricted for EOM::CompoundStory objects
Syntax
Obj.createChannelCopy(channel, callback);
Parameters
Name |
Type |
Required |
Description |
|
{String} |
Yes |
A string containing the channel in form of "Product/Edition". |
|
{Function} |
Optional |
A callback function. See Callback definition for further information. |
Returns
The method returns the object information of the new channel copy as JSON.
Example
ctx.activeObject.createChannelCopy('Product/Edition', function(err) {
if (err) {
ctx.showError(err);
return;
}
//Success
});
The method can also be called synchronously, but this usage is not recommended.
User class methods
List of methods
Name |
Description |
Returns the user groups |
|
Returns the user info |
|
Returns the usermetadata |
|
Returns the username |
|
Returns the system attributes of the user, in XML format |
|
Returns the user teams. |
|
Sets the system attributes of the user |
|
Sets the metadata of the user |
getGroups
Returns the groups which the user belongs to
|
The method returns an error for users other than the current one. |
Syntax
User.getGroups( [callback] )
Parameters
Name |
Type |
Required |
Description |
|
{Function} |
Optional |
A callback function. See Callback definition for further information. |
Example
ctx.getCurrentUser(function(err,User) {
var groups = User.getGroups();
console.log(teams);
});
The method can be called either synchronously or asynchronously. It is indifferent.
getInfo
Returns the user info
Syntax
User.getInfo( [callback] )
Parameters
Name |
Type |
Required |
Description |
|
{Function} |
Optional |
A callback function. See Callback definition for further information. |
Returns
The user information in JSON.
{
"name": "john.doe",
"description": "Star Software",
"ucount": 13159,
"databaseId": 199,
"id": "1.0.532488046",
"fullName": "John Doe",
"phoneNumber": "(01) 5748584456)",
"mobileNumber": "(001) 5476987496798)",
"twitter": "johndoe",
"role": "Reporter",
"homeEmail": "john.doe@google.com",
"businessEmail": "john.doe@star.com",
"statusMessage": "I am available",
"workDir": "workFolder:///Globe/Art",
"location": "London",
"lastLoggedOn": 1494418598,
"initials": "JD",
"signature": "john doe",
"homePath": "/Users/john.doe",
"calendars": [
{
"color": "#32AE0C",
"id": "U12001806763ERC",
"name": "UK Holidays",
"url": "https://www.gov.uk/england-and-wales.ics",
"icon": "icon-calendar",
"private": false
}
],
"status": "busy",
"disabled": false
}
Example
ctx.getCurrentUser(function(err,User) {
var userInfo = User.getInfo();
// Or, if you prefer,
User.getInfo(function(err, userInfo){
console.log(userInfo.name);
});
});
The method can be called either synchronously or asynchronously. It is indifferent.
getMetadata
Returns the user metadata, as a string.
|
The method returns an error for users other than the current one. |
Syntax
User.getMetadata( [callback] )
Parameters
Name |
Type |
Required |
Description |
|
{Function} |
Optional |
A callback function. See Callback definition for further information. |
Example
ctx.getCurrentUser(function(err,User) {
var metadata = User.getMetadata();
console.log(metadata);
});
The method can be called either synchronously or asynchronously. It is indifferent.
getName
Returns the user name
Syntax
User.getName( [callback] )
Parameters
Name |
Type |
Required |
Description |
|
{Function} |
Optional |
A callback function. See Callback definition for further information. |
Returns
The user name as string.
Example
ctx.getCurrentUser(function(err,User) {
var userName = User.getName();
console.log(userName);
});
The method can be called either synchronously or asynchronously. It is indifferent.
getSystemAttributes
Returns the system attributes of the user, in XML format (as string)
|
The method returns an error for users other than the current one. |
Syntax
User.getSystemAttributesXML( [callback] )
Parameters
Name |
Type |
Required |
Description |
|
{Function} |
Optional |
A callback function. See Callback definition for further information. |
Returns
The system attributes of the User, as a XML string.
Example
ctx.getCurrentUser(function(err,User) {
var systemAttributesXml = User.getSystemAttributes();
var $sysAttr = $.parseXML(systemAttributesXml);
console.log(systemAttributesXml);
});
The method can be called either synchronously or asynchronously. It is indifferent.
getTeams
Returns the teams which the user belongs to
|
The method returns an error for users other than the current one. |
Syntax
User.getTeams( [callback] )
Parameters
Name |
Type |
Required |
Description |
|
{Function} |
Optional |
A callback function. See Callback definition for further information. |
Example
ctx.getCurrentUser(function(err,User) {
var teams = User.getTeams();
console.log(teams);
});
The method can be called either synchronously or asynchronously. It is indifferent.
setSystemAttributes
Sets the system attributes of the user
|
The method returns an error for users other than the current one. |
Syntax
User.setSystemAttributes( systemAttributes, [callback] )
Parameters
Name |
Type |
Required |
Description |
|
{String or object} |
Yes |
A string or an object to represent the system attributes |
|
{Function} |
Optional |
A callback function. See Callback definition for further information. |
Returns
The system attributes of the User, as a XML string.
Example
ctx.getCurrentUser(function(err,User) {
var systemAttributes = '<props><principalInfo><email type="business">johndoe@star.comw</email><initials>JD</initials><signature>john doe</signature><statusMessage>I am available</statusMessage><color type="revision" value="#008080"/><color type="annotation" value="#800000"/><location>London</location><email type="home">johndoe@google.com</email><twitter>johndoe</twitter><facebook>aaaa</facebook><mobileNumber>(01) 7834684587438</mobileNumber><phoneNumber>(001) 54753754765375</phoneNumber><status>busy</status><workDir>workFolder:///Globe/Art</workDir><calendar><id>U12001806763ERC</id><icon>icon-calendar</icon><color>#32AE0C</color><name>UK Holidays</name><url>https://www.gov.uk/bank-holidays/england-and-wales.ics</url><private>false</private></calendar></principalInfo><role>Reporter</role><OutputChannels><channel name="Globe-Print"/></OutputChannels></props>';
User.setSystemAttributes(systemAttributes, function(err, data) {
if (err) {
// Do something...
return;
}
);
});
setMetadata
Sets the metadata of the user
|
The method returns an error for users other than the current one. |
Syntax
User.setMetadata( metadata, [callback] )
Parameters
Name |
Type |
Required |
Description |
|
{String or object} |
Yes |
A string or an object to represent the metadata |
|
{Function} |
Optional |
A callback function. See Callback definition for further information. |
Returns
The system attributes of the User, as a XML string.
Example
ctx.getCurrentUser(function(err,User) {
var attributes = '<test><secondtest>hello</secondtest></test>';
User.setMetadata(attributes, function(err, data) {
if (err) {
// Do something...
return;
}
);
});
activeObject
In various contexts, such as the toolbars, editors, Diagram workflow, etc., there is an additional property available, named activeObject.
The activeObject is actually an instance of the Object Class and contains all methods of this class. See Object class methods for further information.
To be compliant with object panel bulk mode please use activeObjects array property.
|
The old activeObj property is being discontinued from Swing 4 and will not be available in Prime. Please use the new activeObject property instead. |
activeObjects
Same as activeObject but returned as an array of all selected items. In single mode array length is 1.
activeDocument
*Deprecated: please use activeDocumentV2
Inside the editor context, it is possible to access the activeDocument. Please refer to Editor API methods reference.
activeDocumentV2
Starting form version 5.2020.11 inside the editor context, it is possible to access the activeDocumentV2. Api(s) from this object are cross platform compatible (Swing, Swing Mobile, Prime).
Please refer to Editor API methods reference.
Callback definition
|
The callback parameter, when specified, is always defined as follows:
|