Git Product home page Git Product logo

eloquentsalesforce's People

Contributors

antonio-bp avatar daikazu avatar danielpetrica avatar edwinsiebel avatar fabiopili avatar lacrc avatar menegain-mathieu avatar nickturrietta avatar nyccto avatar rakshitbharat avatar roblesterjr04 avatar scrutinizer-auto-fixer avatar seankndy avatar wit3 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

eloquentsalesforce's Issues

str_replaceLast

This function doesn't exist and never has. Seems like the Str::replace to str_replace caught this one

return str_replaceLast('try', 'tries', $string);

maybe this function part of the function should be covered by tests as well by using a table on the test that ends in "try" to trigger the if?

MALFORMED_QUERY response

For some queries, for instance this:

Account::where('PersonEmail', $customer->email)
->orWhere('MyToken__c', $customer->token)
->first();

I often get a "MALFORMED_QUERY" error response. Salesforce support tells me the query they receive is this:

select Id, Name, Phone, OwnerId, PersonEmail, Market__pc , Booking_Engine_Customer_Id__pc, MyToken__c from Account whe
re PersonEmail = [email protected] or MyToken__c = 12345678
9 limit 1

While the (according to them correct) query below will return the expected result:

select Id,Name,Phone,OwnerId,PersonEmail, Market__pc, Booking_Engine_Customer_Id__pc, MyToken__c from Account where PersonEmail = '[email protected]' OR MyToken__c = '123456789' limit 1

I'd be thrilled for an idea how to solve this

Using 2 Salesforce sessions concurrently

Can we swap the connections details when working with two different SalesForce instances?

i.e.

'soql_region_1' => [
            'driver' => 'soql',
            'database' => null,
           ...
],

'soql_region_2' => [
            'driver' => 'soql',
            'database' => null,
           ...
],

The idea is to be able to swap the connections on the fly like so

$region1Leads = \App\SaleforceModels\Lead::on('soql_region_1')->get();

$region2Leads = \App\SaleforceModels\Lead::on('soql_region_2')->get();

At the moment with the current set up, when running the above code I get the error below

 local.ERROR: InvalidArgumentException: Unsupported driver [soql] in ...\Database\Connectors\ConnectionFactory.php:283

Any ideas on how to fix or achieve the result?

Value of filter criterion for field must be of type string and should be enclosed in quotes

Laravel 7.30.4
rob-lester-jr04/eloquent-sales-force 2.7.5

Anyone have any ideas here:

I can force this to be in quotes but I get no results.

When I add like and a % after the search I get the result.

Simple first() or get() calls are not working on some fields. Not sure if its a versioning or method piece.

[
{
"message": "\nProductCode from Product2 where ProductCode = 3999\n ^\nERROR at Row:1:Column:44\nvalue of filter criterion for field 'ProductCode' must be of type string and should be enclosed in quotes",
"errorCode": "INVALID_FIELD"
}
] (SQL: select Id, ProductCode from Product2 where ProductCode = 3999)

I change it around and write different thins and it gets confused wether or not its a string. that what it seems, if I use AAA3999 its fine. Sometimes....

Heres are examples where I get varying results where the api is questioning the quote formatting of the native where statement which I make and it works "frequently". SO when I get an exception about the formatting or "string value enclosed in quotes" I change it to a like statement and it works, same variable. makes no sense to me....

    try {
                        $product2 = Product2::where('ProductCode', '=', "{$item->Item}")->first();
                    } catch(\Exception $ex) {
                        $product2 = Product2::where('ProductCode', 'like', "{$item->Item}%")->first();
                   }

Laravel 7?

Is there a list of things needed to be upgraded in order for the package to fit Laravel 7?
I'll be glad to contribute if needed.

ErrorException (E_NOTICE) Undefined index: fieldItems


ErrorException (E_NOTICE)
 Undefined index: fieldItems


I'm not so sure why I'm getting this error.
Does anyone know about this?

/Users/jayomayan/intercon/vendor/rob-lester-jr04/eloquent-sales-force/src/ServiceProvider.php

        $fields = Arr::pluck($layouts["fieldItems"], 'layoutComponents.0');

Querying a checkbox field with "where()" method breaks

The reason is
->where('fieldName', 'false')
is being translated to the SOQL query as
"where fieldName = 'false' "

and:
->where('fieldName', false)
is being translated to the SOQL query as
"where fieldname= 0"

