How to run a snippet of code after a particular file/canonical has data loaded

#1

After loading data from a source file, how do we run an arbitrary piece of javascript so we can refresh some calc fields?

0 Likes

#2

This other community post might help you:

0 Likes

#3

You shouldn’t have to call javascript to refresh calc fields? Generally that happens automatically.

0 Likes

#4

We are setting AsyncProcessingDisabled before loading. In this case we don’t want to have the fields automatically refresh due to the data load being large and backing up the queues while records are added. We know which two types have stored calcs that reference the data. They have a sum over a collection (and the collection keeps changing as new records are loaded) so it causes a backup when it is more efficient (and will actually complete) if we refresh at the very end once.

0 Likes

#5

If you disable AsycProcessing, why dont you just run refreshCalcs after your dataload?

0 Likes

#6

I see.

Given that you have a relatively complex workflow to automate, you may want to checkout the Workflow type. This will allow you to orchestrate multi-step long-running actions.

Disable AsyncProcessing -> Load Data -> Refresh Calc Fields -> Enable AsyncProcessing

Specifically for the “refreshCalcFields” step, you may want checkout the method Tag.rebuild()

0 Likes

#7

So that makes sense, except we don’t know exactly when LoadData will occur as the file will be posted from an internal system to the Azure blob storage. So in this case, would the “load data” step be our cron jobs that detects and processes the file? So each time it checks (say once every 30 minutes), it would run that workflow, and skip refresh calc fields if nothing got loaded?

Thanks for the info

0 Likes

#8

Yes i think you could orchestrate it that way.

0 Likes