Server Scripts & Jobs

We are excited to announce a significant improvement to Vtiger’s customization and automation ability with the Server Scripts & Jobs module.

Server-side scripting is a powerful capability that enables you to execute diverse tasks. Through this capability, you can enact custom actions upon record saving or upon approval/rejection. You can also set up custom background tasks to execute at scheduled intervals.

Three years ago, we launched Vtiger’s Application Platform (VTAP), a low-code automation framework, to help businesses further customize their Vtiger CRM instance. With VTAP, developers can write client-side code that runs within the user’s browser to enable client-side customization.

However, there are many scenarios where the custom code must run on the server end. 

With the Server Scripts & Jobs, customers and partners can directly run custom code written in JavaScript on Vtiger servers. This feature paves the way for unlimited automation.

Here are a few examples:

  • Enrich your lead data by fetching information from other sources.
  • Periodically import data from external sources to CRM.
  • Adjust data in parent records according to child records or vice versa (update outstanding invoice balance in each org).
  • Integrate AI-powered custom analysis.

This feature triggers these server-side scripts in two ways:

  • Server Scripts: These are server-side scripts that execute when a certain action happens. For example, a record is saved or approved/rejected.
  • Server Jobs: These are server-side scripts that execute automatically at fixed intervals like hourly, daily, weekly, etc.

Use Case

Lets understand how server-side scripting works with a simple example of updating overdue invoice amounts in an Organization record.

Requirement: At any point of time, you should be able to see overdue invoice amounts of any organization.

Solution: Using Server Scripts, this can be achieved easily.

  • Whenever an invoice is updated (amount or status change), you trigger a script.
  • Using Vtiger’s REST method, you can link all invoices to the invoice’s organization in the script.
  • Sum the balance of each invoice.
  • Again, using Vtiger’s REST method, update the balance in the Organization’s field.
  • This will ensure that the overdue invoice amounts will always be visible in an organization record.


  

async function main(record, user) {

    var orgId = record.account_id;

    try {

        var response = await vtap.macro.ws.api('GET', 'retrieve_related', {

            id: '3x'+orgId,

            relatedLabel: 'Invoice',

            relatedType: 'Invoice'

        });

        if(response && response.success) {

            var overdueAmount = 0;

            for(var index in response.result) {

                var invoice = response.result[index];

                var balance = parseFloat(invoice.balance);

                if(balance && !isNaN(balance)) {

                    overdueAmount = overdueAmount + balance;

                }

            }

            await vtap.macro.ws.revise({

                id: '3x'+orgId,

                cf_outstanding_invoice_amount: overdueAmount

            });

        }

    } catch(error) {

    }

}


  

async function main(record, user) {

    var orgId = record.account_id;

    try {

        var response = await vtap.macro.ws.api('GET', 'retrieve_related', {

            id: '3x'+orgId,

            relatedLabel: 'Invoice',

            relatedType: 'Invoice'

        });

        if(response && response.success) {

            var overdueAmount = 0;

            for(var index in response.result) {

                var invoice = response.result[index];

                var balance = parseFloat(invoice.balance);

                if(balance && !isNaN(balance)) {

                    overdueAmount = overdueAmount + balance;

                }

            }

            await vtap.macro.ws.revise({

                id: '3x'+orgId,

                cf_outstanding_invoice_amount: overdueAmount

            });

        }

    } catch(error) {

    }

}

To learn more, please refer to our help documentation.

 
 
 

Coming Soon - Update Extension

 
 

The Update Extension! 

Currently, we do not have a way of updating extensions from the Marketplace. 

With the upcoming release, we will provide a core update where the user will be able to update the extensions that are published from the Add-on Publisher. 

Any changes made to the extensions like workflows, API Designer, Module Designer, etc., will be updated to the customer instance. 

 

The Update Extension! 

Currently, we do not have a way of updating extensions from the Marketplace. 

With the upcoming release, we will provide a core update where the user will be able to update the extensions that are published from the Add-on Publisher. 

Any changes made to the extensions like workflows, API Designer, Module Designer, etc., will be updated to the customer instance. 

 
 

Sign up to receive the latest updates!