How to change value of field via Workflow

Hello I would like to change value of field Status to “After due date” if the Due date is today and Status is “Awaiting payment” - Can I do it with workflow automation?

Hello,
Yes. You can do a Workflow with Scheduler trigger (e. g. every day)
In ForEach action you load the rows, you wan to change. Please be careful not to load too many records, otherwise the workflow will be terminated. Use filters for loading rows.
Then, in ForEach inner action just save the row if needed.
Regards
Michal

Is that right?

Because it seems like it doesn’t work…

No. It does not work. Sorry.
In the case of form scripting, it would work. Because you change the object in your browser and then you save it.
However, this is a Workflow Automation (started at some time on server). When you change the model in memory, nothing happens in the database. It is necessary to call update to database, if you want to change the record.
Something like this

await doo.table.updateFields('Documents', model.id, { doc_status: 'After due date' });

Regards
Michal

I used that code like below but it still doesn’t work

Last workflow log printed this:

The Workflow finished 2023-02-07T00:00:33.8608770Z (UTC) with the result:
“Response {\n size: 0,\n timeout: 0,\n errorData: { errors: [ [Object] ] },\n errorsPatch: [\n {\n type: ‘Exception’,\n id: ‘tooManyRequestsException’,\n message: ‘Too Many Requests - API rate limit exceeded (according to your pricing plan).’,\n RecordIndex: 0\n }\n ],\n [Symbol(Body internals)]: {\n body: PassThrough {\n _readableState: [ReadableState],\n _events: [Object: null prototype],\n _eventsCount: 4,\n _maxListeners: undefined,\n _writableState: [WritableState],\n allowHalfOpen: true,\n [Symbol(kCapture)]: false,\n [Symbol(kTransformState)]: [Object]\n },\n disturbed: true,\n error: null\n },\n [Symbol(Response internals)]: {\n url: ‘https://traxart.tabidoo.cloud/api/v2/apps/9402ff71-aecd-49e7-bbca-fc270c583bb8/tables/Documents/data/f197ead8-099c-444c-a626-2d445ea01ed6’,\n status: 429,\n statusText: ‘Too Many Requests’,\n headers: Headers { [Symbol(map)]: [Object: null prototype] },\n counter: 0\n }\n}\n(node:3889441) UnhandledPromiseRejectionWarning: #\n(Use node --trace-warnings ... to show where the warning was created)\n(node:3889441) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see Command-line API | Node.js v19.6.0 Documentation). (rejection id: 1)\n(node:3889441) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.\n”

Hi Thomas,
You sent more requests then your pricing plan allowed.
It would be better for everyone if you collect the records to be updated (in the ForEach section) and then call bulk update instead (after ForEach section - just once).
Update Records (Bulk)

Please, add the array of the records to be updated to a property in doo.workflow.runningData object.

Regards
Michal

Hello micu,

I am not sure how to do it… It looks kinda hardcore for me…

Can you show me some examples?

Hi Thomas,

I solved a similar case today and this worked for me. Maybe it will help you, but I don’t guarantee it’s correct.

First I saved the data in the loop to the “workflow”.

if(!doo.workflow.runningData.dataToUpdate) {
      doo.workflow.runningData.dataToUpdate = [];
}
doo.workflow.runningData.dataToUpdate.push(doo.model.id)

And when the whole loop has passed, I edit them in bulk using “updateRecordsBulk”

await doo.table.updateRecordsBulk("tableNameOrId", doo.workflow.runningData.dataToUpdate.map(itemId => ({
        id: itemId,
        fields: {
            doc_status: 'After due date',
        }
})))

1 Like

So I have this WF now:

If I change trigger to Button it works properly. But if trigger is When it’s time it doesn’t change values. But log seems to be OK.
image

Is that some kind of internal issue? Thanks for help.

Hi Thomas,
I am not aware of any issues like that.
You can use console.log to get more information (about records, which suppose to be updated)
If you don’t resolve the issue, please contact us at support@tabidoo.cloud
Regards
Michal