Skip to content

Latest commit

 

History

History
54 lines (43 loc) · 1.44 KB

custom-sobject.md

File metadata and controls

54 lines (43 loc) · 1.44 KB

Introduction

If you wish to use your own objects in Object Repository then this object must be properly prepared. How it should look like:

  • fields should have jms/serializer annotations:
    • Type - because the lib needs to know how to match fields
    • the ones which are required when creating an object should be in create serialization group
    • the ones which are required when updating an object should be in update serialization group
  • the class should extend AbstractSObject

Example

First of all you need to create your own SObjectType enum and add new object name as class constant.

use Xsolve\SalesforceClient\Enum\AbstractSObjectType;

class MySObjectType extends AbstractSObjectType
{
    const MY_NEW_CLASS = 'MyNewClass';
}

After that you are able to create new object

use Xsolve\SalesforceClient\Model\AbstractSObject;
use Xsolve\SalesforceClient\Enum\AbstractSObjectType;

class MyNewClass extends AbstractSObject
{
    /**
     * @var string
     * @JMS\Type("string")
     * @JMS\Groups({"update", "create"})
     */
    protected $field;

    /**
     * {@inheritdoc}
     */
    public static function getSObjectName(): AbstractSObjectType
    {
        return MySObjectType::MY_NEW_CLASS();
    }
]

That's it! Now you are able to use MyNewClass in SObjectRepository.

↑ Table of contents ↑

← Custom request ←

→ Expression factory →