1

I am trying to create sql table structure in salesforce as an object. In salesforce, there is a field limitation that allows only creation of 100 fields (I am using PE). My SQL table contains more than 200 fields. Is there a way to know how many fields have left for creation so I do not hit the field limit issue. I am doing this all via Metadata API and needs solution around it only.

4

yes, use EntityLimit of Tooling API

Represents the limits for an object as displayed in the Setup UI.

you need to look CustomFields type and get Remaining field value.


Example, how to get all Account limits in Apex:

HttpRequest req = new HttpRequest();
req.setHeader('Authorization', 'Bearer ' + UserInfo.getSessionID());
req.setHeader('Content-Type', 'application/json');    
req.setEndpoint('https://instance.my.salesforce.com/services/data/v44.0/tooling/query/?q=SELECT+Type,+Label,+Remaining,+Max,+EntityDefinitionid+FROM+EntityLimit+where+EntityDefinitionid+=+\'Account\'' );
req.setMethod('GET');
Http h = new Http();
HttpResponse res = h.send(req);

response is:

{
    "size": 11,
    "totalSize": 11,
    "done": true,
    "queryLocator": null,
    "entityTypeName": "EntityLimit",
    "records": [
        {
            "attributes": {
                "type": "EntityLimit",
                "url": "/services/data/v44.0/tooling/sobjects/EntityLimit/Account.CustomFields"
            },
            "Type": "CustomFields",
            "Label": "Custom Fields",
            "Remaining": 451,
            "Max": 500,
            "EntityDefinitionId": "Account"
        },
        {
            "attributes": {
                "type": "EntityLimit",
                "url": "/services/data/v44.0/tooling/sobjects/EntityLimit/Account.RollupSummary"
            },
            "Type": "RollupSummary",
            "Label": "Rollup Summary Fields",
            "Remaining": 23,
            "Max": 25,
            "EntityDefinitionId": "Account"
        },
        {
            "attributes": {
                "type": "EntityLimit",
                "url": "/services/data/v44.0/tooling/sobjects/EntityLimit/Account.CustomRelationship"
            },
            "Type": "CustomRelationship",
            "Label": "Custom Relationship Fields",
            "Remaining": 39,
            "Max": 40,
            "EntityDefinitionId": "Account"
        },
        {
            "attributes": {
                "type": "EntityLimit",
                "url": "/services/data/v44.0/tooling/sobjects/EntityLimit/Account.ActiveRules"
            },
            "Type": "ActiveRules",
            "Label": "Active Workflow Rules",
            "Remaining": 42,
            "Max": 50,
            "EntityDefinitionId": "Account"
        },
        {
            "attributes": {
                "type": "EntityLimit",
                "url": "/services/data/v44.0/tooling/sobjects/EntityLimit/Account.TotalRules"
            },
            "Type": "TotalRules",
            "Label": "Total Workflow Rules",
            "Remaining": 492,
            "Max": 500,
            "EntityDefinitionId": "Account"
        },
        {
            "attributes": {
                "type": "EntityLimit",
                "url": "/services/data/v44.0/tooling/sobjects/EntityLimit/Account.ApprovalProcesses"
            },
            "Type": "ApprovalProcesses",
            "Label": "Approval Processes",
            "Remaining": 500,
            "Max": 500,
            "EntityDefinitionId": "Account"
        },
        {
            "attributes": {
                "type": "EntityLimit",
                "url": "/services/data/v44.0/tooling/sobjects/EntityLimit/Account.ActiveLookupFilters"
            },
            "Type": "ActiveLookupFilters",
            "Label": "Active Lookup Filters",
            "Remaining": 5,
            "Max": 5,
            "EntityDefinitionId": "Account"
        },
        {
            "attributes": {
                "type": "EntityLimit",
                "url": "/services/data/v44.0/tooling/sobjects/EntityLimit/Account.ActiveValidationRules"
            },
            "Type": "ActiveValidationRules",
            "Label": "Active Validation Rules",
            "Remaining": 95,
            "Max": 100,
            "EntityDefinitionId": "Account"
        },
        {
            "attributes": {
                "type": "EntityLimit",
                "url": "/services/data/v44.0/tooling/sobjects/EntityLimit/Account.VLookup"
            },
            "Type": "VLookup",
            "Label": "VLOOKUP Functions",
            "Remaining": 10,
            "Max": 10,
            "EntityDefinitionId": "Account"
        },
        {
            "attributes": {
                "type": "EntityLimit",
                "url": "/services/data/v44.0/tooling/sobjects/EntityLimit/Account.SharingRules"
            },
            "Type": "SharingRules",
            "Label": "Sharing Rules (Both Owner- and Criteria-based)",
            "Remaining": 292,
            "Max": 300,
            "EntityDefinitionId": "Account"
        },
        {
            "attributes": {
                "type": "EntityLimit",
                "url": "/services/data/v44.0/tooling/sobjects/EntityLimit/Account.CbsSharingRules"
            },
            "Type": "CbsSharingRules",
            "Label": "Sharing Rules (Criteria-based Only)",
            "Remaining": 49,
            "Max": 50,
            "EntityDefinitionId": "Account"
        }
    ]
}
  • Oleksandr Berehovskiy, Thank you for the reply!! I will check it out. – Kevin Jan 11 at 14:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.