Questions tagged [sobject]
An sObject represents an object, such as an Account or Campaign. An sObject is the base object for all objects in Apex.
608
questions
1
vote
1
answer
132
views
Invalid field Last_Name__c for SObject Scholarship_Award__c
I have an <apex:pageBlockTable> on a VF page that references an sObject list containing records from 2 objects.
As soon as I reference a field that one object doesn't have, it throws: Invalid ...
1
vote
0
answers
525
views
How to detect Permission Set Assignments deletion?
I am currently trying to detect changes in permission set assignments within an arbitrary period; it implies creation and deletion. Where profile and permission set assignment creation is straight ...
5
votes
2
answers
2k
views
Determine if an SObject has an error
Is there a way to calculate if an SObject in a trigger context has had an error added to it (either with addError or through a validation rule)?
I have some trigger processes I don't want to run if ...
0
votes
1
answer
122
views
How to populate values on sobject dynamically for different types?
I have a method that puts an sObject to a queue that is updated once a trigger handler completes processing all records.
public static void enqueueUpdate(Id sObjectId,Map<String,String> keyValue)...
0
votes
1
answer
405
views
Unexpected token: 'Map' for method that returns a Map
Trying to create a method to return a Map of SObjects using any field I want (not Id or I would use the Map constructor that takes a List).
private static Map<String, SObject> getSObjectMap(List&...
0
votes
1
answer
757
views
Variable does not exist when passing SObject as parameter to method
Refactoring code to merge similar operations and getting an error the SObjects I'm passing to this method are variables that do not exist.
private static List<SObject> getSObjectList(SObject ...
0
votes
2
answers
194
views
Retrieving a Salesforce Id from various objects based on key values
Working to bulkify operations in an Apex REST method. I need to lookup Salesforce Ids for multiple fields in a number of objects (custom and built-in). Would calling a method like this from within the ...
1
vote
1
answer
935
views
Get only one formula field calculated value
I have created an object with multiple formula fields. Some formula fields are simple and some are complex.
I want to get calculated values of few formula fields.
To get the value of a formula field, ...
6
votes
1
answer
5k
views
JSON serialize SObject including fields with null values
I've currently got a use case where I would like to JSON serialize an SObject, but include fields with null (blank) values.
According to the documentation (https://developer.salesforce.com/docs/atlas....
0
votes
1
answer
706
views
Iterating sObject to fetch a field value using sObject.get()
I'm not able to get the sObject fields value in For loop.
Getting Loop must iterate over collection: SObject, Can you help me what I am missing here
sObject con = [SELECT Id, firstName, LastName FROM ...
0
votes
1
answer
159
views
Can an SObject link to a file?
Is it currently natively possible to somehow have an SObject that links to a document, attachment, or salesforce file? Sure, you can always have a field that just includes the id of the object as text ...
1
vote
1
answer
426
views
Visualforce page usingbase standard controller
I have the following Visualforce page and controller:
<apex:page standardController="sObject" extensions="ExtensionController">
<div>
{!o.Id}
</div>
<div>...
2
votes
0
answers
847
views
Apex: Copy all populated values from one SObject record to another
I like the way JavaScript lets you easily overlay two objects, retaining the properties of both:
let obj1 = {name: 'Foo', quantity: 3};
let obj2 = {name: 'Bar', description: 'A very nice bar'};
// ...
6
votes
2
answers
3k
views
Instantiate an instance of the SObject type
Is there a way to instantiate an SObject without a SOQL query?
This works :
Type t = Type.forName('Account' );
Account o = (Account) t.newInstance();
But this doesn't :
Type t = Type.forName('...
0
votes
0
answers
323
views
Soql with multiple lookups on same object
I am gathering data from the LiveChatTranscript and there are multiple references to user as lookup fields. How do I pick which property I want to use as my reference to user?
LiveChatTranscript ...
15
votes
2
answers
34k
views
How to convert a string to sObjectType
I have a object A where I am saving the name of the object as Strings and the fields also as String. Eg: If I have object Account, contact and opp objects. I am saving object Account as object Name ...
0
votes
1
answer
39
views
Query on ApexPageInfo object to get created and lastedmodified fields
From salesforce setup i can acle to see all visualforce page name,createdby,createddate,lastmodifieddate and some other fields, I would like to get all the informations by writing query on ...
0
votes
2
answers
437
views
updating reference field using generics sObject
I am trying to perform upsert on opportunity based on external Id. I am building the opportunity objects based on sObject as I am using that function for other objects too.
Now Opportunity object ...
1
vote
1
answer
94
views
Querying Salesforce Campaigns for Newly Added Contacts
I'd like to pull all of the contacts who have recently been added to a campaign using HTTP requests (from an external application). My current method is using a GET request with the URL /sobjects/...
0
votes
2
answers
144
views
Update Field Properties
I want to Update Field properties
Schema.SObjectField field = fieldMap.get(fieldName);
Schema.DescribeFieldResult fieldDescribe = field.getDescribe();
labelMap.put(fieldDescribe.getLabel(),...
0
votes
2
answers
365
views
How can I assign field values from an Object instance dynamically via a predefined wrapping?
I have a Wrapper object that I'm using to store values via calculations and callouts. I want to map these values to a custom object's fields. I also have a custom metadata type where I'm storing the ...
1
vote
1
answer
38
views
How to access SObject returned from web service?
So, I'm calling a web service via JavaScript:
let opportunity = sforce.apex.execute("OpportunityWebService", "cloneOpportunity", {opportunityId: "{!Opportunity.Id}"});
The web service looks like ...
0
votes
1
answer
148
views
Iterating Over the Sobject
Hi I need to to iterate over the sObject as --> Schema.PicklistEntry for this i have created the for loop to iterate over it but getting below error, can anyone help me out for this.
{`List<...
4
votes
2
answers
3k
views
How to use GetSObject to retrieve related data in a null safe manner?
I have a lookup relationship.
If I just do the following query it works fine:
Sobject c = [select field__r.fieldchild__c from custom_obj where Id = :someId];
system.debug('c:' + c);
However with ...
1
vote
1
answer
59
views
Way to provide complex unique restriction
Let's say we have custom object with 2 key fields. How can I provide complex unique index to avoid interactive inserting records with the same values in this fields?
13
votes
1
answer
11k
views
Get all Parent and child objects related to the current object
I have a string which contain the name of a sobject. Now I want to get all the objects related to this object. Also want to get which kind of relationship it have with these object.
1
vote
1
answer
3k
views
How to make the "Activity" tab appear for Customer Community Plus Users?
I have Customer Community Plus users set up and have used contact shares to grant access to the appropriate contacts.
On the contact detail page, however, the "Activity" tab is missing. When I assign ...
1
vote
1
answer
694
views
How to find a sobject used in which apex class
How to find which object is used in which apex class or trigger.Ex I want to find apex classes where account object is used.
0
votes
1
answer
232
views
Building out a multi-dimensional array / list for an update statement
I have a contact list I am looping over and one of the fields in the contact object holds 1 or more contactIDs in a delimited list using a carriage return.
Standard Contact Object:
ContactId: ...
10
votes
2
answers
4k
views
How would I test a trigger on non-writable SurveyResponse object?
I'm using Salesforce Survey for one of the requirements. I would like to write a trigger on SurveyResponse object. I've written the trigger and apply the logic that I need.
Now, I'm trying to write a ...
0
votes
1
answer
571
views
Filter Object Queries Based On Profile Name
So, as the title says, I would like to find all the records of an object that have been created by OR are only visible by a certain profile.
Here is a query I have tried
SELECT Id, Subject, ...
0
votes
0
answers
1k
views
Account Related List Not Showing Up
I am trying to add an account's related list to the Contact page layout.
It will show up for me in Classic and Lightning, but ONLY me, as I am a sys admin.
The other profiles have to go to classic ...
0
votes
1
answer
90
views
Can't save Object from API as new contact in lightning component
I need to save the data filled through API as a new Contact but i receive the follow msg when i press the "save" button:
This page has an error. You might just need to refresh it. Action failed: c:...
1
vote
1
answer
325
views
SObject key of map mutated returns null but serializing returns the value
I am using a SObject as a key and mutating it. When I try to get the map value using the sobject, I get null.
However, when i serialize the value, I can see the old value stored.
Can anyone clarify ...
0
votes
1
answer
317
views
How to make a Json object a subclass
I have a Json Object which I created with the online JSON to apex tool. This works a a separate class how can i make this a subclass. I get the error:
Inner types are not allowed to have inner ...
1
vote
1
answer
406
views
How to loop trough subquery and fill fields in array Json object
I have created a custom object to create a json string. I kan loop trough the list to fill in the first level/parent fields. How do I loop trough the subquery and fill the arrays in the json object.
...
4
votes
1
answer
4k
views
enableChangeDataCapture' not valid in version 38.0
I’m not sure what causes this error message and I’m trying to deploy my app and getting this error message in Jenkins.
All Component Failures:
‘1. objects/Employment__c.object -- Error: Property '...
1
vote
2
answers
650
views
Data Replication Api
I'm building a data replication system using SF Rest API. I see quite a few different ways to reach my goal. Can somebody highlight the differences between some of these possibilities and provide ...
5
votes
1
answer
703
views
Mocking SObjectType to make tests independent of 3rd party managed packages
When unit testing code that interacts with SObjects in other managed packages, being able to mock those SObjects would be helpful so the packages don't have to be installed to run the unit tests. The ...
0
votes
2
answers
208
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);
...
1
vote
1
answer
3k
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');...
1
vote
1
answer
235
views
Convert object as string to json
I have an object which is converted to string in a text field. How can I convert this to a JSON string.
String of object:
Profile:[UID=, crmId=0000o00002XXXXxXXX, email=top@top.com, firstname=null, ...
6
votes
3
answers
39k
views
sObject ' ' type is not supported
Hey everyone I've been seeing this a lot lately and am trying to figure out why this error is thrown when querying the SOAP API directly. I've tried several very basic SOQL queries such as
SELECT ...
8
votes
2
answers
5k
views
Apex JSON.serialize() with null values (RELOADED)
I need to serialize a list of SObject without omission null values. This string I need for a later usage in JavaScript. Structure is crucial, because I need to construct a table out of it. The ...
2
votes
1
answer
155
views
Runtime error when Converting sObject to Account (typecasting)
I'm working on a SOAP integration (.NET C#) to Salesforce and I am facing a problem when I try to get results from Salesforce.
To do this I'm using the next example code of the Salesforce walkthrough:...
0
votes
1
answer
931
views
Invalid conversion from runtime type Map<String,SObject> to Map<String,OrgWideEmailAddress>
I am trying to cast the type Map<String, SObject> to Map<String, EmailTemplate>, my code as follows:
EmailTemplate emailTemplate = [SELECT Id FROM EmailTemplate LIMIT 1].get(0);
SObject ...
1
vote
1
answer
82
views
Explanation of an notation List<name.test> nameList
I have a piece of code as following:
List<name.test> nameList
In List is name a class or object. Why would we use such an annotation?
Or for example:
method(name.test variable)
5
votes
4
answers
2k
views
Can I tell if I queried a field?
I have some code that queries some fields from an object. I then use the schema to loop over all of the fields of an object. Is there a way, while I'm looping through the schema to tell if I had ...
3
votes
1
answer
471
views
Generic List to Map?
I have two functions that convert a list of SObjects to a map.
They do the same thing except that the SObject is different.
How can i combine them to one generic function?
private Map<String, ...
-1
votes
1
answer
286
views
How to get child object name from child relationshipname using Apex? [closed]
Example:
Parent Object Name: Opportunity
Child relationship Name: OpportunityLineItems
Child object Name: OpportunityLineItem