Skip to content
RTILA Web Business Automation
  • Home
  • Features
  • Pricing
  • Marketplace
  • Support
    • Documentation

Cart

RTILA Web Business Automation
  • Home
  • Features
  • Pricing
  • Marketplace
  • Support
    • Documentation
Free Download
Free Download

Billing & Licensing

10
  • Change License’s registered email address
  • Upgrade a License
  • Manage License Activation Count
  • RTILA Studio local database
  • Standalone Exe Antivirus False Positive Alert
  • Team Member Activation URL & License
  • AppSumo Codes Redemption
  • Download & Activate RTILA Studio
  • AppSumo Code Stacking & Upgrade
  • Mac OS Installation Warning

Custom Commands

36
  • WordPress Posts via API (beta)
  • Webhook Send Request
  • Target Text Before After
  • Download File to Folder
  • Clipboard Copy & Paste
  • ChatGPT API Full Control
  • Generate Random Numbers and Text
  • Regex & JS Filters
  • API Bridge Get Post Requests
  • WhatsApp API send MSG
  • GET HTML
  • Slack Notification Command
  • Target Elements With Text Value
  • Directory Get Files Path
  • Folder and File Monitoring
  • Get iFrame URL
  • Get File Content
  • Verify License Easy Digital Downloads
  • Save Variable to File
  • Rename File
  • Move File to New Directory
  • Delete File
  • Mouse Events
  • Get System Info
  • Airtable Get & Update Records
  • Email Send Via SMTP
  • Wait For Element to disappear
  • OCR Passport Reader
  • Target Element in Shadow Dom
  • Airtable Get Records
  • Airtable Update Records
  • Sanitize URL
  • Email Verification
  • Get Hardware ID HWID
  • Timestamp Unix and UTC
  • Switch Tab Focus Command

How-To & Tutorials

42
  • How to target a CSS element
  • Change default Browser
  • Export Results to a CSV file
  • Profile Session Feature
  • OCR Feature: read text from images
  • Auto Download Pinterest Images
  • Save current URL using JavaScript
  • Search & Filter Projects
  • Error handling Strategy
  • Working with Arrays and Objects in RTILA
  • Auto Comment On WordPress Posts
  • Run Automations in Silent Mode
  • License Check for Standalone Executables
  • Trigger Standalone Bots via Command lines
  • How To Find Custom Collections For List type Datasets
  • Correcting & Completing Auto-Recorder Commands
  • RTILA WordPress Plugin installation & configuration
  • Using Developer Tools In RTILA Studio
  • Create A Project From Scratch
  • Bring back disappearing commands & properties
  • Export & share an RTILA project file
  • Install Browser Extensions using Profile Session
  • How To Fill a Form Using Generic Form Filler Child-Project
  • Project Settings: Import URLs manual entry, From File, From Project, and Read XML Sitemap
  • Project Settings: Import URLs manual entry
  • Use Local Storage Variable to scrape Do-follow Links
  • Schedule Launch of Automations
  • Email Results File via Gmail
  • Read from Google Sheets & Post on WordPress
  • Website Load Testing Automation
  • Read data from a txt or csv file
  • Downloading files
  • Open in a New tab
  • Using filters to complete a URL
  • Choosing the right collection
  • Set a Counter with JavaScript
  • Setup reCAPTCHA Resolution
  • Woo Categories & ChatGPT API
  • Login to Google Account & share profile session
  • Google Search Baby Steps
  • Auto-Recorder as a 1st step
  • Standalone Executable Bots

Official Commands

58
  • List Command
  • Incogniton Anti-detect browser
  • Save results to file command
  • RTILA Cloud API Documentation
  • FTP / SFTP Command
  • Custom Commands
  • Integrations
  • RPA & Desktop OS Commands
  • Add And Configure Dataset Properties
  • Inspection Panel Interface & Elements
  • Config & binaries files for Standalone
  • Focus On Element Command
  • Go To Url Command
  • Scroll Element Command
  • Execute JavaScript Code command
  • Reload Page Command
  • Compare Variables Condition
  • Take Screenshot Command
  • Smart Variable (ChatGPT API)
  • Child Projects
  • Confirm (Dialog Box) Command
  • Populate Text Field Command
  • Hover Mouse On Element Command
  • Download Page Command
  • Stop Automation Command
  • Log Message Command
  • Input (prompt box) Variable
  • Extract Results Command
  • Wait for Element to Appear Command
  • Selector (DOM element)
  • Check Radio Input Command
  • Dynamic Variable (JavaScript Code)
  • Static Variables
  • Set Checkbox State Command
  • Set Dropdown Value Command
  • Press a Keyboard Key Command
  • Upload File Command
  • Double Click On An Element Event
  • Click On An Element Event
  • Switch Browser Identity Command
  • Slack Notification Command
  • Save as Pdf Command
  • Go Back To Previous Page Command
  • Go Forward To Next Page Command
  • Proxies Built-In Rotation
  • External Proxy Rotation API
  • Regular Expressions
  • Mock Location Command
  • Close Page Command
  • Desktop Notification Command
  • Command Folder
  • Clear Cookie Command
  • Change Page Size Command
  • Break Loop Command
  • DataSet Types
  • Link Crawler Command
  • Alert Message Command
  • Wait Commands
  • Home
  • Docs
  • How-To & Tutorials
  • Set a Counter with JavaScript
