private async _addBehaviorsToWorkItemTypes()

in src/Common/ProcessImporter.ts [532:552]


    private async _addBehaviorsToWorkItemTypes(payload: IProcessPayload): Promise<void> {
        for (const witBehaviorsEntry of payload.workItemTypeBehaviors) {
            for (const behavior of witBehaviorsEntry.behaviors) {
                try {
                    if (witBehaviorsEntry.workItemType.workItemTypeClass === WITProcessDefinitionsInterfaces.WorkItemTypeClass.Custom) {
                        const addedBehavior = await Engine.Task(
                            () => this._witProcessDefinitionApi.addBehaviorToWorkItemType(behavior, payload.process.typeId, witBehaviorsEntry.workItemType.refName),
                            `Add behavior '${behavior.behavior.id}' to work item type '${witBehaviorsEntry.workItemType.refName}'`);

                        if (!addedBehavior || addedBehavior.behavior.id !== behavior.behavior.id) {
                            throw new ImportError(`Failed to add behavior '${behavior.behavior.id}' to work item type '${witBehaviorsEntry.workItemType.refName}, server returned empty result or id does not match`);
                        }
                    }
                }
                catch (error) {
                    Utility.handleKnownError(error);
                    throw new ImportError(`Failed to add behavior '${behavior.behavior.id}' to work item type '${witBehaviorsEntry.workItemType.refName}', check logs for details.`);
                }
            }
        }
    }