Both of this options returns an error.

There are 2 possible fixes:

  1. Update the where method to handle boolean data and translate it properly. (recommended, it is a very common method)
  2. Update the readme file to let people use the method whereNotNull() (SOQLGrammar.php) which is currently working for checkbox fields
    AND add another method whereIsNull for a "false" field.

Good luck,
Tzahi.

SOQLBatch has issue with Laravel 7.0

got following exception when trying to get records
Exception: Declaration of Lester\EloquentSalesForce\Database\SOQLBatch::push($builder) should be compatible with Illuminate\Support\Collection::push(...$values)

File: SOQLBatch.php
Line: 49
Function: push($builder)

Authentication - Object Storage

Hello, I am wondering why the object storage (from the forrest package) is not supported. I noticed that session and cache are the only options. Is this something that just hasn't become a priority yet or is this not currently possible with the implementation?

I am using this package (which is awesome by the way) to support many to many SF accounts to customers. The underlying Forrest package supports this using:

$client->setCredentials(['username' => '[email protected]', 'password'=> '1234']);
$client->authenticate();

Any insight into why this is not supported or how to support it would be helpful, I would also be willing to submit a PR if this is possible.

Numeric comparisons are failing

When I try to do a comparison like the following:

$myquery = SalesforceThing::where('Maximum_Number_of_Students__c', '>=', 1)->get();

I get the following error:

value of filter criterion for field 'Maximum_Number_of_Students__c' must be of type double and should not be enclosed in quotes

I definitely need a fix for this! Any thoughts?

Can't save new record- returns a '400 Bad Request` response

When trying to save a new record in a brand new SF custom object I gets this error:
"Salesforce response error: Client error: POST https://BLABLA.my.salesforce.com/services/data/v46.0/sobjects/ObjectName__c` resulted in a 400 Bad Request response"`

From Salesforce developer guide, 400 status code is being returned when:

400 | The request couldn’t be understood, usually because the JSON or XML body contains an error.

Also tried it without a model using
SObject::object('ObjectName__c', $array)->save();

returned the same error.

Your help will be appreciated,
And thank you for sharing this cool feature!

Queries taking too long

Hi! First, thanks for the package I was looking for something just like this!

My issue: I tried querying my Salesforce instance for Contacts but the query took sooo long.

I followed the steps in the installation and then:
Contact::all()
It took 4 minutes to finish and return 232 Contacts.
Is this the normal behavior? Can I do anything to speed it up?

Job dispatching wrapper for SFDC jobs

So the Forrest package supports accessing the SFDC job queue and i thought it would be cool if we found a way to work with SFDC jobs much like we do Laravel Queue jobs. Looking for some help coming up with ideas on how that would look from an execution standpoint! Looking for contributors!

Duplicate records inserted when using updateOrCreate

This Eloquent Salesforce package is awesome but I'm have one slight issue that I'll explain.

In my app I use this package to write data to Salesforce in a console command that looks like this:

<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use App\Salesforce\PersonAccount;
use App\User;
use Log;

class SyncSalesforce extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'sync:salesforce';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Update Salesforce accounts and contacts';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {

        $users = User::get();

        $bar = $this->output->createProgressBar(count($users));

        $bar->start();

        foreach ($users as $user) {

            $person_account = PersonAccount::updateOrCreate(
                [
                    'RecordTypeId' => '0120Y000000ym5dQAA',
                    'PersonEmail' => $user->email
                ],
                [
                    'FirstName' => $user->first_name,
                    'LastName' => $user->last_name,
                    'Portal_ID__c' => $user->id,
                    'Reyker_Portal_ID__c' => $user->reyker_id,
                    'AML_Status__c' => $user->salesforce_aml_status,
                    'AML_Date__c' => $user->salesforce_aml_check_date,
                    'Investor_Type__c' => $user->salesforce_investor_type,
                    'Declaration_Date__c' => $user->salesforce_declaration_date,
                    'NI_Number__c' => optional($user->onboarding)->national_insurance_number,
                    'Date_of_birth__pc' => optional($user->onboarding)->salesforce_date_of_birth,
                    'ShippingStreet' => optional($user->onboarding)->salesforce_address,
                    'ShippingState' => optional($user->onboarding)->county,
                    'ShippingPostalCode' => optional($user->onboarding)->postcode,
                    'ShippingCountry' => optional($user->onboarding)->country,
                    'Registration_Date__c' => $user->salesforce_created_at,
                ]
            );

            //If Newable Private Investing is not set as an area of business, add it
            if (strpos($person_account->Area_of_Business__c, 'Newable Private Investing') === false) {

                //If area of business already has items selected, append NPI to the selected items
                if ($person_account->Area_of_Business__c !== null) {
                    $person_account->Area_of_Business__c = $person_account->Area_of_Business__c . ";Newable Private Investing";
                }

                //If area of business is null, add NPI as the first item
                else {
                    $person_account->Area_of_Business__c = "Newable Private Investing";
                }

                //Update person account
                $person_account->save();
            }

            $this->info("{$user->full_name} -  {$user->email} was checked.");

            $bar->advance();
        }

        $bar->finish();

        $this->info("Salesforce synchronisation complete. " . count($users) . " users updated.");
        Log::info("Salesforce synchronisation complete. " . count($users) . " users updated.");
    }
}

