Questions tagged [describesobject]

Salesforce allows you to describe sObjects either by using sObject or field tokens, or the describeSObjects Schema method.

Filter by
Sorted by
Tagged with
0 votes
1 answer
40 views

How to get Object's Last Modified Date

I want to get the last modified date of a custom object definition in Apex or via Schema.DescribeSObjectResult doesn't have a method like getLastModifiedDate. But this info is clearly available in ...
Tuấn Trần quốc's user avatar
0 votes
1 answer
359 views

Efficient way to get field API name using field label

I have an requirement where I need to get the field api name using field label. For example, If I have field called Spouse_Phone__c(label = Spouse Phone), In apex I want to fetch the api name for that ...
Jason Rickert's user avatar
0 votes
2 answers
71 views

Adjust for missing fields in Test SObject avoid erorr - SObject row was retrieved via SOQL without querying the requested field

I have created an Apex Class to compare the current and prior values of SObjects. If differences are found the field labels are outputted to a ; separated string which I am using to populate a Multi-...
Jeff Callahan's user avatar
0 votes
1 answer
718 views

New fields for Contact (GenderIdentity and Pronouns) not returned by SOAP API v57

The reference page here and the documentation here indicates that there are two new fields on the Contact object called GenderIdentity and Pronouns that should be available with v57 of the API. But ...
VMS's user avatar
  • 89
0 votes
1 answer
160 views

common.apex.runtime.impl.ApexFieldToken

We have using SmartFactory class from long time. But, recently we are facing issues while running smartfactory unit class. Smart Factory Git hub repo. When I try to see the logs I've found out this. I ...
Pavan tej's user avatar
  • 1,479
0 votes
1 answer
96 views

I need to update all Contact Fields dynamically , I am trying throught Schema.SObjectType but getting some Error

I need to update all contact records from one record to another record which has 333 fields. It takes time to update this. I thought of updating the sobject field dynamically, but I'm getting "...
Vinitha vino's user avatar
0 votes
1 answer
623 views

Check if any field of a record has change dyncamically for a bulk trigger

I am trying to run validation in before update trigger which checks if a field value has changed in a particular status for the record. If it has changed then it adds a validation error. I wanted to ...
Madhurima's user avatar
  • 1,235
1 vote
1 answer
677 views

Schema.getGlobalDescribe().get(objectType); doesn't work with custom objects

I have a method that returns a map of all the fields where the field's API name is the key and the object Schema.SObjectField is the value. private static Map<String, Schema.SObjectField> ...
Jean's user avatar
  • 13
0 votes
1 answer
894 views

Get character limit for long text area using Apex

I am trying to get the character limit for a long text area. So for example I have a custom field called --> My_Text_area__c which has the char limit set as 5000. So how can I get this value in my ...
Maverick's user avatar
0 votes
1 answer
98 views

Ordering of fields in describeSObjects result

Is there any ordering to the fields in the describeSObjects result? We're using the connection.js file from this link. The DescribeSObjectsResult does not seem to mention any particular ordering.
VMS's user avatar
  • 89
1 vote
2 answers
7k views

Get object apiname based on recordid in lightning web component

