PHP SDK Samples - Record Operations
These sample codes are only applicable for the latest version ( v2.0.0 ) of PHP SDK. Use this link for the previous version samples.
<?php
use zcrmsdk\crm\crud\ZCRMInventoryLineItem;
use zcrmsdk\crm\crud\ZCRMRecord;
use zcrmsdk\crm\crud\ZCRMTax;
use zcrmsdk\crm\setup\restclient\ZCRMRestClient;
require 'vendor/autoload.php';
class Record{
public function __construct()
{
$configuration =array("client_id"=>{client_id},"client_secret"=>{client_secret},"redirect_uri"=>{redirect_url},"currentUserEmail"=>{user_email_id});
ZCRMRestClient::initialize($configuration);
}
public function create()
{
$record = ZCRMRestClient::getInstance()->getRecordInstance("{module_api_name}", "{record_id}"); // To get record instance
$record->setFieldValue("Subject", "test2312"); // This function use to set FieldApiName and value similar to all other FieldApis and Custom field
$record->setFieldValue("Account_Name", "3524033000001052013"); // Account Name can be given for a new account, account_id is not mandatory in that case
/**
* Following methods are being used only by Inventory modules *
*/
$lineItem = ZCRMInventoryLineItem::getInstance(null); // To get ZCRMInventoryLineItem instance
$lineItem->setDescription("Product_description"); // To set line item description
$lineItem->setDiscount(5); // To set line item discount
$lineItem->setListPrice(100); // To set line item list price
$taxInstance1 = ZCRMTax::getInstance("org"); // To get ZCRMTax instance
$taxInstance1->setPercentage(2); // To set tax percentage
$taxInstance1->setValue(50); // To set tax value
$lineItem->addLineTax($taxInstance1); // To set line tax to line item
$taxInstance1 = ZCRMTax::getInstance("org");
$taxInstance1->setPercentage(12);
$taxInstance1->setValue(50);
$lineItem->addLineTax($taxInstance1);
$lineItem->setProduct(ZCRMRecord::getInstance("Products", "{product_id}")); // To set product to line item
$lineItem->setQuantity(100); // To set product quantity to this line item
$record->addLineItem($lineItem);
$trigger=array();//triggers to include
$lar_id="{lar_id}";//lead assignment rule id
$responseIns = $record->create($trigger,$lar_id);//$trigger , $larid optional
echo "HTTP Status Code:" . $responseIns->getHttpStatusCode(); // To get http response code
echo "Status:" . $responseIns->getStatus(); // To get response status
echo "Message:" . $responseIns->getMessage(); // To get response message
echo "Code:" . $responseIns->getCode(); // To get status code
echo "Details:" . json_encode($responseIns->getDetails());
}
}
$obj =new Record();
$obj->create();
<?php
use zcrmsdk\crm\crud\ZCRMInventoryLineItem;
use zcrmsdk\crm\crud\ZCRMTax;
use zcrmsdk\crm\setup\restclient\ZCRMRestClient;
require 'vendor/autoload.php';
class Record{
public function __construct()
{
$configuration =array("client_id"=>{client_id},"client_secret"=>{client_secret},"redirect_uri"=>{redirect_url},"currentUserEmail"=>{user_email_id});
ZCRMRestClient::initialize($configuration);
}
public function update()
{
$record = ZCRMRestClient::getInstance()->getRecordInstance("{module_api_name}", "{record_id}"); // To get record instance
/**
* only for inventory module *
*/
$record->setFieldValue("Subject", "test2312"); // This function use to set FieldApiName and value similar to all other FieldApis and Custom field
$record->setFieldValue("Account_Name", "{account_id}"); // Account Name can be given for a new account, account_id is not mandatory in that case
$lineItem = ZCRMInventoryLineItem::getInstance("{line_item_id}"); // To get ZCRMInventoryLineItem instance the id of the line item
$lineItem->setDescription("Product_description"); // To set line item description
$lineItem->setDiscount(20); // To set line item discount
$lineItem->setListPrice(3412); // To set line item list price
$taxInstance1 = ZCRMTax::getInstance("{tax_name}"); // to get the tax instance
$taxInstance1->setPercentage(20); // to set the tax percentage
$taxInstance1->setValue(50); // to set the tax value
$lineItem->addLineTax($taxInstance1); // to add the tax to the line item
$lineItem->setQuantity(101); // To set product quantity to this line item
$record->addLineItem($lineItem); // to add the line item to the record of invoice
/**
* for price book alone
* $record->setFieldValue("Pricing_Details", json_decode('[ { "to_range": 5, "discount": 0, "from_range": 1 }, { "to_range": 11, "discount": 1, "from_range": 6 }, { "to_range": 17, "discount": 2, "from_range": 12 }, { "to_range": 23, "discount": 3, "from_range": 18 }, { "to_range": 29, "discount": 4, "from_range": 24 } ]',true));//setting the discount , range of the pricebook record
* $record->setFieldValue("Pricing_Model","Flat"); //setting the price book model*
*/
$trigger=array();//triggers to include
$lar_id="lar_id";//lead assignment rule id
$responseIns = $record->update($trigger,$lar_id); // to update the record
echo "HTTP Status Code:" . $responseIns->getHttpStatusCode(); // To get http response code
echo "Status:" . $responseIns->getStatus(); // To get response status
echo "Message:" . $responseIns->getMessage(); // To get response message
echo "Code:" . $responseIns->getCode(); // To get status code
echo "Details:" . json_encode($responseIns->getDetails());
}
}
$obj =new Record();
$obj->update();
<?php
use zcrmsdk\crm\setup\restclient\ZCRMRestClient;
require 'vendor/autoload.php';
class Record{
public function __construct()
{
$configuration =array("client_id"=>{client_id},"client_secret"=>{client_secret},"redirect_uri"=>{redirect_url},"currentUserEmail"=>{user_email_id});
ZCRMRestClient::initialize($configuration);
}
public function delete()
{
$record = ZCRMRestClient::getInstance()->getRecordInstance("{module_api_name}", "{record_id}"); // To get record instance
$responseIns = $record->delete();
echo "HTTP Status Code:" . $responseIns->getHttpStatusCode(); // To get http response code
echo "Status:" . $responseIns->getStatus(); // To get response status
echo "Message:" . $responseIns->getMessage(); // To get response message
echo "Code:" . $responseIns->getCode(); // To get status code
echo "Details:" . json_encode($responseIns->getDetails());
}
}
$obj =new Record();
$obj->delete();
<?php
use zcrmsdk\crm\crud\ZCRMRecord;
use zcrmsdk\crm\setup\restclient\ZCRMRestClient;
require 'vendor/autoload.php';
class Record{
public function __construct()
{
$configuration =array("client_id"=>{client_id},"client_secret"=>{client_secret},"redirect_uri"=>{redirect_url},"currentUserEmail"=>{user_email_id});
ZCRMRestClient::initialize($configuration);
}
public function convert()
{
$record = ZCRMRestClient::getInstance()->getRecordInstance("Leads", "{lead_id}"); // To get record instance
$deal = ZCRMRecord::getInstance("deals", Null); // to get the record of deal in form of ZCRMRecord insatnce
$deal->setFieldValue("Deal_Name", "test3"); // to set the deal name
$deal->setFieldValue("Stage", "Qualification"); // to set the stage
$deal->setFieldValue("Closing_Date", "2016-03-30"); // to set the closing date
$details = array("overwrite"=>TRUE,"notify_lead_owner"=>TRUE,"notify_new_entity_owner"=>TRUE,"Accounts"=>"{account_id}","Contacts"=>"{contact_id}","assign_to"=>"{user_id}");
$responseIn = $record->convert($deal, $details); // to convert record
echo "HTTP Status Code:" . $responseIn->getHttpStatusCode(); // To get http response code
echo "Status:" . $responseIn->getStatus(); // To get response status
echo "Message:" . $responseIn->getMessage(); // To get response message
echo "Code:" . $responseIn->getCode(); // To get status code
echo "Details:" . json_encode($responseIn->getDetails());
}
}
$obj =new Record();
$obj->convert();
<?php
use zcrmsdk\crm\setup\restclient\ZCRMRestClient;
require 'vendor/autoload.php';
class Record{
public function __construct()
{
$configuration =array("client_id"=>{client_id},"client_secret"=>{client_secret},"redirect_uri"=>{redirect_url},"currentUserEmail"=>{user_email_id});
ZCRMRestClient::initialize($configuration);
}
public function getRelatedListRecords()
{
$record = ZCRMRestClient::getInstance()->getRecordInstance("{module_api_name}", "{record_id}"); // To get record instance
/* For VERSION <=2.0.6 $relatedlistrecords = $record->getRelatedListRecords("Attachments")->getData(); // to get the related list records in form of ZCRMRecord instance*/
$param_map=array("page"=>"1","per_page"=>"200"); // key-value pair containing all the parameters - optional
$header_map = array("if-modified-since"=>"2019-10-10T15:26:49+05:30"); // key-value pair containing all the headers - optional
$relatedlistrecords = $record->getRelatedListRecords("Attachments",$param_map,$header_map)->getData(); // to get the related list records in form of ZCRMRecord instance
foreach ($relatedlistrecords as $relatedlistrecord) {
echo $relatedlistrecord->getEntityId(); // to get the entity id
echo $relatedlistrecord->getFieldValue("File_Name"); // to get the file name
echo $relatedlistrecord->getModuleApiName(); // to get the api name of the module
}
$relatedlistrecords = $record->getRelatedListRecords("Products")->getData(); // to get the related list record inform of ZCRMRecord instance
foreach ($relatedlistrecords as $relatedlistrecord) {
echo $relatedlistrecord->getModuleApiName(); // to get the api name of the module
echo $relatedlistrecord->getFieldValue("Product_Name"); // to get the product name
echo $relatedlistrecord->getEntityId(); // to get the entity id
echo $relatedlistrecord->getFieldValue("Product_Code"); // to get the product code
}
$relatedlistrecords = $record->getRelatedListRecords("Activities")->getData(); // to get the related list record inform of ZCRMRecord instance
foreach ($relatedlistrecords as $relatedlistrecord) {
echo $relatedlistrecord->getModuleApiName(); // to get the api name of the module
echo $relatedlistrecord->getEntityId(); // to get the entity id
echo $relatedlistrecord->getFieldValue("Subject"); // to get the subject of the activity
echo $relatedlistrecord->getFieldValue("Due_Date"); // to get the due date of the activity
echo $relatedlistrecord->getFieldValue("Billable"); // to get the billable value
echo $relatedlistrecord->getFieldValue("Activity_Type"); // to get the activity type
}
$relatedlistrecords = $record->getRelatedListRecords("Campaigns")->getData(); // to get the related list record inform of ZCRMRecord instance
foreach ($relatedlistrecords as $relatedlistrecord) {
echo $relatedlistrecord->getModuleApiName(); // to get the api name of the module
echo $relatedlistrecord->getEntityId(); // to get the entity id
echo $relatedlistrecord->getFieldValue("Campaign_Name"); // to get the campaigns name
echo $relatedlistrecord->getFieldValue("Description"); // to get the campaign's description
echo $relatedlistrecord->getFieldValue("Member_Status"); // to get the member status
}
$relatedlistrecords = $record->getRelatedListRecords("Quotes")->getData(); // to get the related list record inform of ZCRMRecord instance
foreach ($relatedlistrecords as $relatedlistrecord) {
echo $relatedlistrecord->getModuleApiName(); // to get the api name of the module
echo $relatedlistrecord->getEntityId(); // to get the entity id
echo $relatedlistrecord->getFieldValue("Carrier"); // to get the carrier
echo $relatedlistrecord->getFieldValue("Quote_Stage"); // to get the quote stage
echo $relatedlistrecord->getFieldValue("Subject"); // to get the quote subject
echo $relatedlistrecord->getFieldValue("Quote_Number"); // to get the quote number
echo $relatedlistrecord->getFieldValue("currency_symbol"); // to get the currency symbol
}
$relatedlistrecords = $record->getRelatedListRecords("SalesOrders")->getData(); // to get the related list record inform of ZCRMRecord instance
foreach ($relatedlistrecords as $relatedlistrecord) {
echo $relatedlistrecord->getModuleApiName(); // to get the api name of the module
echo $relatedlistrecord->getEntityId(); // to get the entity id
echo $relatedlistrecord->getFieldValue("Carrier"); // to get the carrier
echo $relatedlistrecord->getFieldValue("Status"); // to get the status of the sales order
echo $relatedlistrecord->getFieldValue("Billing_Street"); // to get the billing street
echo $relatedlistrecord->getFieldValue("Billing_Code"); // to get the billing code
echo $relatedlistrecord->getFieldValue("Subject"); // to get the subject
echo $relatedlistrecord->getFieldValue("Billing_City"); // to get the billing city
echo $relatedlistrecord->getFieldValue("SO_Number"); // to get the sales order number
echo $relatedlistrecord->getFieldValue("Billing_State"); // to get the billing state
}
$relatedlistrecords = $record->getRelatedListRecords("Cases")->getData(); // to get the related list record inform of ZCRMRecord instance
foreach ($relatedlistrecords as $relatedlistrecord) {
echo $relatedlistrecord->getModuleApiName(); // to get the api name of the module
echo $relatedlistrecord->getEntityId(); // to get the entity id
echo $relatedlistrecord->getFieldValue("Status"); // to get the status of the case
echo $relatedlistrecord->getFieldValue("Email"); // to get the email id
echo $relatedlistrecord->getFieldValue("Case_Origin"); // to get the case origin
echo $relatedlistrecord->getFieldValue("Case_Number"); // to get the case number
}
}
}
$obj =new Record();
$obj->getRelatedListRecords();
<?php
use zcrmsdk\crm\crud\ZCRMInventoryLineItem;
use zcrmsdk\crm\crud\ZCRMRecord;
use zcrmsdk\crm\setup\restclient\ZCRMRestClient;
require 'vendor/autoload.php';
class Record{
public function __construct()
{
$configuration =array("client_id"=>{client_id},"client_secret"=>{client_secret},"redirect_uri"=>{redirect_url},"currentUserEmail"=>{user_email_id});
ZCRMRestClient::initialize($configuration);
}
public function addLineItemToExistingRecord() //this function costs 2 API credits.
{
$record = ZCRMRestClient::getInstance()->getRecordInstance("{module_api_name}", "{record_id}"); // To get record instance
$lineItem = ZCRMInventoryLineItem::getInstance(null); // To get ZCRMInventoryLineItem instance
$lineItem->setDescription("Product_description"); // To set line item description
$lineItem->setDiscount(5); // To set line item discount
$lineItem->setListPrice(100); // To set line item list price
$lineItem->setProduct(ZCRMRecord::getInstance("Products", "{product_id}")); // To set product to line item
$lineItem->setQuantity(100); //
$responseIns = $record->addLineItemtoExistingRecord($lineItem);
echo "HTTP Status Code:" . $responseIns->getHttpStatusCode(); // To get http response code
echo "Status:" . $responseIns->getStatus(); // To get response status
echo "Message:" . $responseIns->getMessage(); // To get response message
echo "Code:" . $responseIns->getCode(); // To get status code
echo "Details:" . $responseIns->getDetails()['id'];
}
}
$obj =new Record();
$obj->addLineItemToExistingRecord();
<?php
use zcrmsdk\crm\crud\ZCRMInventoryLineItem;
use zcrmsdk\crm\setup\restclient\ZCRMRestClient;
require 'vendor/autoload.php';
class Record{
public function __construct()
{
$configuration =array("client_id"=>{client_id},"client_secret"=>{client_secret},"redirect_uri"=>{redirect_url},"currentUserEmail"=>{user_email_id});
ZCRMRestClient::initialize($configuration);
}
public function updateLineItemofTheExistingRecord() //this function costs 2 API credits.
{
$record = ZCRMRestClient::getInstance()->getRecordInstance("{module_api_name}", "{record_id}");// To get record instance
$lineItem = ZCRMInventoryLineItem::getInstance(null); // To get ZCRMInventoryLineItem instance
$lineItem->setId("3524033000001325006");
$lineItem->setDescription("Product_ssdsdcription"); // To set line item description
$lineItem->setDiscount(5); // To set line item discount
$lineItem->setListPrice(12312); // To set line item list price
$lineItem->setQuantity(100); //
$responseIns = $record->updateLineItemofTheExistingRecord($lineItem);
echo "HTTP Status Code:" . $responseIns->getHttpStatusCode(); // To get http response code
echo "Status:" . $responseIns->getStatus(); // To get response status
echo "Message:" . $responseIns->getMessage(); // To get response message
echo "Code:" . $responseIns->getCode(); // To get status code
echo "Details:" . $responseIns->getDetails()['id'];
}
}
$obj =new Record();
$obj->updateLineItemofTheExistingRecord();
<?php
use zcrmsdk\crm\setup\restclient\ZCRMRestClient;
require 'vendor/autoload.php';
class Record{
public function __construct()
{
$configuration =array("client_id"=>{client_id},"client_secret"=>{client_secret},"redirect_uri"=>{redirect_url},"currentUserEmail"=>{user_email_id});
ZCRMRestClient::initialize($configuration);
}
public function deleteLineItemFromTheExistingRecord() //this function costs 2 API credits.
{
$record = ZCRMRestClient::getInstance()->getRecordInstance("{module_api_name}", "{record_id}"); // To get record instance
$responseIns = $record->deleteLineItemFromTheExistingRecord("{line_item_id}");
echo "HTTP Status Code:" . $responseIns->getHttpStatusCode(); // To get http response code
echo "Status:" . $responseIns->getStatus(); // To get response status
echo "Message:" . $responseIns->getMessage(); // To get response message
echo "Code:" . $responseIns->getCode(); // To get status code
echo "Details:" . $responseIns->getDetails()['id'];
}
}
$obj =new Record();
$obj->deleteLineItemFromTheExistingRecord();
<?php
use zcrmsdk\crm\setup\restclient\ZCRMRestClient;
require 'vendor/autoload.php';
class Record{
public function __construct()
{
$configuration =array("client_id"=>{client_id},"client_secret"=>{client_secret},"redirect_uri"=>{redirect_url},"currentUserEmail"=>{user_email_id});
ZCRMRestClient::initialize($configuration);
}
public function getNotes()
{
$record = ZCRMRestClient::getInstance()->getRecordInstance("{module_api_name}", "{record_id}"); // To get record instance
/* For VERSION <=2.0.6 $notes = $record->getNotes()->getData(); // to get the notes in form of ZCRMNote instances array */
$param_map=array("page"=>"1","per_page"=>"200"); // key-value pair containing all the parameters - optional
$header_map = array("if-modified-since"=>"2019-12-12T15:26:49+05:30"); // key-value pair containing all the headers - optional
$notes = $record->getNotes($param_map,$header_map)->getData(); // to get the notes in form of ZCRMNote instances array
foreach ($notes as $note) {
echo "\n";
echo $note->getId(); // To get note id
echo $note->getTitle(); // To get note title
echo $note->getContent(); // To get note content
$parentRecord = $note->getParentRecord(); // To get note's parent record
echo $parentRecord->getEntityId(); // To get note's parent record id
echo $note->getParentName(); // To get note's parent name
echo $note->getParentId(); // To get note's parent id
$createdBy = $note->getCreatedBy();
echo $createdBy->getId(); // To get user_id who created the note
echo $createdBy->getName(); // To get user name who created the note
$modifiedBy = $note->getModifiedBy();
echo $modifiedBy->getId(); // To get user_id who modified the note
echo $modifiedBy->getName(); // To get user name who modified the note
$owner = $note->getOwner();
echo $owner->getId(); // To get note_record owner id
echo $owner->getName(); // To get note_record Owner name
echo $note->getCreatedTime(); // To get created time of the note
echo $note->getModifiedTime(); // To get modified time of the note
echo $note->isVoiceNote(); // Check if the note is voice_note or not
echo $note->getSize(); // To get note_record size
$attchments = $note->getAttachments(); // To get attachments of the note_record
if ($attchments != null) // check If attachments is empty/not
{
foreach ($attchments as $attchmentIns) {
echo $attchmentIns->getId(); // To get the note's attachment id
echo $attchmentIns->getFileName(); // To get the note's attachment file name
echo $attchmentIns->getFileType(); // To get the note's attachment file type
echo $attchmentIns->getSize(); // To get the note's attachment file size
echo $attchmentIns->getParentModule(); // To get the note's attachment parent module name
$parentRecord = $attchmentIns->getParentRecord();
echo $parentRecord->getEntityId(); // To get the note's parent record id
echo $attchmentIns->getParentName(); // To get the note name
echo $attchmentIns->getParentId(); // To get the note id
$createdBy = $attchmentIns->getCreatedBy();
echo $createdBy->getId(); // To get user_id who created the note's attachment
echo $createdBy->getName(); // To get user name who created the note's attachment
$modifiedBy = $attchmentIns->getModifiedBy();
echo $modifiedBy->getId(); // To get user_id who modified the note's attachment
echo $modifiedBy->getName(); // To get user name who modified the note's attachment
$owner = $attchmentIns->getOwner();
echo $owner->getId(); // To get the note's attachment owner id
echo $owner->getName(); // To get the note's attachment owner name
echo $attchmentIns->getCreatedTime(); // To get attachment created time
echo $attchmentIns->getModifiedTime(); // To get attachment modified time
}
}
}
}
}
$obj =new Record();
$obj->getNotes();
use zcrmsdk\crm\crud\ZCRMNote;
use zcrmsdk\crm\crud\ZCRMRecord;
use zcrmsdk\crm\setup\restclient\ZCRMRestClient;
require 'vendor/autoload.php';
class Record{
public function __construct()
{
$configuration =array("client_id"=>{client_id},"client_secret"=>{client_secret},"redirect_uri"=>{redirect_url},"currentUserEmail"=>{user_email_id});
ZCRMRestClient::initialize($configuration);
}
public function addNotes(){
$record = ZCRMRecord::getInstance("Accounts", "3524033000003350015");
$noteIns = ZCRMNote::getInstance($record, NULL); // to get the note instance
$noteIns->setTitle("Title_API1"); // to set the note title
$noteIns->setContent("This is test content"); // to set the note content
$noteIns1 = ZCRMNote::getInstance($record, NULL); // to get another note instance
$noteIns1->setTitle("Title_API1"); // to set the note title
$noteIns1->setContent("This is test content1");
$noteInstances=[$noteIns,$noteIns1];
$responseIn=$record->addNotes($noteInstances);
foreach ($responseIn->getEntityResponses() as $responseIns) {
echo "HTTP Status Code:" . $responseIn->getHttpStatusCode(); // To get http response code
echo "Status:" . $responseIns->getStatus(); // To get response status
echo "Message:" . $responseIns->getMessage(); // To get response message
echo "Code:" . $responseIns->getCode(); // To get status code
echo "Details:" . json_encode($responseIns->getDetails());
}
}
$obj =new Record();
$obj->addNotes();
<?php
use zcrmsdk\crm\crud\ZCRMNote;
use zcrmsdk\crm\setup\restclient\ZCRMRestClient;
require 'vendor/autoload.php';
class Record{
public function __construct()
{
$configuration =array("client_id"=>{client_id},"client_secret"=>{client_secret},"redirect_uri"=>{redirect_url},"currentUserEmail"=>{user_email_id});
ZCRMRestClient::initialize($configuration);
}
public function addNote()
{
$record = ZCRMRestClient::getInstance()->getRecordInstance("{module_api_name}", "{record_id}"); // To get record instance
$noteIns = ZCRMNote::getInstance($record, null); // to get the note instance
$noteIns->setTitle("Title_API1"); // to set the note title
$noteIns->setContent("This is test content"); // to set the note content
$responseIns = $record->addNote($noteIns); // to add the note
echo "HTTP Status Code:" . $responseIns->getHttpStatusCode(); // To get http response code
echo "Status:" . $responseIns->getStatus(); // To get response status
echo "Message:" . $responseIns->getMessage(); // To get response message
echo "Code:" . $responseIns->getCode(); // To get status code
echo "Details:" . $responseIns->getDetails()['id'];
}
}
$obj =new Record();
$obj->addNote();
<?php
use zcrmsdk\crm\crud\ZCRMNote;
use zcrmsdk\crm\setup\restclient\ZCRMRestClient;
require 'vendor/autoload.php';
class Record{
public function __construct()
{
$configuration =array("client_id"=>{client_id},"client_secret"=>{client_secret},"redirect_uri"=>{redirect_url},"currentUserEmail"=>{user_email_id});
ZCRMRestClient::initialize($configuration);
}
public function updateNote()
{
$record = ZCRMRestClient::getInstance()->getRecordInstance("{moduel_api_name}", "{record_id}"); // To get record instance
$noteIns = ZCRMNote::getInstance($record, "{note_id}"); // to get the note instance
$noteIns->setTitle("Title_API1"); // to set the title of the note
$noteIns->setContent("This is test cooontent"); // to set the content of the note
$responseIns = $record->updateNote($noteIns); // to update the note
echo "HTTP Status Code:" . $responseIns->getHttpStatusCode(); // To get http response code
echo "Status:" . $responseIns->getStatus(); // To get response status
echo "Message:" . $responseIns->getMessage(); // To get response message
echo "Code:" . $responseIns->getCode(); // To get status code
echo "Details:" . $responseIns->getDetails()['id'];
}
}
$obj =new Record();
$obj->updateNote();
<?php
use zcrmsdk\crm\crud\ZCRMNote;
use zcrmsdk\crm\setup\restclient\ZCRMRestClient;
require 'vendor/autoload.php';
class Record{
public function __construct()
{
$configuration =array("client_id"=>{client_id},"client_secret"=>{client_secret},"redirect_uri"=>{redirect_url},"currentUserEmail"=>{user_email_id});
ZCRMRestClient::initialize($configuration);
}
public function deleteNote()
{
$record = ZCRMRestClient::getInstance()->getRecordInstance("{module_api_name}", "{record_id}"); // To get record instance
$noteIns = ZCRMNote::getInstance($record, "{note_id}"); // to get the note instance
$responseIns = $record->deleteNote($noteIns); // to delete the note
echo "HTTP Status Code:" . $responseIns->getHttpStatusCode(); // To get http response code
echo "Status:" . $responseIns->getStatus(); // To get response status
echo "Message:" . $responseIns->getMessage(); // To get response message
echo "Code:" . $responseIns->getCode(); // To get status code
echo "Details:" . $responseIns->getDetails()['id'];
}
}
$obj =new Record();
$obj->deleteNote();
<?php
use zcrmsdk\crm\setup\restclient\ZCRMRestClient;
require 'vendor/autoload.php';
class Record{
public function __construct()
{
$configuration =array("client_id"=>{client_id},"client_secret"=>{client_secret},"redirect_uri"=>{redirect_url},"currentUserEmail"=>{user_email_id});
ZCRMRestClient::initialize($configuration);
}
public function getAttachments()
{
/* For VERSION <=2.0.6 $records = ZCRMRestClient::getInstance()->getRecordInstance("{module_api_name}", "{record_id}"); // To get record instance
$responseIns = $records->getAttachments(1, 50); // to get the attachments */
$record = ZCRMRestClient::getInstance()->getRecordInstance("{module_api_name}", "{record_id}"); // To get record instance
$param_map=array("page"=>"1","per_page"=>"200"); // key-value pair containing all the parameters - optional
$header_map = array("if-modified-since"=>"2019-12-12T15:26:49+05:30"); // key-value pair containing all the headers - optional
$responseIns = $record->getAttachments($param_map, $header_map); // to get the attachments
$attachments = $responseIns->getData(); // to get the attachments in form of ZCRMAttachment instance array
foreach ($attachments as $attchmentIns) {
echo $attchmentIns->getId(); // To get the note's attachment id
echo $attchmentIns->getFileName(); // To get the note's attachment file name
echo $attchmentIns->getFileType(); // To get the note's attachment file type
echo $attchmentIns->getSize(); // To get the note's attachment file size
echo $attchmentIns->getParentModule(); // To get the note's attachment parent module name
$parentRecord = $attchmentIns->getParentRecord();
echo $parentRecord->getEntityId(); // To get the note's parent record id
echo $attchmentIns->getParentName(); // To get the note name
echo $attchmentIns->getParentId(); // To get the note id
$createdBy = $attchmentIns->getCreatedBy();
echo $createdBy->getId(); // To get user_id who created the note's attachment
echo $createdBy->getName(); // To get user name who created the note's attachment
$modifiedBy = $attchmentIns->getModifiedBy();
echo $modifiedBy->getId(); // To get user_id who modified the note's attachment
echo $modifiedBy->getName(); // To get user name who modified the note's attachment
$owner = $attchmentIns->getOwner();
echo $owner->getId(); // To get the note's attachment owner id
echo $owner->getName(); // To get the note's attachment owner name
echo $attchmentIns->getCreatedTime(); // To get attachment created time
echo $attchmentIns->getModifiedTime(); // To get attachment modified time
}
}
}
$obj =new Record();
$obj->getAttachments();
<?php
use zcrmsdk\crm\setup\restclient\ZCRMRestClient;
require 'vendor/autoload.php';
class Record{
public function __construct()
{
$configuration =array("client_id"=>{client_id},"client_secret"=>{client_secret},"redirect_uri"=>{redirect_url},"currentUserEmail"=>{user_email_id});
ZCRMRestClient::initialize($configuration);
}
public function uploadAttachment()
{
$record = ZCRMRestClient::getInstance()->getRecordInstance("{module_api_name}", "{record_id}"); // To get record instance
$responseIns = $record->uploadAttachment("/path/to/file"); // $filePath - absolute path of the attachment to be uploaded.
echo "HTTP Status Code:" . $responseIns->getHttpStatusCode(); // To get http response code
echo "Status:" . $responseIns->getStatus(); // To get response status
echo "Message:" . $responseIns->getMessage(); // To get response message
echo "Code:" . $responseIns->getCode(); // To get status code
echo "Details:" . $responseIns->getDetails()['id'];
}
}
$obj =new Record();
$obj->uploadAttachment();
<?php
use zcrmsdk\crm\setup\restclient\ZCRMRestClient;
require 'vendor/autoload.php';
class Record{
public function __construct()
{
$configuration =array("client_id"=>{client_id},"client_secret"=>{client_secret},"redirect_uri"=>{redirect_url},"currentUserEmail"=>{user_email_id});
ZCRMRestClient::initialize($configuration);
}
public function downloadAttachment()
{
$record = ZCRMRestClient::getInstance()->getRecordInstance("{module_api_name}", "{record_id}"); // To get record instance
$fileResponseIns = $record->downloadAttachment("{attachment_id}");
$filePath = "file/path";
$fp = fopen($filePath.$fileResponseIns->getFileName(), "w"); // $filePath - absolute path where downloaded file has to be stored.
echo "HTTP Status Code:" . $fileResponseIns->getHttpStatusCode();
echo "File Name:" . $fileResponseIns->getFileName();
$stream = $fileResponseIns->getFileContent();
var_dump($stream);
fputs($fp, $stream);
fclose($fp);
}
}
$obj =new Record();
$obj->downloadAttachment();
<?php
use zcrmsdk\crm\setup\restclient\ZCRMRestClient;
require 'vendor/autoload.php';
class Record{
public function __construct()
{
$configuration =array("client_id"=>{client_id},"client_secret"=>{client_secret},"redirect_uri"=>{redirect_url},"currentUserEmail"=>{user_email_id});
ZCRMRestClient::initialize($configuration);
}
public function deleteAttachment()
{
$record = ZCRMRestClient::getInstance()->getRecordInstance("{module_api_name}", "{record_id}"); // To get record instance
$fileResponseIns = $record->deleteAttachment("{attachment_id}");
echo "HTTP Status Code:" . $fileResponseIns->getHttpStatusCode(); // To get http response code
echo "Status:" . $fileResponseIns->getStatus(); // To get response status
echo "Message:" . $fileResponseIns->getMessage(); // To get response message
echo "Code:" . $fileResponseIns->getCode(); // To get status code
echo "Details:" . $fileResponseIns->getDetails()['id'];
}
}
$obj =new Record();
$obj->deleteAttachment();
<?php
use zcrmsdk\crm\setup\restclient\ZCRMRestClient;
require 'vendor/autoload.php';
class Record{
public function __construct()
{
$configuration =array("client_id"=>{client_id},"client_secret"=>{client_secret},"redirect_uri"=>{redirect_url},"currentUserEmail"=>{user_email_id});
ZCRMRestClient::initialize($configuration);
}
public function uploadPhoto()
{
$record = ZCRMRestClient::getInstance()->getRecordInstance("{module_api_name}", "{record_id}"); // To get record instance
$responseIns = $record->uploadPhoto("path/to/photo"); // $photoPath - absolute path of the photo to be uploaded.
echo "HTTP Status Code:" . $responseIns->getHttpStatusCode(); // To get http response code
echo "Status:" . $responseIns->getStatus(); // To get response status
echo "Message:" . $responseIns->getMessage(); // To get response message
echo "Code:" . $responseIns->getCode(); // To get status code
echo "Details:" . $responseIns->getDetails()['id'];
}
}
$obj =new Record();
$obj->uploadPhoto();
<?php
use zcrmsdk\crm\setup\restclient\ZCRMRestClient;
require 'vendor/autoload.php';
class Record{
public function __construct()
{
$configuration =array("client_id"=>{client_id},"client_secret"=>{client_secret},"redirect_uri"=>{redirect_url},"currentUserEmail"=>{user_email_id});
ZCRMRestClient::initialize($configuration);
}
public function downloadPhoto()
{
$record = ZCRMRestClient::getInstance()->getRecordInstance("{module_api_name}", "{record_id}"); // To get record instance
$fileResponseIns = $record->downloadPhoto(); // to download the photo
echo "HTTP Status Code:" . $fileResponseIns->getHttpStatusCode();
echo "File Name:" . $fileResponseIns->getFileName();
$filePath = "/Users/pravesh-pt2533/Desktop/";
$fp = fopen($filePath.$fileResponseIns->getFileName(), "w"); // $filePath - absolute path where the downloaded photo is stored.
$stream = $fileResponseIns->getFileContent();
fputs($fp, $stream);
fclose($fp);
}
}
$obj =new Record();
$obj->downloadPhoto();
<?php
use zcrmsdk\crm\setup\restclient\ZCRMRestClient;
require 'vendor/autoload.php';
class Record{
public function __construct()
{
$configuration =array("client_id"=>{client_id},"client_secret"=>{client_secret},"redirect_uri"=>{redirect_url},"currentUserEmail"=>{user_email_id});
ZCRMRestClient::initialize($configuration);
}
public function deletePhoto()
{
$record = ZCRMRestClient::getInstance()->getRecordInstance("{module_api_name}", "{record_id}"); // To get record instance
$responseIns = $record->deletePhoto(); // $photoPath - absolute path of the photo to be uploaded.
echo "HTTP Status Code:" . $responseIns->getHttpStatusCode(); // To get http response code
echo "Status:" . $responseIns->getStatus(); // To get response status
echo "Message:" . $responseIns->getMessage(); // To get response message
echo "Code:" . $responseIns->getCode(); // To get status code
echo "Details:" . $responseIns->getDetails()['id'];
}
}
$obj =new Record();
$obj->deletePhoto();
<?php
use zcrmsdk\crm\crud\ZCRMJunctionRecord;
use zcrmsdk\crm\setup\restclient\ZCRMRestClient;
require 'vendor/autoload.php';
class Record{
public function __construct()
{
$configuration =array("client_id"=>{client_id},"client_secret"=>{client_secret},"redirect_uri"=>{redirect_url},"currentUserEmail"=>{user_email_id});
ZCRMRestClient::initialize($configuration);
}
public function addRelation()
{
$record = ZCRMRestClient::getInstance()->getRecordInstance("{module_api_name}", "{record_id}"); // To get record instance
$junctionrecord = ZCRMJunctionRecord::getInstance("{module_api_name}", "{record_id}"); // to get the junction record instance
$responseIns = $record->addRelation($junctionrecord); // to add a relation between the record and the junction record
echo "HTTP Status Code:" . $responseIns->getHttpStatusCode(); // To get http response code
echo "Status:" . $responseIns->getStatus(); // To get response status
echo "Message:" . $responseIns->getMessage(); // To get response message
echo "Code:" . $responseIns->getCode(); // To get status code
echo "Details:" . $responseIns->getDetails()['id'];
}
}
$obj =new Record();
$obj->addRelation();
<?php
use zcrmsdk\crm\crud\ZCRMJunctionRecord;
use zcrmsdk\crm\setup\restclient\ZCRMRestClient;
require 'vendor/autoload.php';
class Record{
public function __construct()
{
$configuration =array("client_id"=>{client_id},"client_secret"=>{client_secret},"redirect_uri"=>{redirect_url},"currentUserEmail"=>{user_email_id});
ZCRMRestClient::initialize($configuration);
}
public function removeRelation()
{
$record = ZCRMRestClient::getInstance()->getRecordInstance("{module_api_name}", "{record_id}"); // To get record instance
$junctionrecord = ZCRMJunctionRecord::getInstance("{module_api_name}", "{record_id}"); // to get the junction record instance
$responseIns = $record->removeRelation($junctionrecord); // to add a relation between the record and the junction record
echo "HTTP Status Code:" . $responseIns->getHttpStatusCode(); // To get http response code
echo "Status:" . $responseIns->getStatus(); // To get response status
echo "Message:" . $responseIns->getMessage(); // To get response message
echo "Code:" . $responseIns->getCode(); // To get status code
echo "Details:" . $responseIns->getDetails()['id'];
}
}
$obj =new Record();
$obj->removeRelation();
<?php
use zcrmsdk\crm\setup\restclient\ZCRMRestClient;
require 'vendor/autoload.php';
class Record{
public function __construct()
{
$configuration =array("client_id"=>{client_id},"client_secret"=>{client_secret},"redirect_uri"=>{redirect_url},"currentUserEmail"=>{user_email_id});
ZCRMRestClient::initialize($configuration);
}
public function addTags()
{
$record = ZCRMRestClient::getInstance()->getRecordInstance("{module_api_name}", "{record_id}"); // To get record instance
$tagNames = array(
"test1",
"test2"
); // to create array of tag names
$responseIns = $record->addTags($tagNames); // to add tags
echo "HTTP Status Code:" . $responseIns->getHttpStatusCode(); // To get http response code
echo "Status:" . $responseIns->getStatus(); // To get response status
echo "Message:" . $responseIns->getMessage(); // To get response message
echo "Code:" . $responseIns->getCode(); // To get status code
echo "Details:" . json_encode($responseIns->getDetails());
}
}
$obj =new Record();
$obj->addTags();
<?php
use zcrmsdk\crm\setup\restclient\ZCRMRestClient;
require 'vendor/autoload.php';
class Record{
public function __construct()
{
$configuration =array("client_id"=>{client_id},"client_secret"=>{client_secret},"redirect_uri"=>{redirect_url},"currentUserEmail"=>{user_email_id});
ZCRMRestClient::initialize($configuration);
}
public function removeTags()
{
$record = ZCRMRestClient::getInstance()->getRecordInstance("{module_api_name}", "{record_id}"); // To get record instance
$tagNames = array(
"test1",
"test2"
); // to create array of tag names
$responseIns = $record->removeTags($tagNames); // to remove tags
echo "HTTP Status Code:" . $responseIns->getHttpStatusCode(); // To get http response code
echo "Status:" . $responseIns->getStatus(); // To get response status
echo "Message:" . $responseIns->getMessage(); // To get response message
echo "Code:" . $responseIns->getCode(); // To get status code
echo "Details:" . json_encode($responseIns->getDetails());
}
}
$obj =new Record();
$obj->removeTags();