Skip to content

Commit

Permalink
Fix workflow transition metadata being updated multiple times (#2655)
Browse files Browse the repository at this point in the history
* fix workflow transition metadata being updated multiple times

Split transition workflow triggers into pre- and post-methods.
Call the transition workflow update separately to triggers.

* restore method required for interface

* Implemented onTransitionWorkflow for record creation

Added an additional update to the metadata if postSync triggers are configured to run so that any changes to the record are persisted

* Fixed order when initialising the record on create.

---------

Co-authored-by: Andrew Brazzatti <[email protected]>
  • Loading branch information
cofiem and andrewbrazzatti authored Dec 9, 2024
1 parent b4575b1 commit ef149bf
Show file tree
Hide file tree
Showing 3 changed files with 171 additions and 112 deletions.
4 changes: 3 additions & 1 deletion core/src/RecordsService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ export interface RecordsService {
hasEditAccess(brand, user, roles, record): boolean;
hasViewAccess(brand, user, roles, record): boolean;
appendToRecord(targetRecordOid: string, linkData: any, fieldName: string, fieldType: string, targetRecord: any): Promise<any>
transitionWorkflowStep(currentRec: any, recordType: any, nextStep: any, user: any, triggerPreSaveTriggers: boolean, triggerPostSaveTriggers: boolean): Promise<any>;
setWorkflowStepRelatedMetadata(currentRec:any, nextStep:any): void;
transitionWorkflowStepMetadata(currentRec:any, nextStep:any): void;
triggerPreSaveTransitionWorkflowTriggers(oid: string, record: any, recordType: object, nextStep: any, user: object): Promise<any>;
triggerPostSaveTransitionWorkflowTriggers(oid: string, record: any, recordType: any, nextStep: any, user: object, response: any): any;
getAttachments(oid: string, labelFilterStr?: string): Promise<any>;
getDeletedRecords(workflowState, recordType, start, rows, username, roles, brand, editAccessOnly, packageType, sort, fieldNames?, filterString?, filterMode?): Promise<any>;
getRecords(workflowState, recordType, start, rows, username, roles, brand, editAccessOnly, packageType, sort, fieldNames?, filterString?, filterMode?, secondarySort?): Promise<any>;
Expand Down
3 changes: 1 addition & 2 deletions typescript/api/controllers/webservice/RecordController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -891,8 +891,7 @@ export module Controllers {
}
const recType = await RecordTypesService.get(brand, record.metaMetadata.type).toPromise();
const nextStep = await WorkflowStepsService.get(recType, targetStepName).toPromise();
await this.RecordsService.transitionWorkflowStep(record, recType, nextStep, req.user, true, true);
const response = await this.RecordsService.updateMeta(brand, oid, record, req.user);
const response = await this.RecordsService.updateMeta(brand, oid, record, req.user, true, true, nextStep);
this.apiRespond(req, res, response);
} catch (err) {
this.apiFailWrapper(req, res, 500, new APIErrorResponse("Failed to transition workflow, please check server logs."), err,
Expand Down
Loading

0 comments on commit ef149bf

Please sign in to comment.