Documentation Center

Available services

The customization SDK contains several UI services that you can inject as require dependencies. These services are located in the sdk/services namespace.

UrlService (sdk/services/urlService)

This service performs URL-related operations.
Method nameMethod return typeDescription
getSdkUrl(relativeUrl)string

This method returns a full URL from a specified relative URL. It is useful in situations where you need to refer to an image or to other resources that are packed together with your customization.

The relativeUrl parameter should have the following format: <customization folder name>/ <resource name>. For example, urlService.getSdkUrl('mycustomization/icon.svg').

DialogService (sdk/services/dialog/dialogService)

This service displays modal dialog boxes.
Method nameMethod return typeDescription
showDialog(templateLoader, templateId, options)promiseThis method is used to display modal dialog boxes.
  • The templateLoader parameter specifies either an HTML string or a promise that produces an HTML string.
  • The templateId parameter specifies a unique ID for the template.
  • The options parameter is an object that specifies the look and behavior options for the modal dialog box.
{
    title: string,
    isFullScreen: boolean,
    dialogSize: DialogSize 
    okButton: {
        text: string,
        isVisible: boolean,
        // a promise that will be executed when the user pressed the OK button
        onClick: promise       
    },
    cancelButton: {
        text: string,
        isVisible: boolean,
        // a promise that will be executed when the user presses the Cancel button
        onClick: promise       
    },
    extraButtons: [{
        text: 'Fly',
        visible: true,
        onClick: onFly
    }]
}
This method returns a promise. The result of the promise is an object that has the following structure:
{
    // Specifies whether the user pressed the OK or Cancel button
    userAction: DialogResult,
    // The result of the ok/cancel promise, if one was supplied.
    result: object
}
Example:
dialogService.showDialog('<span>Hello Dialog</span>', 'hello-dialog-id', { title: 'Hello' })
             .then(function(dialogResult) {
                    if (dialogResult.userAction === DialogResult.OK) {
                        alert('user pressed OK');
                    } else {
                        alert('user pressed cancel');
                    }
              });
changeCurrentDialogOptions(options)void

Use this method to change the look and feel of an existing modal dialog box and call it after an existing modal dialog box has been displayed.

The options parameter has the same format as the one used in the showDialog method.

closeDialogvoid

Use this method to close an existing modal dialog box and call it after an existing modal dialog box has been displayed.

DialogSize (sdk/services/dialog/DialogSize)

This service defines the size of the dialog box displayed. Possible values are:
  • Small
  • Medium
  • Large

DialogResult (sdk/services/dialog/DialogResult)

This service defines the action that the user has performed in the dialog box. Possible values are:
  • OK
  • CANCEL

AjaxService (sdk/services/ajaxService)

This service performs REST API operations.
Method nameMethod return typeDescription
getData(apiCall, options)promise

This method performs a GET operation on the REST API.

The apiCall parameter specifies which endpoint should be used. The options parameter specifies options for the REST API call.

Here is an example of options for a tasks GET call that returns a list of tasks:
{
    // restrict the fields for each task object to the fields specified below
    fields : 'id,taskNumInProject,currentTaskStep(workflowTransitions(id,text)),assets,targetLocale',
    // return only tasks with the ids specified below
    ids : tasksIds.join(','),
    // return only the first 1000 records
    offset : 0,
    limit : 1000
}
GET example:

options = { offset : 0, limit : 1000 }

ajaxService.getData(ApiCall.LOCALES.withParams(''), options)
postData(apiCall, data)promise

This method performs a POST operation on the REST API. The apiCall parameter specifies which endpoint should be used. The data parameter specifies the JSON data to be posted.

For example:
ajaxService.postData(ApiCall.PROJECT_GROUPS_SEARCH.withParams(["id, name&offset=0&limit=100&sortBy=id&sortDirection=asc&viewMode=100"]),
'{"operator":"and","filters":[{"field":"description","value":"Group","operator":"like"}]}')
putData(apiCall, data)promise

This method performs a PUT operation on the REST API. The apiCall parameter specifies which endpoint should be used. The data parameter specifies the JSON data to be put.

