Home > Forum > Rules, JS, SQL > Update form field - finish state

Update form field - finish state
0

Hello,
I have a process (start - finish) that creates an instance and remains in the "Finish" state.
Here, I have the following form fields: "Quantity TOTAL" (Floating-point number) and "Quantity" (Data table).
In that data table, I have other instances from a different process, and in one column (Quantity Requested), I calculate the sum.
How could I save that sum in Quantity TOTAL and have it consistently updated? (i mean - transferring the Aggregation type Sum value in my form field).
Currently, I have an issue where it's not updated unless I enter the instance in edit mode and save it after.

That instance is set to read-only.
Can you help, please?
Thank you!

Hi,

From what I know, an instance does not update itself, however you can add an action for each instance from different processes that updates this instance where you want to see
the total.
For example:
instance 1 - holds the total value
instance 2 and 3 holds value used for the total in instance 1.
Each time you do any change to instance 2 or 3, you have an action that will trigger an update to instance 1.

Hope it helps
Regards

MVP

Hi,

I have only one additional comment. If you don't need "Quantity Total" in a report / chart or the like, I wouldn't save the total quantity in an actual field. I would use a data row column instead.
Volatile values are often a problem.

Regarding updating the value you could use the "update related workflow" action.
https://docs.webcon.com/docs/2023R3/Studio/Action/Workflow/UpdateParentWorkflow/

Best regards,
Daniel

MVP
In reply to: MariaM

Hi,

I need that column especially for a report.
I have created an action "Change value of a single field" on timeout which runs every 15min.

Do you see any problem with this?

Running update every 15 minutes, will create 96 versions of the document daily.
If there will be many documents like that, then it might eat disk space.

As Daniel said, I'd rather keep a data row on the form, an if you need it on report - use calculated column with subquery like this:

(
SELECT
SUM(WFD_ATT2) AS Sum -- Sum of all the rows
FROM
WFElementDetails JOIN
WFConfigurations ON DET_WFCONID = WFCON_ID
WHERE
DET_WFDID = wfelems.WFD_ID AND --wfelems is a name available in calculated columns, it refers to the id of the document displayed in specific row
WFCON_GUID = '{GUID of the item list}' -- guid is environment safe, no need to worry about changing list id between environments
)


It might cause some speed issues though, but i think that's a better option than 96 updates daily.

MVP
In reply to: Maksymilian Stachowiak

Running update every 15 minutes, will create 96 versions of the document daily.
If there will be many documents like that, then it might eat disk space.

As Daniel said, I'd rather keep a data row on the form, an if you need it on report - use calculated column with subquery like this:

(
SELECT
SUM(WFD_ATT2) AS Sum -- Sum of all the rows
FROM
WFElementDetails JOIN
WFConfigurations ON DET_WFCONID = WFCON_ID
WHERE
DET_WFDID = wfelems.WFD_ID AND --wfelems is a name available in calculated columns, it refers to the id of the document displayed in specific row
WFCON_GUID = '{GUID of the item list}' -- guid is environment safe, no need to worry about changing list id between environments
)


It might cause some speed issues though, but i think that's a better option than 96 updates daily.

@Maks

That reminds me of something I read in the latest 2022 release, which I read to get an idea what will be in the next 2023 release:
Change Log:
Increased the maximum value of a workflow instance version when assigning a
task to users. Previously, a task could be assigned for instances whose version
was a maximum 16-bit integer (int16); after the changes, this value can reach a
maximum of 32 bits (int32)

Maxing out 16 bit or 65536 version.....
And it seems, that this wasn't by accident either, as this was related to tasks.

I think everyone misconfigured a Timeout which cause the creation of a lot of versions, but this. :)