Pergapedia / SSP7
SMTX SupportSMTX Wiki
  • Introduction
  • Pergapedia / SSP7 Admin guide
  • Catalog
    • Typical use cases
      • Usage as Knowledge Catalog
      • Usage as Data Catalog
      • Usage as Service Catalog
    • Catalog Maintenance
      • Templates
        • Create a new template
        • Version management of templates
        • ACL (Access Control Lists)
          • Scopes
          • Add default ACLs
          • Remove All ACLS
          • ACL condition script examples
        • Set translation label for Publication request button
      • Parts (Fields)
        • Field types
        • Calculations
        • Field Validation examples
        • Field Visibility Examples
        • Field Filtering
        • Default value
      • Actors
      • Reusable content
      • Settings
      • General Settings
      • Roles
      • Javascript for Variables in processes
      • Action Forms
        • Add log entries for Action Forms
    • Service Maintenance
      • Services
        • Filter list of services
        • Duplicating services
        • Adding a new service
        • Service Details
          • General settings
          • Service Data
          • Contracts
          • Actors
          • Receivers
          • Targets
          • Support Groups
          • Relations
          • Requests
          • Quality Notes
          • Publication History
          • Documents
          • Log
          • Service Actions
        • Compare versions
        • Quality Notes
        • Service Changed flag
      • Approvals
      • Relations
        • Start service from service
      • Subscriptions
      • Outages
    • Public
    • Service Catalog API
      • Outbound REST API
        • Get Services
        • Get Service Details
      • Inbound SOAP calls
        • Create custom approval
        • Add log to service publish request
        • Add person to service person list
        • Add persongroup to service persongroup list
        • Delete service
        • Mark service publish request as in approval state
        • Process service publish request
        • Publish request set can be cancelled
        • Publish request set show in public
        • Remove person from service person list
        • Remove persongroup from service persongroup list
        • Remove support group from service
        • Update service field
        • Update service language field
        • Update template part datetime value
        • Update template part numeric value
        • Update template part text value
  • Fulfillment Platform
    • Admin Panel
    • General Settings
      • General
      • My Profile
      • Mail Settings
      • Login
      • Forms Setting
      • Workflow
      • Archive
      • Calendar Overview
      • Dashboard
      • Mobile Component
      • Ticketing
      • Webhooks
      • Goto
      • Search options
      • Application URL Settings
      • Address Book Settings
    • Dashboard
    • Categories
    • Topics
    • Forms
      • Fields-tab
      • Field: General Settings
      • Dynamic Value
      • Text (Area) Field
      • Yes : No Field
      • Upload file(s)
      • Date (Time) Field
      • Password Field
      • Read Only Display Field
      • Header
      • Tab
      • Section
      • Repeatable section buttons
      • Subform
      • Static HTML
      • Hidden Field
      • Selection Fields
      • Calculations
    • Processes
      • General Settings
      • Dynamic Field Mapping
      • Process Steps
      • Step Types
      • Logging
    • Datastore
      • Process interaction
      • Manage datastore entries via Webservices - Javascript
    • Tasks
    • Auto Forms
    • Adapters
      • Person Data
      • Web Services
    • Event triggers
    • Roles
    • Rolesets
    • Groups
    • Views
      • View Example 1
      • View example 2
    • Mail Templates
    • Layouts
    • Mail queue
    • Reporting
    • External Apps
    • My Items
    • Translations
    • Bulk Uploads
    • Help page
    • Goto
    • Search
    • Inbound Email
    • Reporting Dashboard
    • Ticketing
      • My Activities
      • Ticketing Views
      • External Integrations
    • Release Manager
    • Content Management Console module
    • SSP Studio
    • Persons & Accounts
    • Pools
  • Release Notes
    • Terms and Conditions
      • December 2024
    • Release 7.21.01
    • Release 7.21.03
    • Release 7.21.04
    • Release 7.21.05
    • Release 7.21.06
    • Release 7.21.07
    • Release 7.21.08
    • Release 7.21.09
    • Release 7.21.10
    • Release 7.21.11
    • Release 7.21.12
    • Release 7.22.02
    • Release 7.22.03
    • Release 7.22.04
    • Release 7.22.05
    • Release 7.22.06
    • Release 7.22.07
    • Release 7.22.08
    • Release 7.22.09
    • Release 7.22.10
    • Release 7.22.12
    • Release 7.23.01
    • Release 7.23.02
    • Release 7.23.03
    • Release 7.23.04
    • Release 7.23.05
    • Release 7.23.07
    • Release 7.23.08
    • Release 7.23.09
    • Release 7.23.10
    • Release 7.23.11
    • Release 7.23.12
    • Release 7.24.02
    • Release 7.24.03
    • Release 7.24.04
    • Release 7.24.05
    • Release 7.24.06
    • Release 7.24.07
    • Release 7.24.08
    • Release 7.24.09
    • Release 7.24.10
    • Release 7.24.11
    • Release 7.24.12
    • Release 7.25.01
    • Release 7.25.02
    • Release 7.25.03
    • Release 7.25.04
    • Release 7.25.05
  • Guides
    • Installation Guide
      • Scheduled Task installation
    • Upgrade Guide
    • LDAP Import
    • Training
      • Exercise : Create a new form
      • Exercise : Create a new Datastore Parameter
      • Exercise : Create a new Process
      • Exercise : Create a new Role
    • SubTopics in Topics
  • Pergapedia platform
