You are reading the documentation for an outdated Corteza release. 2024.9 is the latest stable Corteza release.

Workfing with Records

The section outlines some tips and tricks you can use when working with records.

Checking for existence

In case where you wish to perform some task depending on the existence of records, you can use either of the following approaches.

Both approaches are valid and there is no benefit between using one or the other. Decide based on your preferences/context.

Approach A

When searching for records, tick the incTotal option and assign the total result value to a variable.

Inside the gateway, check if the total value is greater then 0.

The screenshot outlines a basic example of checking for existence.
Figure 1. The screenshot outlines a basic example of checking for existence.

You can find the source code for the workflow here.

Approach B

Inside the gateway, check if the count(items) value is greater then 0.

The screenshot outlines a basic example of checking for existence.
Figure 2. The screenshot outlines a basic example of checking for existence.

You can find the source code for the workflow here.

Create or update

When creating the record you need to call the compose record create function, and when updating the record, you need to call the compose record update function.

Only the highlighted portion performs the create/update check; the rest is boilerplate to get it to the desired state.

If you need to call one or the other on-the-fyly, you can use the following approach. You can use the record.recordID != "0" to determine if the record needs to be updated — the default recordID value is "0".

The screenshot outlines a basic example of checking for existence.
Figure 3. The screenshot outlines a basic example of checking for existence.

You can find the source code for the workflow here.

Removing the value

To remove some record value, use an expression step to set the value in question to an empty Any.

The screenshot outlines a basic example of removing record values.
Figure 4. The screenshot outlines a basic example of removing record values.

You can find the source code for the workflow here.

Handling missing values

To use the default value in case the record value does not exist, you need to use the ?? operator.

To exemplify, using a ?? b will return a if it exists or b if it does not.

The below example uses a variable as the default value. You can use a constant such as "something string" or 42.

The screenshot outlines a basic example of using default values.
Figure 5. The screenshot outlines a basic example of using default values.

You can find the source code for the workflow here.