JavaScript Routings
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.
Arguments
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 interfaceinterface 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.
Example:
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.