View Categories

Set a Counter with JavaScript

2 min read

Use cases for a Counter #

The Counter is a JavaScript based Child template that you can import into an existing project and will give you the possibility of initializing and using a Counter variable. This can help you count the number of cycles you have in an automation, or other use cases where an incremental counter is needed. This Child Template can be tweaked to count by increments of 2 or 3 or X as a value. It can also be modified to be used as a count down by using a negative number.

Import the Counter Child Template #

The Counter Child Template is available in our Public Template library or as a download through this link
1- Import the Counter Child Template file from your automation panel by clicking on the Import icon.
2- Browse to the folder where you saved this Child Template and select the file
3- Click open and this will create all the necessary blocks you need to run the counter in your existing project

Counter components #

Below are the blocks that compose the Counter Child Template, with a quick description of each element

1: All the blocks are arranged inside a Folder command

2: This is where we initialize starting value of counter

3: An example of a loop where counter is incremented

4: You can add your automation commands here

5: This is where we increment the counter with +1

6: Dynamic variable “catches” counter value from JS code

7: An Alert command can display Dynamic/Counter value

Initialize the Counter #

Before you can start using the Counter in your automation, you need to initialize this variable by assigning to it a starting value (by default it is zero). Initialization is preferably done at the very beginning of your automation flow, or at least before and outside the loop or command that will later increment this variable. Below is the JavaScript code which you can tweak to your needs.

Copy CodeCopiedUse a different Browser
localStorage.setItem('COUNTER', 0);

Increment the Counter #

You can execute the Counter increment block to have the Counter variable incremented by the specified number that is within the JavaScript code. Each occurrence of the Counter increment block will increase the value of the counter. You can call this block in various places in your flow, or you can also call it within a given loop so to keep track of the loop progress. An other scenario is to kick a specific action once the Counter reaches a specific value, using the conditional logic command that can compare the Counter current value to a static or otherwise specified benchmark value.

Copy CodeCopiedUse a different Browser
let number=parseInt(localStorage.getItem('COUNTER')) || 0;
localStorage.setItem('COUNTER', ++number);

Save COUNTER value in a Dynamic variable #

You will notice that RTILA offers you the possibility to save any data generated by a JavaScript code into what we call a localStorage variable, which value can then be “shared” with other Variable commands and blocks in your automation flow. In our current example we are saving the COUNTER value into a Dynamic Variable block using the code below.

Copy CodeCopiedUse a different Browser
VALUE=localStorage.getItem('COUNTER');

Display COUNTER value where needed #

In most cases you may want to display the current value of the counter to guide the user or the monitoring of the automation. In this case you can just call the Dynamic Variable into an Alert or a Desktop Notification command and display it to the user. Below is the code syntax you should use to express the current value of the Dynamic Variable (which had inherited the localStorage value from the earlier JavaScrip command). You can replace the word counter by anything that makes sense for your case, but the {{Dynamic}} should be the exact name of the Variable block you are using.

Copy CodeCopiedUse a different Browser
Counter: {{Dynamic}}

Demo video of this COUNTER #

Below is a quick video capture of how the Counter automation flow we shared in this page do unfold on the user side.

    Still stuck? How can we help?

    How can we help?

    Updated on 04/03/2023
    Choosing the right collection

    Powered by BetterDocs

    Table of Contents
    • Use cases for a Counter
    • Import the Counter Child Template
    • Counter components
    • Initialize the Counter
    • Increment the Counter
    • Save COUNTER value in a Dynamic variable
    • Display COUNTER value where needed
    • Demo video of this COUNTER

    INFO & LEGALS

    PRICING
    PAYMENTS & REFUND
    COOKIES - PRIVACY
    LICENSE AGREEMENT

    DOWNLOADS

    BOT LAUNCHER
    RTILA STUDIO ON GITHUB
    BOT & TEMPLATES
    PARTNERSHIPS

    RESOURCES

    VIDEO TUTORIALS
    DOCUMENTATION
    SUPPORT PORTAL
    FB COMMUNITY SUPPORT

    stay in touch

    Subscription Form

    follow us on

    • Facebook
    • YouTube
    • RTILA LinkedIn Page
    Copyright © RTILA CORPORATION