All posts by Jawad Rehman

 A Software Engineer having great experience with all the stages of SDLC including designing, developing, testing software's.  Result oriented, self driven, highly motivated, smart and hungry to learn new technologies, methodologies, strategies and processes.

How to set Owner of record in Zoho CRM

I was working on a project by integration records from third party app to Zoho CRM & set the same owner in 3rd party record in Zoho CRM. I used the following code to set the owner. Its code of Zoho CRM PHP Sdk V2.


$zcrmUser = ZCRMUser::getInstance($userId, null);


CSV String in API Response

I was working on a project  and was using REST API to import records from third party application to Zoho CRM. The API returns the data in CSV formatted string.  I used PHP and used the following logic to create records in CRM.


$csvData = file_get_contents($fileName); // It was actually API call.
$lines = explode(PHP_EOL, $csvData);
$array = array();
foreach ($lines as $line) {
    $array[] = str_getcsv($line);

Handle API Date In Deluge

I was working on API in Zoho CRM and used deluge script. There I faced problem to handle datetime field to create a record. Zoho use specific format to handle date. It is then solved using the following function.

newdate = zoho.currenttime.addMinutes(30).toString("yyyy-MM-dd'T'HH:mm:ss'+05:30'");


In PHP, i faced the similar problem when using PHP Zoho CRM SDK V2.  I then also solved it using the following datatime function.

$dt = new DateTime();

$start_timestamp = $dt->format('c');



Delete Log files after 10 days

I was creating web hook for an application and needed to write a log , so i created this function as to delete a log file after 10 days as log file size increase with passage of time.

function deleteLogFileAfter10Days()
$fileSystemIterator = new FilesystemIterator(‘logs’);
$now = time();
foreach ($fileSystemIterator as $file) {
if ($now – $file->getCTime() >= 60 * 60 * 24 * 10) // 2 days

Send attachment in email deluge script

Send attachment in Email using deluge script Zoho CRM

CRMresponse = zoho.crm.getRelatedRecords(“Attachments”,”Deals”,id.toLong());
opp_info = zoho.crm.getRecordById(“Deals”,id.toLong());
contact_id = ifnull(opp_info.get(“Contact_Name”).get(“id”),””);
contact_info = zoho.crm.getRecordById(“Contacts”,contact_id);
email = ifnull(contact_info.get(“Email”),””);
info email;
if(email != “”)
for each record in CRMresponse
file_id = record.get(“id”);
downloadFile = invokeurl
url :”” + id + “/Attachments/” + file_id
type :GET
from :zoho.adminuserid
to :email
subject :”Test subject”
message :”<h2>Test Email</h2>”
content type :HTML
Attachments :file:downloadFile

Create Activities in Vitger using code

How to create Task Activity on Calendar

include_once ‘includes/main/WebUI.php’;
require_once ‘modules/Users/Users.php’;

$recordModel = Vtiger_Record_Model::getCleanInstance(‘Calendar’);
$recordModel->set(‘mode’, ”);
$recordModel->set(‘description’,’Test Task’);
$activityId = $recordModel->getId();