Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [sobjecttype]

A token representing a custom or standard SObject type in Apex. Akin to Class in Java, but the token's getDescribe method must be called to get detailed information.

3
votes
1answer
160 views

Trigger: Find out the name of the object the trigger is firing for?

Is it possible for the trigger to see the name of the object it's firing for? Say can I make the OpportunityTrigger be aware that the object name it's firing for is Opportunity without hardcoding the ...
0
votes
1answer
15 views

Get sObjectType by ExternalID

Same as we can do using sobject ID, do you know if it's possible to get sObjetType of an object using it's externalID ? Something like this is it possible ? Id sobjectId = Id.valueOf(externalId);...
1
vote
1answer
171 views

How can I pass a custom object type as a parameter in a method call?

I am working on a Lightning Component and I am trying to refactor my code. I have four combo boxes set up to query junction objects. The selection for object one determines what fills the list for ...
7
votes
1answer
211 views

How to distinguish between ContentDocument and ContentNote?

There seems to be some unusual stuff going on with SObjectType for the enhanced note ContentNote (ERD) object and the underling ContentDocument (ERD) structure. For example, both these return a ...
0
votes
2answers
220 views

dynamic SObjectType.getDescribe().isAccessible()?

I have a Lightning component with a search bar that uses Apex to search Cases, and another that searches Opportunities. For example: @AuraEnabled public static List<Case> searchCases(String ...
1
vote
1answer
506 views

System.QueryException: sObject type 'OpportunityLineItem' is not supported

We get this script exception (in managed package) emailed from a customer instance. Apex script unhandled trigger exception by user/organization: XXXXX/YYYYY pkg1.ProductOppStockCheck: ...
3
votes
1answer
333 views

Why should I even use the SObject type for the aura:attribute type?

Sometimes I see code using the SObject type as an aura:attribute type and I don't see why! <aura:attribute type="Account" .. It feels like it behaves the same as "Map", it's just a javascript ...
5
votes
1answer
142 views

Apex differentiate between Lookup field to master detail field

Is there a way to differ between regular Lookup field to a MasterDetail field? When calling to getDescribe() on a field both of them holds the type of REFERENCE. EDIT: After further investigation, ...
5
votes
1answer
700 views

Apex differentiate between RichTextArea, LongTextArea and TextArea

When calling getDescribe() on a custom field I get the field data. Although, I need to know when the field is Text Area (Long), Text Area (Rich) or just TextArea. When seeing the result from ...
5
votes
1answer
75 views

Get list of “first-class” Salesforce objects

I'm working on a managed package that will allow users to select an object in their org and create a mapping with an external service. I noticed that Schema.getGlobalDescribe() returns a plethora of ...
1
vote
2answers
126 views

Null pointer exception in SchemaMap

I am trying to find whether a given field resides in a particular Sobject. I am using the code When I try to run this code, I am getting null pointer exception in line no. 3. I guess schemaMap ...
2
votes
1answer
48 views

Null Pointer if sObjectType isn't Case

I have the apex trigger below that is meant to check the WhatId on a new Task if the WhatId belongs to a case. The trigger then populates fields on the related Case for ActivityDate and Task Type. ...
5
votes
4answers
94 views

Is it possible to get the label or describe from an SObjectTypeToken?

In my controller, I have some SObjectType property: public SObjectType myProperty { get; private set; } I want to get the label (or better yet the entire describe) of this object in Visualforce ...
8
votes
2answers
3k views

Get SObjectType from 'ObjectName' without using getGlobalDescribe()?

I'm working on rewriting a utility method that gives record type ids without using SOQL queries. I found two ways to do this: Schema.getGlobalDescribe().get(objName).getDescribe()....
0
votes
0answers
281 views

Get SObjectField with same API Name dynamically across SObjects

I have a unique situation. I have several different SObjects that are using the same field API names and I'm trying to get them dynamically by passing the SObjectType. For instance. This is for a ...
1
vote
2answers
1k views

assign values to a Map<Id,List<SObject>> in an apex trigger

I have below code where I face error as incompatible type. Can someone please help me resolve it? I can't get how to populate it. Apex Code Map<Id,List<Account_Territory_Loader_vod__c>> ...
1
vote
0answers
388 views

Unable to query PermissionSetAssignment object

I have a method in my package's postInstall script that is trying to check to see if the user has access to edit custom settings. In the method, I query the PermissionSetAssignment object. When I run ...
1
vote
1answer
691 views

Create Customize cloning , copying old to new record

UPDATE: AFter I have tried with the @Adrian approach I'm getting the following error now: |EXCEPTION_THROWN|[65]|System.DmlException: Insert failed. First exception on row 0; first error: ...
3
votes
2answers
267 views

How does SObjectType.newSObject() works?

From the documentation > SObjectType Class I see that we can instantiate a new sObject from the SObjectType class Could you tell me how does the code below create a new Account regarding the required ...
4
votes
1answer
419 views

setType & setField methods not available in SObject - Apex SOAP API

I'm trying to create an object of SObject class and then setting its type to Lead and setting one of the fields for Email. Eventually, I want to pass this object in findDuplicates() method. But the ...
1
vote
1answer
3k views

How to get field of an object dynamically

I am trying to build a VF component. One of the feature of the component is the ability to show the fields related to an object dynamically. For example - if my component is used in an VF page like: &...
2
votes
2answers
688 views

Where is SobjectType.newSObject useful

I was going through a document at the SObjectType class where there was a method named - newSObject(recordTypeId, loadDefaults). I see that using this method one can create a new Sobject with default ...
1
vote
1answer
47 views

Insantiate list dynamic one line

So I am able to return the sobject of a list like so: //sobjectlist = list of records passed into fuction. Schema.SObjectType sotype = sobjectList.getsObjectType(); Now this gives me sotype with ...
2
votes
1answer
86 views

Standard SObject which are not exposed by Salesforce

I would like to know if there is Standard SObject for Changeset or Package? I noticed that 033 is prefix for Package and 0A2 is key prefix for Changeset. However, neither of there objects are not ...
0
votes
1answer
392 views

From Parent ID, dynamically derive child's lookup field name/token

I'm trying to save a new record dynamically, but I'm having a problem with a lookup field. For instance, I'm able to get the parent object with the id. Id relatedID = '<someId>'; SObjectType ...
3
votes
2answers
154 views

DescribeFieldResult.getSOAPType() returns type not in enum list

Was working on some generic apex, and wrote a few lines of code to get the SOAPType of a field based on the type and the name. Went off, and worked on some other areas, and wrote something which used ...
2
votes
1answer
196 views

Opportunity.IsPrivate via Apex but not Developer Console?

I'm trying to query all of my Opportunity fields at runtime by using Schema.SObjectType.Opportunity.fields. This seems straightforward, but I am seeing some strange behavior when I put some of my ...
1
vote
2answers
377 views

Unable to retieve dynamic sObject field value

Trying to retrieve value of field from any given query on sobject. But when i have to traverse across multiple objects to fetch the value, I am not getting expected result. Ex: to get value of owner....
2
votes
1answer
798 views

Dynamic Schema getDescribe

I have two variables: public String selectedObject {get; set;} //selectlist public String selectedField {get; set;} //selectlist public String selectedDataType {get; set;} //text They are the ...
15
votes
1answer
15k views

Lightning/Aura components: aura attribute default sobjectType gives error for Standard Objects

sorry for almost duplicate - but I have not enough reputation yet to comment on: Lightning/Aura components: aura attribute default sobjectType gives error in managedpackage I am having the same issue ...
2
votes
1answer
412 views

How to use a Dynamic List Type of SObject getted by ID

I'm trying to do a Dynamic List of a SObject gutted from an ID. My goal is SEND a SObject info via mail. (Opportunity, Case...) From a list of selected records, I send by argument their IDs with ...
5
votes
2answers
620 views

Utility Method Returning Different Type (Set instead of List)

Previously I had posted this question awhile back: Utility Methods flexible enough for all sObject Types Now I want to expand my method a bit to return a Set<Object> instead of a List<Object&...
2
votes
1answer
165 views

CampaignMember.getSobjectType() returning null

Whenever i am calling CampaignMember.getSobjectType() method , getting nullpointer exception. I tried to debug the CampaignMember object but getting null value object as well. Marketing User checkbox ...
4
votes
2answers
6k views

Get Record Type Developer Name without SOQL Query

I want to get Developer Name of record Type without using SOQL query. With the below code, I'm able to get the "Name", but I want the DeveloperName. Let me know. string recordTypeName = Schema....
13
votes
4answers
6k views

Utility Methods flexible enough for all sObject Types

QUESTION I am trying to create a few utility methods that can work with any sObject that gets passed to it and return dynamic data-types. Unfortunately I'm starting to wonder, is this even possible? ...
4
votes
2answers
4k views

How to reset an attribute of type sObject in Lightning for Salesforce1?

I want to reset an attribute of type sObjectType in Lightning/Aura to the default value. I'm unable to reset even if I declare a dummy attribute of same sObjectType attaribute in component and assign ...
11
votes
1answer
202 views

Is this a Salesforce bug? If so, how do I report it?

Running this code snippet Anonymously produces the following error: "System.NullPointerException: Attempt to de-reference a null object" Map<SObjectType,List<Id>> myMap = new Map<...
4
votes
1answer
276 views

Can't seem to use $ObjectType in a component

I found myself using a bit of code to display a searchable history of a given SObject, for a couple of different SObjects so I thought it sensible to create a component, that could be told the SObject ...
1
vote
2answers
634 views

Lookup Field Object

I have to get the object name of the lookup field in any object. I am using: sobjectType objectType=Schema.getGlobalDescribe().get('SA_S3_File__c'). then, to get the lookup field name, i am using "...
4
votes
1answer
215 views

How to detect if a custom field is present using only a Visualforce expression?

I have a field (defined by a 3rd party package) that I need to include in some forms in my package if the field is present on the Contact object (i.e. if the 3rd party package is installed). I'm ...
2
votes
1answer
225 views

Opportunity Name Label Not Showing Correctly

I want to show the Opportunity Name label on VF page using the following code. {!$ObjectType.Opportunity.fields.Name.label} The label is 'Opportunity Name,' but instead of showing 'Opportunity Name'...
1
vote
0answers
395 views

ExactTarget Landing Page form - getting a ExactTarget error message if two non-required fields are empty

I have an ExactTarget Landing page form that create a SF Lead when submitted. If every field is filled out(approx 20 fields) everything passes into SF with no issue. The problem is this - of the non-...
3
votes
1answer
711 views

Dynamic field retrieval from sobject in vf page

Map<String, Schema.SObjectField> M = Schema.SObjectType.Account.fields.getMap(); from this we can retrieve all the fields but of account object but i want retrieve all the fields of any sobject....
7
votes
2answers
433 views

Finding the SObjectType from the SObjectField

As part of the implementation of an API, I would like to be able to find the SObjectType from the SObjectField: public class MyClass { // Fields are from various SObjects public void myMethod(...
2
votes
1answer
94 views

Checking CRUD for Static SobjectType

I am enforcing CRUD permissions for mainly custom objects. Doing it this way Boolean isUpdateable = Schema.sObjectType.Custom_Object__c.isUpdateable(); works, and it seems to avoid a describe call....
27
votes
1answer
8k views

Getting “__r” relationship name from Schema.SObjectType.Fields

Say I have a master-detail relationship between two objects, Schematic__c and Part__c. I can SOQL query the master from the detail: [SELECT Schematic__r.Name FROM Part__c] If I'm building a query ...
1
vote
1answer
70 views

Weird error in listing values from object

Good afternoon, I'm currently having a problem which I don't know absolutely why it is happening. The following is an example: "The value '9/18/2013' is not a valid number Error is in expression '{!...
3
votes
3answers
7k views

How can I do a substring (or string operation in general) on a Schema.SObjectType?

Please ignore any syntax errors I may have made while typing the following up: Schema.SObjectType t = custom__c.sObjectType; // The following succeeds String query = 'select id, name from ' + t + ' ...