Skip to content

Commit

Permalink
Fixed order when initialising the record on create.
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewbrazzatti committed Dec 4, 2024
1 parent 8c258f8 commit 1e18438
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions typescript/api/services/RecordsService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,23 +181,26 @@ export module Services {

async create(brand: any, record: any, recordType: any, user ? : any, triggerPreSaveTriggers = true, triggerPostSaveTriggers = true, targetStep = null) {

//set the initial workflow metadata to the first step
let wfStep = await WorkflowStepsService.getFirst(recordType).toPromise();
this.setWorkflowStepRelatedMetadata(record, wfStep);



let wfStep = await WorkflowStepsService.getFirst(recordType).toPromise();
let formName = _.get(wfStep, 'config.form');

let form = await FormsService.getForm(brand, formName, true, recordType.name, record);

let metaMetadata = this.initRecordMetaMetadata(brand.id, user.username, recordType, wfStep, form, moment().format());
_.set(record,'metaMetadata',metaMetadata);
//set the initial workflow metadata to the first step
this.setWorkflowStepRelatedMetadata(record, wfStep);

if (targetStep) {
wfStep = await WorkflowStepsService.get(recordType.name, targetStep).toPromise();
record = await this.triggerPreSaveTransitionWorkflowTriggers(null, record, recordType, wfStep, user);
this.setWorkflowStepRelatedMetadata(record, wfStep);

Check warning on line 200 in typescript/api/services/RecordsService.ts

View check run for this annotation

Codecov / codecov/patch

typescript/api/services/RecordsService.ts#L198-L200

Added lines #L198 - L200 were not covered by tests
}




let createResponse = new StorageServiceResponse();
const failedMessage = "Failed to created record, please check server logs.";
Expand Down

0 comments on commit 1e18438

Please sign in to comment.