For example:
ajaxService.putData(ApiCall.USER_PROFILE_PREFS, '[{"key":"projectGroupColumns","value":"claimedTasks,name,sourceLocale,canceledTasks,workgroup"}]')
deleteData(apiCall, data)promiseThis method performs a DELETE operation on the REST API. The apiCall parameter specifies which endpoint should be used. The data parameter specifies the entity to be deleted.
For example:
ajaxService.deleteData(ApiCall.USER_MULTISEARCH_MANAGE_FILTER.withParams([2, "projectGroupFilters"]),'{"key:projectGroupFilters}]}')
patchData(apiCall, data)promiseThis method performs a PATCH operation on the REST API. The apiCall parameter specifies which endpoint should be used. The data parameter specifies the JSON data to be patched.
For example:
ajaxService.patchData(ApiCall.USER_MULTISEARCH_MANAGE_FILTER.withParams([4, "projectGroupFilters"]),'{"resource":"PROJECT_GROUP","name":"test5","filter":{"operator":"and","filters":[{"field":"name","value":"updated value","operator":"like"}]}}')

ApiCall (sdk/services/ApiCall)

This service is an enumeration of possible endpoints.
Method nameMethod return typeDescription
withParams(param1, param2, ...)ApiCall

This method fills parameter values for parameterized endpoints.

For example, to GET a specific project, you would make a call to the following endpoint: /projects/%s, where %s is the project ID.
ApiCall.PROJECT.withParams(projectId)
The following is the list of all supported methods (ApiCall - REST API endpoint correspondence):
  • ApiCall.PROJECT_GROUP_STATISTICS = "/projectGroups/statistics"
  • ApiCall.PROJECT_STATISTICS = "/projects/statistics"
  • ApiCall.PROJECTS = "/projects"
  • ApiCall.PROJECT_COMPLETE = "/projects/complete"
  • ApiCall.PROJECT_CANCEL = "/projects/cancel"
  • ApiCall.PROJECT_STEP_REDO = "/projects/redo"
  • ApiCall.PROJECT = "/projects/%s"
  • ApiCall.PROJECTSEARCH = "/projects/search"
  • ApiCall.PROJECT_SCOPING = "/projects/%s/scoping"
  • ApiCall.PROJECT_GROUP_SCOPING = "/projectGroups/%s/scoping"
  • ApiCall.SCOPING_ASSETS = "/projects/%s/scopedAssets"
  • ApiCall.TASKS = "/tasks"
  • ApiCall.TASK = "/tasks/%s"
  • ApiCall.TASK_HISTORY = "/taskHistory?taskId=%s"
  • ApiCall.TASKSEARCH = "/tasks/search?fields=%s"
  • ApiCall.TASK_CLAIM = "/tasks/claim"
  • ApiCall.TASK_UNCLAIM = "/tasks/unclaim"
  • ApiCall.TASK_INCLUDE_COST = "/tasks/includeCost"
  • ApiCall.TASK_EXCLUDE_COST = "/tasks/excludeCost"
  • ApiCall.TASK_STEP_COMPLETE = "/tasks/complete"
  • ApiCall.TASK_STEP_CHANGE_ASSIGNEES = "/tasks/changeAssignees"
  • ApiCall.MOVE_TASKS = "/tasks/move"
  • ApiCall.IMPORT_TASKS = "/tasks/import"
  • ApiCall.EXPORT_TASKS = "/tasks/export"
  • ApiCall.TASK_STEP_REDO = "/tasks/redo"
  • ApiCall.TASKS_FOR_PROJECT = "/tasks?projectId=%s"
  • ApiCall.CANCEL_TASKS = "/tasks/cancel"
  • ApiCall.PROJECT_ATTRIBUTES = "/projectAttributes"
  • ApiCall.PROJECT_TYPES = "/projectTypes"
  • ApiCall.PROJECT_TYPE = "/projectTypes/%s"
  • ApiCall.RFQS = "/rfqs"
  • ApiCall.USER_PROFILE_PREFS = "/users/me/profilePreferences"
  • ApiCall.USER_MULTISEARCH_FILTERS = "/searchFilters"
  • ApiCall.USER_MULTISEARCH_CREATE_FILTER = "/searchFilters?key=%s"
  • ApiCall.USER_MULTISEARCH_MANAGE_FILTER = "/searchFilters/%s?key=%s"
  • ApiCall.USER_DETAILS = "/users/me/details"
  • ApiCall.PROJECT_GROUP = "/projectGroups/%s"
  • ApiCall.PROJECT_GROUP_CUSTOM_ATTRIBUTES = "/projectGroups/%s?fields=%s"
  • ApiCall.PROJECT_GROUPS = "/projectGroups"
  • ApiCall.PROJECT_GROUPS_SEARCH = "/projectGroups/search?fields=%s"
  • ApiCall.FILES = "/files"
  • ApiCall.DOWNLOAD_ASSETS = "/files/assets"
  • ApiCall.DOWNLOAD_ASSET = "/files/asset"
  • ApiCall.VERIFY_DOWNLOAD_ASSETS = "/files/assets/verify"
  • ApiCall.CLIENTS = "/clients"
  • ApiCall.LOCALES = "/locales"
  • ApiCall.COLUMNS = "/columns"
  • ApiCall.CREATE_PROJECT = "/projectGroups/create"
  • ApiCall.ATTRIBUTES = "/attributeDefinitions"
  • ApiCall.ATTRIBUTE_VALUES = "/attributeValues"
  • ApiCall.USER_ACTION_PERMISSIONS = "/users/me/permissions"
  • ApiCall.PROJECT_DETAILS = "/projects/%s/details"
  • ApiCall.PROJECT_GROUP_DETAILS = "/projectGroups/%s/details"
  • ApiCall.WORKFLOWS = "/workflows"
  • ApiCall.WORKFLOW = "/workflows/%s"
  • ApiCall.WORKFLOW_IMAGE = "/workflows/%s/image"
  • ApiCall.JOB = "/jobs/%s"
  • ApiCall.JOBS = "/jobs"
  • ApiCall.NOTIFICATIONS = "/notifications"
  • ApiCall.DOWNLOAD = "/download/%s"
  • ApiCall.ATTRIBUTE_ATTACHMENT = "/files/attachments"
  • ApiCall.TRANSLATE_IN_STUDIO_JOBS = "/jobs/%s"
  • ApiCall.CONFIG = "/config"
  • ApiCall.EXPORT = "/export"
  • ApiCall.USERS = "/users"
  • ApiCall.ROLES = "/workflowRoles"
  • ApiCall.LINGUISTIC_FILTERS = "/linguisticFilters"
  • ApiCall.ISSUES = "/issues"
  • ApiCall.USER_STATISTICS = "/users/me/statistics"
  • ApiCall.ANNOUNCEMENTS = "/announcements"
  • ApiCall.CUSTOMIZATIONS = "/customizations"
  • ApiCall.DOWNLOAD_SCOPING_INFO = "/projects/%s/scoping/download"
  • ApiCall.DOWNLOAD_PG_SCOPING_INFO = "/projectGroups/%s/scoping/download"
  • ApiCall.COST_MODEL = "/costModels"
  • ApiCall.QUALITY_MODEL = "/qualityModels"
  • ApiCall.WORKGROUPS = "/workgroups"
  • ApiCall.CREATE_PROJECT_FOR_TASK = "/projects/createForTask"
  • ApiCall.ADAPTER_CONFIGURATIONS = "/adapterConfigurations"
  • ApiCall.ADAPTER_CONFIGURATION = "/adapterConfigurations/%s"
  • ApiCall.GET_ADAPTER_CONFIGURATION = "/adapterConfigurations/%s?adapterName=%s"

