InterConnectaOrg / zoho-crm

MIT License
2 stars 4 forks source link

How to create a record? #2

Closed onlinecheckwriter-zz closed 4 years ago

onlinecheckwriter-zz commented 4 years ago

Is it something like this? $new = new \Zoho\CRM\Client(); $data = zohocrm::createRecord("Leads",["Account_Name"=>"Testing1000"]); it is saying not found

emw3 commented 4 years ago

Hi @onlinecheckwriter,

To create a record:

use Zoho\CRM\Facades\ZohoCRM;

class MyController extends Controller
{
    public function store(Request $request)
    {
        $record = ZohoCRM::createRecords('Leads', [
            'Account_Name' => "Testing"
        ]);

        var_dump($record);
    }
}
onlinecheckwriter-zz commented 4 years ago

If we follow your documentation: We are getting an error: vendor\interconnecta\zoho-crm\src\API.php392

But if we called as follow


class MyController extends Controller
{
    public function store(Request $request)
    {
        $record = ZohoCRM::createRecords('Leads', [[
            'Account_Name' => "Testing"
        ]]);

        var_dump($record);
    }
}

We are getting this error: array(1) { [0]=> array(4) { ["code"]=> string(19) "MANDATORY_NOT_FOUND" ["details"]=> array(1) { ["api_name"]=> string(9) "Last_Name" } ["message"]=> string(24) "required field not found" ["status"]=> string(5) "error" } }

emw3 commented 4 years ago

You need to map the mandatory field "Last Name". It is a required field in your Lead's module.

 $record = ZohoCRM::createRecords('Leads', [ [
    "Account_Name" => "Testing",
    "Last_Name" => "Joe Doe"
 ]]);
hackel commented 4 years ago

@emw3 This is actually a bug. Client::createRecord tries to call the non-existent method API::createRecord. I would suggest keeping it as a shortcut for $this->createRecords($module, [$record], $params);.