Schedulers help you to automate executing manual tasks within an application.  In SuiteCRM it allows several possibilities like processing incoming mail, sending an outbound email and set up reminders and notifications. To run a scheduler in SuiteCRM, we need to write a function and a business logic which need to be automated. In this article, we will see one such example where, based on certain conditions, a task need to be automatically created and assigned. 

Steps on how to create a Scheduler file in SuiteCRM 

In this section, we will see how to create relevant scheduler file in SuiteCRM file directory system. First we will create the Scheduler file. The following path location where we need to create the same. 

  • Navigate to the installation file directory of SuiteCRM and check for the path as shown below 
    • Create a “ScheduledTask” folder if not exist in “Ext” folder
Copy to Clipboard
  • The following an example code for a scheduler task in SuiteCRM 
Copy to Clipboard

Create a language Function file in SuiteCRM 

The purpose to create a language file in SuiteCRM is to display a function file in a drop-down list in SuiteCRM scheduler list-view view below are steps. 

Navigating to file path location 

Below is a file path you need to navigate to create a “language file” in SuiteCRM. If folders do not exist as mentioned in the below path you can also create them with the same name.

Copy to Clipboard

Syntax for creating label

The below syntax is used to create a function file in SuiteCRM, make sure that you create a function in the above file path directory.

Copy to Clipboard

Step to Run an Quick Repair 

After creating all mandatory files it is the most important step to do a repair to SuiteCRM instance to replicate the changes follow the below steps to repair instance. 

  • From profile, drop-down navigate to the Administration panel
  • In the Administration panel find  “Repair”, Click on it and follow steps and shown below screen

Navigating to repair setup in SuiteCRM

  • On click to “Repair” you will be navigated to below screen, click on the “Quick Repair and Rebuild” it will automatically the changes and reflected in SuiteCRM instance

Starting Quick repair setup in SuiteCRM

Business logic for Scheduler 

In the above steps, we have learned how to create a scheduler task file and how to create an extension label in SuiteCRM. Now will see a simple business logic with end to end configuration. We are building a business logic on leads module if there is a lead record with status “In Progress” more than a 10 days the status needs change as “FollowUp” when the scheduler runs. 

Before jumping into writing business logic we need to create a “List Item” in the lead module. The Status field is by default created in the SuiteCRM module. We are adding an item to an exciting created field following the below steps to create. 

  • Navigate to the administration panel in SuiteCRM, In developer click on “Studio”
    • As shown in below screen from module section select “Leads” and click on “Field”

Selecting fields tap form studio in SuiteCRM

  • Once you click “Field”, navigate to the Status field and click on it as shown in below screen 

Selecting Status form studio in SuiteCRM

  • On navigation to Status field click and edit and follow the below steps as shown below screen. 

Adding a custom field to leads module in SuiteCRM

We have created an item name in status drop-down in SuiteCRM, Writing code for business logic. Below is code needed to save in the SuiteCRM installation directory as mentioned in 

 Code snippet for Scheduler task.

Copy to Clipboard

Code Snippet for Language File 

Copy to Clipboard

How to create an a Scheduler in SuiteCRM 

In these steps we will see how to create a Scheduler record and set a time interval to run a task. 

Navigate to Scheduler module in SuiteCRM 

  • As shown in below screen click on the profile drop-down and click on admin

Navigate to Scheduler module in SuiteCRM

  • In administrator, panel navigate to the “System Settings” and click on “ Scheduler module as shown in below screen 

Navigate to the System Settings in SuiteCRM

  • The below screen shows the scheduler module in SuiteCRM. Click on “Create Scheduler”

Creating a scheduler in SuiteCRM

  • The below screenshot shows the edit view of the scheduler in SuiteCRM. 

Edit view of the scheduler in SuiteCRM

  • The below screens shows the edit view of SuiteCRM scheduler task with details 

Entering details in Scheduler edit view record

  • The following screenshot shows the scheduler has been created successfully. 
  • We can check the status of the scheduler in Screenshot below with field name “Last Successfully Run”, make sure that “cron.php” is running for 1 minute or we can set time interval as per business requirement. 

Scheduler task created successfully in SuiteCRM

Hope this article is useful to create a scheduler in SuiteCRM.