Below is the query that I'm using and I can't get the await ECO_fileAttachmentVariableArray.setValue and await ECO_attachmentLinksVariable.setValue to work. They don't work for the 1st trigger of the below query, but always works on the 2nd trigger.
Am I missing something? Any help would be appreciated.
abc.js:
await ECO_fetch_ECO_Forms_Table.trigger();
await ECO_fetchAffectedSKU.trigger();
await ECO_fetchFileAttachments.trigger();
await ECO_fetchFileAttachmentsFromS3.trigger();
await ECO_getSKUDescriptionTrigger.trigger();
await ECO_multiSelectSKU.setValue(ECO_fetchAffectedSKU.data.SKU_1);
await ECO_Output_LoadToDB.setValue(ECO_fetch_ECO_Forms_Table.data.FormID['0']);
await ECO_fileAttachmentVariableArray.setValue(
[{name: ECO_fetchFileAttachmentsFromS3.data.Key.split('/').pop(),
type: ECO_fetchFileAttachmentsFromS3.data.ContentType,
sizeBytes: ECO_fetchFileAttachmentsFromS3.data.ContentLength,
base64Data: ECO_fetchFileAttachmentsFromS3.data.Body}]);
await ECO_attachmentLinksVariable.setValue([ECO_fetchFileAttachmentsFromS3.data.Key]);
you could try using the onsuccess event handler:
await ECO_fetch_ECO_Forms_Table.trigger();
await ECO_fetchAffectedSKU.trigger();
await ECO_fetchFileAttachments.trigger();
await ECO_fetchFileAttachmentsFromS3.trigger({
onSuccess: async function(data) {
await ECO_fileAttachmentVariableArray.setValue([{name: data.Key.split('/').pop,
...]});
await ECO_attachmentLinksVariable.setValue([data.Key]);
}
});
await ECO_getSKUDescriptionTrigger.trigger();
await ECO_multiSelectSKU.setValue(ECO_fetchAffectedSKU.data.SKU_1);
await ECO_Output_LoadToDB.setValue(ECO_fetch_ECO_Forms_Table.data.FormID['0']);
I'm not sure what you mean by this.... do you mean the first time this block of code runs? or do you mean line1 doesn't work but line2 does?
Yes, 1st time when the above block is executed, the query is unable to set values. Even though related queries are correctly triggered.
Here is what solved it for me, incase someone faces the same issue:
ECO_fetchFileAttachmentsFromS3.data = null; // set null value
ECO_fetchFileAttachmentsFromS3.data = await new Promise(resolve => {
resolve(ECO_fetchFileAttachmentsFromS3.trigger());
});