ProjectsViewService (sdk/services/views/projectsViewService)

Use this service to obtain details about the information currently displayed in the Projects view.
Method nameMethod return typeDescription
getSelectedProjectsIds()arrayThis method returns an array with the IDs of the currently selected projects.
getSelectedProjectGroupsIds()arrayThis method returns an array with the IDs of the currently selected project groups.
getVisibleProjectIds()arrayThis method returns an array with the IDs of the currently visible projects.
getVisibleProjectGroupsIds()arrayThis method returns an array with the IDs of the currently visible project groups.
getVisibleColumns()arrayThis method returns an array with the metadata of the currently visible columns.

TasksViewService (sdk/services/views/tasksViewService)

Use this service to obtain details about the information currently displayed in the Tasks view.
Method nameMethod return typeDescription
getSelectedTasksIds()arrayThis method returns an array with the IDs of the currently selected tasks.
getVisibleTasksIds()arrayThis method returns an array with the IDs of the currently visible tasks.
getVisibleColumns()arrayThis method returns an array with the metadata of the currently visible columns.
getTasksParent() objectThis method returns an object with the current task's parent type and ID.

MessageBus (sdk/services/messaging/messageBus)

Use this service to get notifications when important events occur on a page.
Method nameMethod return typeDescription
subscribe(onMessageCallback, messageType)voidThe onMessageCallback parameter specifies a function to be executed when the event occurs. The messageType parameter specifies the type of event to which to subscribe.

MessageType (sdk/services/messaging/messageType)

This service specifies the type of message to which to subscribe using the MessageBus.
Method nameDescription
TasksDataLoadedShown when the information about tasks has finished loading on the Tasks page.
SelectedTasksChangedShown when the current task selection has changed on the Tasks page.
ProjectsDataLoadedShown when the information about projects has finished loading on the Projects page.
SelectedProjectsChangedShown when the current project selection has changed on the Projects page.