Is it possible to het the object apiname based on a recordId in a lwc without a call to apex? Something like apex but then without going to backend: Id recordId = '001g000001jmmCA'; System.debug('...
Thomas's user avatar
  • 2,294
0 votes
1 answer
606 views

Determine `SObject type` from relationship name without an exhaustive search

Consider a general relation 'Foo.Bar' and some SObject type. An example might be 'Account.Id' and an Opportunity.SObjectType. Can I determine SObjectType Foo is referring to without getting the field ...
ipavlic's user avatar
  • 3,684
0 votes
1 answer
763 views

Retrieve the type of field using Schema classes

I am trying to create a generic class to retrieve the type of a field for any sObject. I am struggling with the following part of the code: String[] fields = ['Id','Name']; for(sObject o : ...
arpit gupta's user avatar
3 votes
0 answers
1k views

How to populate a picklist field with its label value instead of API value in apex

I have configured the picklist values like this. If I want to populate the picklist field by label value we need to query object schema and iterate to find API value. Schema.DescribeFieldResult ...
Jaydeep Godara's user avatar
2 votes
2 answers
237 views

How to get the local object from a string in the managed package?

Our managed package has a namespace, say DemoApp, and a custom object named Form__c, the client's org also has a custom object Form__c According to the doc here: https://developer.salesforce.com/docs/...
Adam's user avatar
  • 459
0 votes
2 answers
1k views

How to Describe a SOQL Query

I am trying to write a utility to export a SOQL query to a POCO / POJO, and it works so far using the describe API on the SObjects. Is there a way to directly describe a specific SOQL query, including ...
Kyle J V's user avatar
  • 287
2 votes
0 answers
914 views

Best way to get the custom object type of a WhatId in a Flow

I'm working on a Task record-triggered flow and I need to evaluate the WhatId to see what the object type is. As I see it's not directly available. I'm wondering if what the best solution would be. I ...
Andrew L.'s user avatar
  • 837
2 votes
1 answer
247 views

Is it possible to get valuetypes of fields of a JSON object without using getGlobalDescribe() [duplicate]

I have the following piece of code to get the valuetype. Is it possible to do this with getSObjectType() instead of getGlobalDescribe() since this is a lot slower. Apex Map<String, Object> ...
Thomas's user avatar
  • 2,294
2 votes
1 answer
664 views

Describing the default Person Account record type using Apex

Using the RecordTypeInfo class allows us to get information about the Record Types and which one is set to default for the running user's profile. The (Person) Account is however a special case, ...
Folkert's user avatar
  • 2,672
0 votes
2 answers
862 views

Is an Address and Location SObjects or a Compound Fields?

I am trying to build a picklist which would display all the available SObject, and global describe returns me some strange SObject Address, when I try to instantiate dynamically this SObject, it fails ...
Patlatus's user avatar
  • 15.8k
0 votes
1 answer
51 views

try/catch vs describe calls inside for loop which has more performance impact?

We have a generic method which is called in a for loop for each record where we try to get a value of a field using Sobject get method. Before getting the field we have to make sure that field ...
Isha's user avatar
  • 163
2 votes
2 answers
563 views

How to retrieve Apex class (Not sObject) fields in apex dynamically?

I have task to test fields from custom class and i need to find all the fields are exist and return expected data. ex: Class Person{ String Name {get;set;} integer Age {get;set;} } //in ...
jks's user avatar
  • 158
1 vote
1 answer
47 views

Why Does Describe Information Always Return True for Updateable on Read-Only Fields?

I cloned the Administrator profile, removed the Edit permission for some fields on Opportunity Product, and applied the cloned profile to a non-admin user. I logged in as this user and went to a ...
YXY's user avatar
  • 130
1 vote
1 answer
110 views

Apex: How to figure out actual sobject that has been queried having only AggregateResult type

To narrow down the problem - we have a method like this: private static Object doSomeProcessing(List<AggregateResult> records) { ... // need to add additional logic here based on sobject ...
wesaw's user avatar
  • 2,980
3 votes
1 answer
79 views

Describe vs EntityDefinition for non-active features

Is this supposedly a bug? Have anyone came across this already? Asking because I was under the impression both should have the same behaviour. I tried to use a query against EntityDefinition instead ...
Jeferson Chaves's user avatar
0 votes
2 answers
876 views

Get all Sobject Label and API name in Ascending order according to the label

Is there any standerd methord to get all Sobjects name in Ascending order. I am able to get all objects label and API name by the following code. I need to put all the names into map in ascending ...
Ajith Kumar's user avatar
4 votes
1 answer
616 views

How do I tell if a custom metadata type field is a Field Definition?

I have the following code: public static void getFields(){ SObject obj = (SObject) Type.forName('Health_Cloud_Integration_Settings__mdt').newInstance(); DescribeSObjectResult describe = obj....
MetadataBaiter's user avatar
0 votes
2 answers
10k views

How to List all Custom Objects from Salesforce API?

I'm currently working to use the Salesforce REST API to get a list of all Salesforce Custom SObjects without including System or Standard Objects (like how the /services/data/vXX.X/sobjects/ does). ...
Will Osbourne's user avatar
3 votes
0 answers
69 views

Are individual object describe calls expensive enough to justify static cache? [duplicate]

Supposing we have a method that executes logic dynamically depending on the SObject type like the following one: public class TestDescriber { public static void callMeManyTimes(SObject record) { ...
jonathanwiesel's user avatar
0 votes
2 answers
264 views

SOQL statements cannot query more than 20 different child types error

I have the following piece of code public static void fetchRelatedRecords(String primaryRecordString){ SObject primaryRecord = (SObject)JSON.deserialize(primaryRecordString, SObject.class); ...
Madhurima's user avatar
  • 1,235
1 vote
1 answer
5k views

How to get child relationship name from Parent Object in Apex

In the following piece of code, i am trying to do a dynamic parent - child query public static void fetchRelatedRecords(SObject primaryRecord){ String recordId = (String)primaryRecord.get('Id');...
Madhurima's user avatar
  • 1,235
2 votes
1 answer
4k views

How do I get the RecordTypeId for a Person Account using Describe method?

I can get them by running the following query SELECT Name, SobjectType, IsPersonType FROM RecordType WHERE SobjectType='Account' AND IsPersonType=True or by doing public Id ...
Irene's user avatar
  • 1,703
1 vote
0 answers
74 views

getDescribe Failing on Individual Object Id in Tests (Data Protection and Privacy)

My tests of methods using dynamic SOQL queries stopped working after enabling Data Protection and Privacy. I receive the following Exception: FATAL_ERROR caused by: System.SObjectException: Field ...
Cleverlemming's user avatar
0 votes
1 answer
144 views

List of fields and whether or not they are Encrypted And tracked in Field history

I have been wracking my brain trying to figure out a way to get a list of fields and include whether they are encrypted, and whether they are marked for field history tracking. I seem to be able to ...
TestMcTesterson's user avatar
1 vote
2 answers
809 views

Is there a way to check if an object is the actual object visible in the objects tab in an org?

We have need to run through every object in an org to determine which ones have certain fields our app needs. We ONLY care about the actual objects (case, campaign, contract, custom objects, etc...). ...
Tyler Dahle's user avatar
  • 2,609
0 votes
1 answer
2k views

Most efficient way to get all child records for a specific record

I have an account record that I want to get every single possible child record - ideally as a list of IDs. Currently I am doing the following: for(Opportunity opp : [SELECT ID From Opportunity ...
scousins's user avatar
3 votes
1 answer
99 views

Is Contact othergeocodeaccuracy a legitimate field?

Many of our Continuous Integration builds just failed with hundreds of this error: System.QueryException: No such column 'othergeocodeaccuracy' on entity 'Contact'. Our code does describe calls ...
Keith C's user avatar
  • 134k
5 votes
1 answer
443 views

Any way to get Child Relationships without being bound by user permissions?

Question User object-level permissions limit the results of DescribeSObjectResult.getChildRelationships(). Are there any workarounds? I have submitted an Idea about this (https://success.salesforce....
Charles Koppelman's user avatar
0 votes
2 answers
334 views

Prevent other fields which is part of managed package

Retrieve all fields for particular sObject it is working fine but then i insall app which is part of manage package also retrieving fields of manage package. how to prevent to retrieve. objects/...
cloudZigZag's user avatar
  • 1,356
1 vote
1 answer
1k views

How to access Owner field using getDescribe().fields.getMap()

I have a below code to access owner field from sObject. Map <String, Schema.SObjectType > sObjects = Schema.getGlobalDescribe(); Schema.SObjectType targetType = sObjects.get('...
JURY's user avatar
  • 173
0 votes
0 answers
222 views

Objects not in getGlobalDescribe() (Scorecard, ScorecardMetric, ScorecardAssociation)

i am confused why the objects Scorecard, ScorecardMetric, ScorecardAssociation arn't listed in the getGlobalDescribe() Map. Documentation (https://developer.salesforce.com/docs/atlas.en-us.apexcode....
Felix's user avatar
  • 11
1 vote
2 answers
2k views

Determine if User is System Administrator without a query

has anyone found a way to check if the current user is a sysadmin without consuming a query? Seems like something that should be easily determined using Describe but haven't seen a solution to this. ...
wbrproductions's user avatar
11 votes
2 answers
867 views

Apex method to find out if SObject is a setup object

Regular SObjects and Setup Objects can't be mixed in DML otherwise you'll experience a Mixed Dml Exception. How can Apex code find out if a given SObjectType is such a setup object? System.assert(...
Robert Sösemann's user avatar
10 votes
1 answer
526 views

Drawbacks of using SObjectField.toString() over SObjectField.getDescribe().getName()

I often do '' + field where field is an SObjectField to get the field's API name. I like that much more than the clunky verbose field.getDescribe().getName(). So is there a reason I should not do it ...
Robert Sösemann's user avatar
1 vote
2 answers
296 views

Is there a way to determine if an object supports list view?

Is there a way to determine if an object supports list view? I've developed a VF page which shows a list of Objects and based on Object selection it shows list views of that selected object. For some ...
Chirag Mehta's user avatar
  • 1,281
1 vote
2 answers
115 views

Type safe access to SObject ChildRelationships describe

To access an SObjectField you can use Account.Field_Name__c. This has the advantage of being checked at compile time. Is there an equivalent syntax for ChildRelationship? Account.Contacts does not ...
NSjonas's user avatar
  • 10k
1 vote
1 answer
325 views

sobjects describe label displaying a different label

I'm using the toolkit for .net and am making a soobjects/{type}/describe request to get the fields for a given entity. See code for "DescribeAsync" in https://github.com/developerforce/Force.com-...
Mark Nadig's user avatar
1 vote
1 answer
990 views

Using Describe to return single field result

I wrote a generic method that takes an object, field and value as string parameters and returns the picklist label. I was wondering if there is a more efficient way to write the method instead of ...
Dman100's user avatar
  • 2,415
5 votes
1 answer
196 views

Impact of Shield Platform Encryption on describe calls?

Some old code was obtaining information about record types by querying the RecordType object. But now that the RecordTypeInfo describe API includes the record type developer name, we have changed the ...
Keith C's user avatar
  • 134k
0 votes
1 answer
35 views

How to get Two articles in One list using salesforce query

Hi every one I have a two articles: Offer__kav and Offer_order__kav. How to Query This Two Objects Related All Fields. For Ex: I tried : List<List<SObject>> search_results = [FIND 'SFDC'...
ali's user avatar
  • 13