Powered by GitBook
On this page
  • Where to place the JS
  • When editing a process, on the first tab, go to ‘Variables’.
  • Different types of JS
  • Retrieving a plain value
  • Retrieving the full name of a custom actor
  • Retrieving the email address of a custom actor
  • Retrieving a date in a readeable format
  • Retrieving data from a multiselect field
  • Retrieving ‘yes’ from a Yes/No-field
  • Retrieve the Phase
  • Retrieve the Technical Approvers Person Groups (Email group)
  • Retrieve the Technical Approvers Person Groups (Email group + members)

Was this helpful?

  1. Catalog
  2. Catalog Maintenance

Javascript for Variables in processes

In a process, you can use a variable to pull data from the Service Catalog into your process. The text below gives examples on different data types.

With the new code update (Feb 2023) it is possible to update a variable using javascript.

This allows to refresh the data every time the variable is used in the process.

This document shows some examples, as the needed JS is different per type of data.

Where to place the JS

When editing a process, on the first tab, go to ‘Variables’.

- Select ‘JavaScript’ in the dropdown

- Check the box ‘ServiceCatalogInterface’

- Enter the JS in the box for the default value

Different types of JS

In yellow: the internal label if the field in the SC

In green : the GUID of the service, in this example, it comes from an action form.

Retrieving a plain value