As you can see I'm using the model method updateOrCreate however on the first run it creates one duplicate for each entry.

Is this a bug?

ExceptionError: Declaration of Lester\EloquentSalesForce\Database\SOQLHasOneOrMany::getRelationCountHash() should be compatible with Illuminate\Database\Eloquent\Relations\Relation::getRelationCountHash($incrementJoinCount = true)

Hi, First of all, thank you for this great package.

I am receiving this error after upgrading to Laravel 8.

Declaration of Lester\EloquentSalesForce\Database\SOQLHasOneOrMany::getRelationCountHash() should be compatible with Illuminate\Database\Eloquent\Relations\Relation::getRelationCountHash($incrementJoinCount = true) {"exception":"[object] (ErrorException(code: 0): Declaration of Lester\EloquentSalesForce\Database\SOQLHasOneOrMany::getRelationCountHash() should be compatible with Illuminate\Database\Eloquent\Relations\Relation::getRelationCountHash($incrementJoinCount = true) at rob-lester-jr04\eloquent-sales-force\src\Database\SOQLHasOneOrMany.php:370

Could you update the following method to make it compatible with Laravel 8, please?

Current:

<?php

namespace Lester\EloquentSalesForce\Database;

use Lester\EloquentSalesForce\Model;
use Lester\EloquentSalesForce\Facades\SObjects;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Relations\Relation;

abstract class SOQLHasOneOrMany extends Relation
{
    /**
     * Get a relationship join table hash.
     *
     * @return string
     */
    public function getRelationCountHash()
    {
    	return 'laravel_reserved_' . static::$selfJoinCount++;
    }
}

new:

<?php

namespace Illuminate\Database\Eloquent\Relations;

use Closure;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Query\Expression;
use Illuminate\Support\Arr;
use Illuminate\Support\Traits\ForwardsCalls;
use Illuminate\Support\Traits\Macroable;

/**
 * @mixin \Illuminate\Database\Eloquent\Builder
 */
abstract class Relation
{
    /**
     * Get a relationship join table hash.
     *
     * @param  bool $incrementJoinCount
     * @return string
     */
    public function getRelationCountHash($incrementJoinCount = true)
    {
        return 'laravel_reserved_'.($incrementJoinCount ? static::$selfJoinCount++ : static::$selfJoinCount);
    }
}

Many thanks,

Laravel 6.0 Support

we would like to upgrade our project to laravel 6.0 but this package which we depend on is not yet ready for the switch.

#27 is a pull request to add laravel 6.0 support, maybe this can help in getting this package updated?

Replacing SOQL relationship query with eloquent

I can get the relationships using the model's columns array using dot notation and nested selects. But I have not been able to refactor to using eloquent relations

The following works

Mandate::first();

with the supporting code...

<?php

namespace App\SaleforceModels;

use Lester\EloquentSalesForce\Model;
use Lester\EloquentSalesForce\Database\SOQLBuilder;

class Mandate extends Model
{
    protected $table = 'Company__c';

    public $columns = [
        'Id',
        'Name',
        'Opportunity__r.Id',
        'Opportunity__r.Name',
        '(Select Id, Name from Shareholders__r)',
    ];
}

My attempt to use relations does not. Could you point out what I'm doing wrong here?

return Mandate::with('shareholders')->find($this->salesforce_id);

Omniphx\Forrest\Exceptions\SalesforceException [ { "errorCode": "NOT_FOUND", "message": "The requested resource does not exist" } ]

supporting code below

<?php

namespace App\SaleforceModels;

use Lester\EloquentSalesForce\Model;
use Lester\EloquentSalesForce\Database\SOQLBuilder;
use App\SaleforceModels\Shareholder;
use App\SaleforceModels\Opportunity;

class Mandate extends Model
{
    protected $table = 'Company__c';

    public $columns = [
        'Id',
        'Name',
    ];

    public function shareholders()
    {
        return $this->belongsToMany(Shareholder::class);
    }

    public function opportunity()
    {
        return $this->belongsTo(Opportunity::class);
    }
}
<?php

namespace App\SaleforceModels;

use Lester\EloquentSalesForce\Model;
use Lester\EloquentSalesForce\Database\SOQLBuilder;

class Shareholder extends Model
{
    protected $table = 'Shareholder__c';

    public $columns = [
        'Id',
        'Name',
    ];
}
<?php

namespace App\SaleforceModels;

use Lester\EloquentSalesForce\Model;
use Lester\EloquentSalesForce\Database\SOQLBuilder;

class Opportunity extends Model
{
    protected $table = 'Opportunity__c';

    public $columns = [
        'Id',
        'Name',
    ];
}

Is it possible to use model observers?

My question is, as the base model in this package is an extension of the base eloquent model, is it possible to use model observers as you would with any standard model?

In my experience they do not seem to work in this scenario however, I could be wrong.

Am I just missing something?

Thanks

Impossible to connect with UserPassword

Hello,

I need to log in via the UsernamePassword method. But every time I get this error:

POST https://test.salesforce.com/services/oauth2/token resulted in a 400 Bad Request response: {"error": "invalid_grant", "error_description": "authentication failure"}

Code in the .env file:

CONSUMER_KEY = XXXXXXXXXXXXXXX
CONSUMER_SECRET = XXXXXXXXXXXX
CALLBACK_URI = https: //app.laravel.test/callback

LOGIN_URL = https: //test.salesforce.com (sandbox)

[email protected]
PASSWORD = PasswordAndTokenWithoutSpace

Code in config/database.php

'soql' => [
            'driver' => 'soql',
            'database' => null,
            'consumerKey'    => env('CONSUMER_KEY'),
            'consumerSecret' => env('CONSUMER_SECRET'),
            'callbackURI' => env('CALLBACK_URI'),
            'loginURL'       => env('LOGIN_URL'),
            // Only required for UserPassword authentication:
            'username'       => env('USERNAME'),
            // Security token might need to be ammended to password unless IP Address is whitelisted
            'password'       => env('PASSWORD')
        ],

These are the API (Enable OAuth Settings) configurations on salesforce:

image

Is there any way to avoid "UNABLE_TO_LOCK_ROW" error every once in a while?

I get this error every once in a while and it's very annoying.
"message": "unable to obtain exclusive access to this record or 1 records: 001XXXXXXXXXXXXXX", "errorCode": "UNABLE_TO_LOCK_ROW",
I can see that Salesforce API has some kind of solution for this error that sets the API to wait for the row to be released.
Is there any implementation for it in this package? any way to avoid it?

Thank you!

accessors don't seem to work at all

On my Salesforce object, I have a column Website_Availability__c. I have it named in $columns = [] and accessing it directly works just fine! However, I'd like to write an accessor for it so that I can refer to it elsewhere as just availability_label. The general format for accessors looks like this:

  public function getAvailabilityLabelAttribute()
  {
    return $this->attributes['Website_Availability__c'];
  }

When I try this, I get

in_array() expects parameter 2 to be array, string given

Stack trace says it's line 38 of this file: /vendor/rob-lester-jr04/eloquent-sales-force/src/Database/SOQLBuilder.php that's causing the error.

I can work around this for now but I would definitely really like it if accessors (and mutators, which I'm guessing are going to have the same issue) would work properly!

using batch functionality causes exception

I am trying to use the batch method, but it always throws this exception:

Omniphx\Forrest\Exceptions\SalesforceException
[ { "message": "The Content-Encoding of the message specifices GZIP, but the data is not in valid GZIP format", "errorCode": "UNKNOWN_EXCEPTION" } ]

I tried to change the config to 'eloquent_sf.forrest.defaults.compression' => false and 'eloquent_sf.forrest.defaults.compressionType' => null, but this has no effect.

Objects don't seem to be fillable

I have an object called a Campaign Member which I can create with no issue however when I try to update the object many of the fields are not updated.

See this code sample.


$this->campaignMember->fill(
    array_merge($data, ['Status' => "Responded"])
)->save();

In this example the object's status is updated but everything in the data array is not.

Here is the $data array


$data = [
  "Salutation" => "Mr"
  "FirstName" => "Palmer"
  "LastName" => "Edwards"
  "Suffix" => "Nihil iste est eum a"
  "Email" => "[email protected]"
  "Title" => "Reprehenderit eum f"
  "Phone" => "+1 (858) 405-9048"
  "MobilePhone" => "+1 (674) 381-1799"
  "ShippingStreet" => "Aliqua Ut rem sint"
  "ShippingState" => "Nostrud sed quia sin"
  "ShippingPostalCode" => "Duis consectetur ma"
  "Website" => "https://www.rile.mobi"
  "Company_House_Number__c" => "687"
  "NumberOfEmployees" => "633"
  "Started_Trading__c" => "27-Dec-1995"
  "Primary_Industry__c" => "Energy, Oil & Gas"
  "Turnover__c" => "£40,000,000+"
  "Net_Profit_Before_Tax_Last_Financial_Yr__c" => "£50,000 - £99,999"
  "Balance_Sheet_Euro_43m__c" => "1"
  "Subsidary_Rule__c" => "0"
  "Parent_Rule__c" => "1"
  "Difficulty__c" => "1"
  "Total_State_Aid__c" => "1"
  "X1_Funding" => "Iste officia quam eius esse numquam voluptatum tempor aut vel reprehenderit ex"
  "X1_Purpose" => "Fugiat ratione voluptatem molestiae quos duis excepteur et eos quo commodi"
  "X1_Amount" => "65"
  "X2_Funding" => "Totam ut blanditiis aliquam quibusdam consequatur Maiores doloribus architecto voluptates ad molest"
  "X2_Purpose" => "Laborum officia sint ea ex odit quis"
  "X2_Amount" => "15"
  "X3_Funding" => "Sed dolores fuga Quod autem nisi dolor voluptate duis accusamus sit reprehenderit"
  "X3_Purpose" => "Aspernatur fugit harum accusantium corporis pariatur Eius numquam molestias"
  "X3_Amount" => "20"
  "Email_Third_Parties__c" => "1"
  "Phone_opt_in" => "1"
  "Status" => "Requested"
];

Array Pluck Function Missing in Laravel 6.0.3.

Hi,

After upgrading to laravel 6 adding a lead doesnt work.

Could you take a look please?

Thanks

Mike

{
"class": "Symfony\Component\Debug\Exception\FatalThrowableError",
"message": "Call to undefined function Lester\EloquentSalesForce\array_pluck()",
"code": 0,
"file": "/var/www/website/vendor/rob-lester-jr04/eloquent-sales-force/src/ServiceProvider.php:54",
"trace": [
"/var/www/website/vendor/rob-lester-jr04/eloquent-sales-force/src/Database/SOQLBuilder.php:123",
"/var/www/website/vendor/rob-lester-jr04/eloquent-sales-force/src/Database/SOQLBuilder.php:38",
"/var/www/website/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php:505",
"/var/www/website/app/Http/Controllers/QuoteController.php:1303",
"/var/www/website/vendor/laravel/framework/src/Illuminate/Routing/Controller.php:54",
"/var/www/website/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php:45",
"/var/www/website/vendor/laravel/framework/src/Illuminate/Routing/Route.php:219",
"/var/www/website/vendor/laravel/framework/src/Illuminate/Routing/Route.php:176",
"/var/www/website/vendor/laravel/framework/src/Illuminate/Routing/Router.php:680",
"/var/www/website/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:130",
"/var/www/website/app/Http/Middleware/ClearanceMiddleware.php:112",
"/var/www/website/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:171",
"/var/www/website/vendor/laravel/passport/src/Http/Middleware/CreateFreshApiToken.php:50",
"/var/www/website/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:171",
"/var/www/website/vendor/laravel/fra

SOQL Query on a multi-select picklist

My client has a custom field Contact_Type__c which is a multi select picklist. When doing a query, the field returns a string with "A;B;D" indicating the field has been selected with A, B, and D (but not C).

When doing an eloquent query, I can do a standard $query->where('Contact_Type__c','A') but the only records returned are the ones with only A selected. If they have more than one selected, the record is not returned. A "like" statement does not work either, with a hard error about it being a multi select picklist field.

Research found the correct SOQL way to do this is an "Includes" statement as described in this Salesforce KB article.

Example:
Select Id, Name, Contact_Type__c from Contact where Contact_Type__c includes ('Coach')

Is there any support for this is the package?

Thanks

Not possible to use with strings that contains numbers

Hi, here to report an issue on try to use where with string values that contains numbers.

This creates a SOQL bad formatted:

Account::where('Custom_String_Attribute__c', (string) 9999)->get()
// OR
Account::where('Custom_String_Attribute__c', "9999")->get()

This creates a SOQL well formatted:

Account::where('Custom_String_Attribute__c', (string) 10000)->get()
// OR
Account::where('Custom_String_Attribute__c', "10000")->get()

This issue exists due to to the following code section:

try {
if (\Carbon\Carbon::parse($item) !== false && !$this->isSalesForceId($item)) {
return $item;
}
} catch (\Exception $e) {
if (is_int($item) || is_float($item)) {
return $item;
} else {
return "'$item'";
}
}

This happens because for a 4 digit number string, Carbon::parse($number) results on a valid Carbon parameter, so it ends up returning the number as integer.

For my understanding all that block of code has not reason to be there, so it leave the parameter as it is being passed, but adding the quotes as '$item'.

I think that same issue potentially could exists on the following section of code since it is duplicated code:

try {
if (\Carbon\Carbon::parse($item) !== false && !$this->query->connection->isSalesForceId($item)) {
return $item;
}
} catch (\Exception $e) {
if (is_int($item) || is_float($item)) {
return $item;
} else {
return "'$item'";
}
}

Update 1 This #4 (comment) seems to be the same issue that I'm reporting here.

Update 2 Created a PR #54 with the unnecessary code removed, but for some reason the CI tests are not passing. Created another issue related to that.

Configuration path

Hi i have problems when the object call goes the next path
/services/data/v48.0/sobjects/Lead/

and must go to

/services/data/v48.0/sobjects/Lead/describe/

how could i fix this?
pd: i think its something about guzzleHttp

Error 411 when issuing GET request after a POST request

It's happening to me as well when i do

SObjects::object('Lead', $params)->save();

and immediately after above i do

SObjects::object('Lead')->find('00Q6325345D000001HROeUAO');

I get 411

Client error: GET https://afdasfasf.salesforce.com/services/data/v46.0/query?q=select+Id%2C+Name%2C+FirstName%2C+LastName%2C+Phone%2C+Email%2C+OwnerId%2C+contact_type__c%2C+Nationality__c%2C+Company%2C+Campuses__c%2C+Agent_Account__c%2C+LeadSource%2C+Address%2C+prospective_agency_location__c%2C+prospective_agency_market__c%2C+Status+from+Lead+where+Id+is+null+limit+1 resulted in a 411 Length Required response:

updateOrCreate equivalent

If Salesforce Duplicate Rules are active, save action of an SObject throws an client exception. Therefore Lead::updateOrCreate($attributes = [], $values = []) is needed to query existing record before and update it, otherwise save it.

Add support for mass delete

Regular eloquent behavior has the ability to mass delete a collection of models.
EloquentSalesforce does not have this functionality.

e.g
Leads::where('Status__c','please delete me')->delete();

returns an error

file: projectName/vendor/laravel/framework/src/Illuminate/Database/Connection.php
line: 485
message: "Call to a member function prepare() on null"

I see that the forest library is missing this functionality either on their documentation and maybe that is the reason you've missed it, but it seems that basic Salesforce rest API has that functionality and it is too bad to miss it (for my opinion).
Bulk delete Salesforce API reference

Instead of mapping the collection and sending it with separated API calls it can be done with one single API call.

Thank you for a great library.

Accessing Limit Info Headers

Hi, this package is great, thanks so much.

I'm currently working on trying to limit my calls to Salesforce to keep within the API rate limit. Is it possible for me to access the current limit info that Salesforce returns in the response headers?

Example headers from the docs

HTTP/1.1 200 OK
Date: Mon, 20 May 2013 22:21:46 GMT
Sforce-Limit-Info: api-usage=18/5000
Last-Modified: Mon, 20 May 2013 20:49:32 GMT
Content-Type: application/json;charset=UTF-8
Transfer-Encoding: chunked

Salesforce trailhead page the example of the header is from

Bump Guzzle

Hi,

Can we please bump Guzzle to 7.0.1 so that we can go to Laravel 8?

Thanks

Mike

Forrest works but EloquentSalesForce doesn't

I'd really like to use this extension, but I can't seem to get past the following error.

I query for a Customer by email address in Forrest and get the result.
I do a "where" for the same field and value in EloquentSalesForce, and unfortunately, I get this:

local.ERROR: [
    {
        "errorCode": "NOT_FOUND",
        "message": "The requested resource does not exist"
    }
] {"userId":1,"exception":"[object] (Omniphx\\Forrest\\Exceptions\\SalesforceException(code: 404): [
    {
        \"errorCode\": \"NOT_FOUND\",
        \"message\": \"The requested resource does not exist\"
    }
] at /var/sites/xxxx/vendor/omniphx/forrest/src/Omniphx/Forrest/Client.php:799, GuzzleHttp\\Exception\\ClientException(code: 404): Client error: `GET https://xxxx/services/data/v46.0/sobjects/Customer/describe/compactLayouts/primary/` resulted in a `404 Not Found` response:
[{\"errorCode\":\"NOT_FOUND\",\"message\":\"The requested resource does not exist\"}]

Any ideas?

Trouble saving an Object due to Security Settings on unrelated fields

Thanks for the great package! One issue I ran into and possible solution.

I tried to update the Description field on a Case object.

I received this error message.
Salesforce response error: Client error: ``PATCH https://******.my.salesforce.com/services/data/v47.0/sobjects/Case/5006C000004ZWUGQA4`` resulted in a ``400 Bad Request`` response: [{"message":"Unable to create/update fields: LastModifiedDate, CreatedDate, ContactEmail. Please check the security settings...

The culprit was that I had specified LastModifiedDate, CreatedDate, and ContactEmail in the $columns property on the Case model.

Even though I did not actively try to modify these properties, it looks they are still being passed to Salesforce as part of the patch request.

I'm not an expert but I think you can replace these 2 lines in Model.php:76

$body = $this->attributes;
unset($body['attributes'], $body['Id']);

with this line in the patch request (to only include the fields that have changed)

$body = $this->getDirty();

Thanks again! This package is helping us a lot.

Cannot run tests: Cannot redeclare PHPUnit\Framework\assertArrayHasKey()

After execute composer install, an error comes with the following output:

Fatal error: Cannot redeclare PHPUnit\Framework\assertArrayHasKey() (previously declared in /home/vagrant/code/EloquentSalesForce/vendor/phpunit/phpunit/src/Framework/Assert/Functions.php:79) in /home/vagrant/code/EloquentSalesForce/vendor/phpunit/phpunit/src/Framework/Assert/Functions.php on line 79

Not sure but think that is related to the following:

"autoload-dev": {
"psr-4": {
"Lester\\EloquentSalesForce\\Tests\\": "tests"
},
"files": [
"vendor/phpunit/phpunit/src/Framework/Assert/Functions.php"
]
},

Since autoload already has loaded functions on the referenced file.

Error Handling

How i go with error handling in laravel project?

Shall i just use generic exception handling?

Thank you.

omniphx/forrest configurations

Hi again!
Sorry for bothering, but is it possible to tweak the configuration for omniphx/forrest using your eloquent? I tried publishing their config file but it seems the configurations I made are not being loaded.

Thanks!

Backticks in the SOSQL causing error

I'm having an issue where the generated SOSQL contains backticks (`) around column names, and table names. I have run the generated query through the developer console inside of Salesforce and it also fails, until I remove the backticks?

The offending query is:
SELECT `Id` FROM `Account` LIMIT 1

The query that works based on Salesforce developer console is:
SELECT Id FROM Account LIMIT 1

Any thoughts?

describe not returning all the fields (including custom fields)

describe not returning all the fields (including custom fields)

Tried below:

- Account::describe(true)
-  SObjects::object('Account')->describe();
-  SObjects::object('Account')->describe(true);

etc

Not sure it is bug or i am doing something wrong.

Thank you.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.