asciisd / zoho

Zoho package for Laravel
36 stars 36 forks source link

how to retrieve lead id from response . #19

Closed asifaecor closed 3 years ago

asifaecor commented 3 years ago
   $request = (object)$request;
    $leads = ZohoManager::useModule('Leads');
    $record = $leads->getRecordInstance();
    $record->setFieldValue('First_Name', $request->fname);
    $record->setFieldValue('Last_Name', $request->lname);
    $record->setFieldValue('Job_Title', $request->title);
    $record->setFieldValue('Email',$request->email);
    $record->setFieldValue('Phone',$request->phone);
    $record->setFieldValue('Company',$request->company);
    $record->setFieldValue('Country',$request->country);
    $record->setFieldValue('Product_Interest',implode(",", $request->product_interest));
    $record->setFieldValue('Lead_Type','Demo');
    $record->setFieldValue('Industry',$request->industry);
    $record->setFieldValue('Vehicle_Count',$request->vehicle_count);
    $record->setFieldValue('Fleet_Services',implode(",",$request->fleet_services));
    $record->setFieldValue('People_Count',$request->people_count);
    $record->setFieldValue('Workforce_Services',implode(",",$request->workforce_services));
    $record->setFieldValue('Demo_Schedule_Time',$request->date.' '.$request->timeoption);
    $lead = $record->create()->getData();
            $id = $lead->getEntityId();

    $event = ZohoManager::useModule('Events');
    $eventrecord = $event->getRecordInstance();
    $eventrecord->setFieldValue('Event_Title','Schedule A Demo');
    $eventrecord->setFieldValue('Start_DateTime','2021-07-16T14:32:23+05:30');
    $eventrecord->setFieldValue('End_DateTime','2021-07-16T15:32:23+05:30');
    $eventrecord->setFieldValue('What_Id',$id);
            //$eventrecord->setFieldValue('What_Id',$id);
            $event = $eventrecord->create()->getData();

HI above code is working fine when I m comment $eventrecord->setFieldValue('What_Id',$id);
whenever I uncomment this line I will get following error.

image

aemaddin commented 3 years ago

as I can see you already getting the id by

$id = $lead->getEntityId();

however if you asking about the error, I think its because you didn't set a mandatory field on 'Events' module, you can go to the CRM settings page and try to figure out api_names for mandatory fields,

Settings->(under DEVELOPER SPACE section)->APIs->API names

APIs
aemaddin commented 3 years ago

This issue has been closed because there has been no response to our request for more information from the original author. With only the information that is currently in the issue, we don't have enough information to take action. Please reach out if you have or find the answers we need so that we can investigate further.