in src/Common/ProcessImporter.ts [652:676]
private async _validateFields(payload: IProcessPayload): Promise<void> {
const currentFieldsOnTarget: WITInterfaces.WorkItemField[] =
await Utility.tryCatchWithKnownError(async () => {
return await Engine.Task(
() => this._witApi.getFields(),
`Get fields on target account`);
}, () => new ValidationError("Failed to get fields on target account."));
if (!currentFieldsOnTarget) { // most likely 404
throw new ValidationError("Failed to get fields on target account.")
}
payload.targetAccountInformation.collectionFields = currentFieldsOnTarget;
for (const sourceField of payload.fields) {
const convertedSrcFieldType: number = Utility.WITProcessToWITFieldType(sourceField.type, sourceField.isIdentity);
const conflictingFields: WITInterfaces.WorkItemField[] = currentFieldsOnTarget.filter(targetField =>
((targetField.referenceName === sourceField.id) || (targetField.name === sourceField.name)) // match by name or reference name
&& convertedSrcFieldType !== targetField.type // but with a different type
&& (!sourceField.isIdentity || !targetField.isIdentity)); // with exception if both are identity - known issue we export identity field type = string
if (conflictingFields.length > 0) {
throw new ValidationError(`Field in target Collection conflicts with '${sourceField.name}' field with a diffrent refrence name or type.`);
}
}
}