JavaScript Routings

Advanced JavaScript routings for dynamic mapping

In addition to basic static routings (sync entities from Project A to Project B), you can write dynamic JavaScript routings. For example, share only bugs from a specific project, entities with a specific value in a custom field, etc.


Script for dynamic routings receives args object as a parameter with the following interface

interface IExecuteParamsArgs {
  account: string
  entities: EntityRef[]
  sourceTool: ToolRef
  targetTool: ToolRef

Return value

Dynamic routing script should return an array of objects with the following interface

interface IEntityResult {
  entity: EntityRef
  targetScope: {
    kind: 'project',
    // Id of project where entity needs to be created
    sourceId: string
  } | null | undefined

For each entity in args.entities array you need to define the target integration scope (project in an opposite tool) where a pairing entity needs to be created. Alternatively, null can be set as the target scope or entity can be excluded from the returned value if the entity shouldn't be synced to an opposite tool.


 return args.entities
   .filter(e => e.entityType.toLowerCase() === 'bug')
   .map(e => ({
     entity: e,
     targetScope: {
       kind: 'project',
       sourceId: 'SYNC_PROJECT_ID'

In this example routing shares only bugs to project with id `SYNC_PROJECT_ID`. The entity with entity type id other from bug won't be shared.


To maximize the performance of JavaScript routings and decrease the load on your Jira/Azure DevOps/Targetprocess instance, try to minify the number of HTTP requests your scripts do using HttpApi. Additionally, avoid usage of shareEntity/shareEntities in routings. It may lead to an loops in your scripts.


GitHub librarary of JS mappings and routings samples