var serviceparts = JSON.parse(ServiceCatalogInterface.getServiceParts(#REPLACE-FORMFIELD-serviceguid#, ["radiology_clinical_report"]));

if (serviceparts.length) return serviceparts[0].value;

return "";

Retrieving the full name of a custom actor

The JS below is long, as it covers all possible types of custom actor. To retrieve the email, see the next chapter.

var servicesummary = JSON.parse(ServiceCatalogInterface.getServiceSummary(#REPLACE-FORMFIELD-serviceguid#));

if (servicesummary && servicesummary.customactors && servicesummary.customactors.length) {

var customactors = servicesummary.customactors.filter(function (ca) { return ca.internalname === "CRA"; });

if (customactors.length) {

var customactor = customactors[0];

if (customactor.typename === "Single_person") {

//value is single object

if (customactor.value) {

return customactor.value.firstname + ' ' + customactor.value.lastname;

}

} else if (customactor.typename === "Single_persongroup") {

//value is single object

if (customactor.value) {

return customactor.value.name;

}

} else if (customactor.typename === "Multiple_persons") {

//value is array

if (customactor.value) {

return customactor.value.map(function (person) { return person.firstname + ' ' + person.lastname }).join(", ");

}

} else if (customactor.typename === "Multiple_persongroups") {

//value is array

if (customactor.value) {

return customactor.value.map(function (persongroup) { return persongroup.name }).join(", ");

}

}

}

}

return "";

Retrieving the email address of a custom actor

var servicesummary = JSON.parse(ServiceCatalogInterface.getServiceSummary(#REPLACE-VARIABLE-1067-ServiceGUID#));

if (servicesummary && servicesummary.customactors && servicesummary.customactors.length) { var customactors = servicesummary.customactors.filter(function (ca) { return ca.internalname === "Head_of_department"; });

if (customactors.length) { var customactor = customactors[0];

if (customactor.typename === "Single_person") { //value is single object if (customactor.value) { return customactor.value.email; } }

else

if (customactor.typename === "Single_persongroup") { //value is single object if (customactor.value) { return customactor.value.email; } }

else

if (customactor.typename === "Multiple_persons") { //value is array if (customactor.value) { return customactor.value.map(function (person) { return person.email }).join(", "); } }

else

if (customactor.typename === "Multiple_persongroups") { //value is array if (customactor.value) { return customactor.value.map(function (persongroup) { return persongroup.email }).join(", "); } } } } return "";

Retrieving a date in a readeable format

var serviceparts = JSON.parse(ServiceCatalogInterface.getServiceParts(#REPLACE-FORMFIELD-serviceguid#, ["Geplande_einddatum "]));

if (serviceparts.length && serviceparts[0].value) return CommonInterface.utcDateToString(new Date(serviceparts[0].value), "dd/MM/yyyy");

return "";

Retrieving data from a multiselect field

var serviceparts = JSON.parse(ServiceCatalogInterface.getServiceParts(#REPLACE-FORMFIELD-serviceguid#, ["locaties"]));

if (serviceparts.length && serviceparts[0].value) return serviceparts[0].value.join(", ");

return "";

Retrieving ‘yes’ from a Yes/No-field

var serviceparts = JSON.parse(ServiceCatalogInterface.getServiceParts(#REPLACE-FORMFIELD-serviceguid#, ["site_initiation_visit_is_required"]));

if (serviceparts.length && (serviceparts[0].value === true || serviceparts[0].value === false)) return serviceparts[0].value ? "Yes" : "No";

return "";

Retrieve the Phase

var service = JSON.parse(ServiceCatalogInterface.getServiceOverview(#REPLACE-VARIABLE-1682-ServiceGUID#)); return service && service.phase ? service.phase.name : ""

Retrieve the Technical Approvers Person Groups (Email group)

This first code below will return the email addresses of the groups, so not the email addresses of the Members. If you want them also, see below

Any Group can have an e-mail address, that serves as a group mailbox. If this is not entered, the JS below will return 0 values for that group.

var service = JSON.parse(ServiceCatalogInterface.getServiceSummary(#REPLACE-VARIABLE-1682-ServiceGUID#, { LoadRelations: false })); return service.technicalapprovalpersongroups ? service.technicalapprovalpersongroups.map(function (grp) { return grp.email; }).filter(function (mail) { return !!mail; }).join("||") : "";

Retrieve the Technical Approvers Person Groups (Email group + members)

The code below will return:

  • the Email address of the Group, if known

  • The email addresses of the Members, that are marked to receive the Group emails, when n Group email has been defined.

var service = JSON.parse(ServiceCatalogInterface.getServiceSummary(#REPLACE-VARIABLE-1013-ServiceGUID#, { LoadRelations: false })); var emails = []; if (service.technicalapprovalpersongroups) { service.technicalapprovalpersongroups.forEach(function (grp) { if (grp.email) { if (emails.indexOf(grp.email) < 0) { emails.push(grp.email); } } else { var personsingroup = JSON.parse(CommonInterface.getPersonsForPersonGroup(grp.id)); personsingroup.forEach(function (person) { if (person.email) { if (emails.indexOf(person.email) < 0) { emails.push(person.email); } } }); } }); } return emails.join("||");

PreviousRolesNextAction Forms

Last updated 2 months ago

Was this helpful?