Help

How to increase a counter field each time will make a change on the record

Topic Labels: Automations
Solved
Jump to Solution
1990 6
cancel
Showing results for 
Search instead for 
Did you mean: 
dirende
4 - Data Explorer
4 - Data Explorer

Hi

I would like to create a number field "recall" that each time the record is update make something like that: recall = recall +1.

I used the automation with the update record filter and I try to apply formula on the recall filed by used a formula like tahs: SUM({recall}, 1) but it is returned an error about the format of the value.

dirende_0-1704461479216.png

Do you have idea how to increment the value?

For the moment I fixed by add string +1 and the result is "+1+1+1+1+1" for each time the update is execute.

Thanks

1 Solution

Accepted Solutions
simmonkc
5 - Automation Enthusiast
5 - Automation Enthusiast

Good call. This is a more elegant method to the same outcome. 👍

See Solution in Thread

6 Replies 6
simmonkc
5 - Automation Enthusiast
5 - Automation Enthusiast

You can easily do this with a script block. ChatGPT helps write these scripts - I've recorded a little video showing how.

That said, I would pass the Richiami number into the script, then use the newly created number (from the script) as the data to update your field.

Screenshot 2024-01-06 at 10.45.59 AM.png

Screenshot 2024-01-06 at 10.46.10 AM.png

Screenshot 2024-01-06 at 10.45.29 AM.png

Here is the code:

// Get the input number from the previous step
let inputNumber = input.config().inputNumber; // Replace 'inputNumber' with the actual field name or variable name containing the number

// Ensure inputNumber is a valid number or set it to 0 if blank
if (inputNumber === '' || isNaN(inputNumber)) {
    inputNumber = 0;
}

// Increment the number by one
const incrementedNumber = inputNumber + 1;

// Save the incremented number as a variable output for future automation steps
output.set('incrementedNumber', incrementedNumber);

 

ScottWorld
18 - Pluto
18 - Pluto

@dirende 

No scripts are necessary for this. You just need to change your RICHIAMI field to a number field instead of a text field.

Then, create a new formula field back in your base with the value that you want it to be after running the automation. Your formula field will be RICHIAMI+1.

Then, when you run the automation, just set your number field to the value of the formula field.

hi

Thanks for feedback.

I tried this solution but I received a wrong format value.

I resolved by creating a hide string field that adds each time a "+" in the field each, and I created a formula field that counts this  "+" in this hide field.

Thanks

Thanks for your feedback.

Unfortunately, I have only a free account, and I cannot execute the script, but the solution is very clear.

 

 

simmonkc
5 - Automation Enthusiast
5 - Automation Enthusiast

Good call. This is a more elegant method to the same outcome. 👍

flexharm23
4 - Data Explorer
4 - Data Explorer
  1. Database Schema Design: Begin by ensuring that your database schema includes a dedicated counter field, such as 'change_counter,' associated with the relevant records.

  2. Initialization: Set the initial value of the counter field to zero when creating a new record.

  3. Transaction Management: Implement transactional processes to guarantee atomicity when updating records. This ensures that the counter is incremented only when the entire transaction is successfully completed.

  4. Change Detection Mechanism: Develop a robust mechanism to detect changes in the record. This can include triggers, timestamps, or any other relevant indicators that signify a modification.

  5. Incrementing Counter: Integrate logic of r2 within your application or database triggers to automatically increment the 'change_counter' each time a modification is made to the associated record.

  6. Error Handling: Implement error-handling mechanisms to address any potential issues during the update process, ensuring the counter accurately reflects successful changes.

  7. Logging and Auditing: Consider implementing comprehensive logging and auditing features to track changes and maintain a historical record. This adds an extra layer of accountability and transparency to the system.

  8. Optimization: Regularly optimize the process by assessing the frequency of changes and adjusting the counter incrementation mechanism accordingly. This ensures efficiency and scalability as the system evolves.