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.
618
questions
3
votes
2
answers
3k
views
Benefits of using sObject.clone versus creating a new record
Hello I am curious whats the use case of the clone method. Also when its beneficial. Example here I create a lead once then clone it 200 times.
list<lead> leadlist = new list<lead>();
...
2
votes
1
answer
151
views
Update sObjects in .sfdx/typings
I have a VSCode SFDX Project that we use to develop LWCs, and we recently changed some object names in the Org and now I can't upload anything to our Org.
I found that there is a command to refresh ...
0
votes
0
answers
96
views
How to store a collection type (set, map, list) on a object?
I have a visual-force page which displays an Apex form with some dynamic number of input text fields that I would like to save on the Opportunity object. Is the easiest way to serialize them as JSON ...
1
vote
1
answer
847
views
How to enable read permissions for organization sobject?
I'm trying to use the salesforce standard rest api to access the organization sobject so I can read the name of an organization I'm working with. I make a soql query "SELECT Id,Name FROM Organization ...
3
votes
1
answer
1k
views
Rendering Visual Force page as PDF via the REST api
The documentation suggests that a Visual Force page can easily be rendered with apex: https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_output_pdf_render_in_apex.htm
// ...
1
vote
1
answer
104
views
unable to read sobject when object has id null
I am actually getting the error "Unable to read sobjet", when sending an object to my server even if I specify the sobjectType as follow :
sendforSave : function(component) {
var habitatInfo = ...
-1
votes
1
answer
26
views
How salesforce compares on sObject with another
We know that "Set" is a collection of unique records. If I am creating a set of SObjects, on what basis Salesforce identifies Uniqueness of the entries in the Set?
1
vote
2
answers
158
views
How do i iterate over a list with 3 different object types in lightning component?
I am building a lighting component which needs to iterate over a list with three different object types but I have run into a problem because I cannot write an aura if expression which checks the ...
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('...
14
votes
2
answers
14k
views
Generic SObject update pattern
Question
I know that it is possible to update a generic of List<SObject>, But what is the best approach to generate that list without knowing the SObjectType, only the ids ?
Sample:
List<...
-4
votes
3
answers
566
views
how to create dynamic query [closed]
List<Opportunity> opps = [
SELECT Id
,Name
,Amount
,CloseDate
,Stagename
,Near_to_Close_Date__c
...
0
votes
2
answers
902
views
Convert List<String> into List<Schema.SObjectField>
I have a below code
public PageReference SyncCandidatewithMirror(map<Id, cxsrec__cxsCandidate__c> NewMap,Map<Id, List<String>> fieldChangedMapChanged, List<...
0
votes
1
answer
66
views
How does joining two custom objects into one custom object through master-detail relationship work
I've been working on a test method but I've had a problem creating the setup of it.
public static List<Job_Posting__c> createPostings(){
List<Job_Posting__c> testPostings = new ...
1
vote
1
answer
173
views
How are action overrides handled for managed package upgrades?
I want to override a custom object's "New" action with a Visualforce page in my managed package. (This is the mechanism where the platform's default New or Edit or View etc. actions can be routed to ...
2
votes
2
answers
3k
views
Delete an SObject by knowing only Id
Is it possible to delete an SObject by knowing only Id?
Here is what I found:
Id del = '003S00000099999'; // whatever ID you are deleting
Contact ct = new Contact(Id = del);
delete ct;
So, is it ...
0
votes
1
answer
691
views
Adding new Fields to Sobject or changing field values dynamically
I have a Sobject Record which is already instantiated and fields are added along with values.
sObject sObj = Schema.getGlobalDescribe().get(Name of Object).newSObject() ;
sobj.put(...
0
votes
1
answer
910
views
Trying to create a new User, cannot create new user because of profileID
I am trying to create a new user inside of Salesforce using nforce. However, every time I create the user I get the error: FIELD_INTEGRITY_EXCEPTION stating Profile ID: id value of incorrect type: ...
0
votes
2
answers
2k
views
List all standard and custom fields for a given object (standard/custom object)
is there a way to list all the fields both standard and custom for a given object.
tooling api - customfield gives only list of custom fields but not the standard fields.
58
votes
1
answer
108k
views
Using sObject.get() to fetch a field value from a related parent object
I have a contact in a generic sObject in apex and while I'm able to easily get detail field values using
sObject.get('MyContactField__c')
I'm not able to get fields off the related parent object, ...
0
votes
2
answers
61
views
Lightning components - Initiating attribute with controller with multiples sObjects
I'm Working on Lightning components
I would like to add some values in my App, by its controller (aura:handler)
I'm trying with this :
component.set("v.objetsCamping", tabObjets);
But it doesn't ...
3
votes
1
answer
93
views
Combining similar code with different objects
I have 4 very similar code blocks in a trigger that deal with synchronizing record type changes from Opportunity to its children. The only difference between them is that they do work on different ...
1
vote
2
answers
973
views
Query regarding generic sObject and specific sObject
I was going through the 'Apex and Database basics' module in Trailhead and came across the following sentence in one of the units:
This example shows how the generic sObject variable can be assigned ...
9
votes
2
answers
2k
views
Strange Behavior with null sObject in Apex Class
I've observed some strange behavior with null sObjects which are members of an Apex class. Consider the following anonymous block:
public class test
{
public Contact tc;
public test(){}
}
...
0
votes
3
answers
196
views
Salesforce database : how does it work
I don't really know how to ask that question, in Salesforce we have objects, and if I want to update some object (for example) I use an soql query like
Account a = [select name from Account where id ...
0
votes
2
answers
986
views
RelatedTo field of Email message
RelatedTo field has multiple lookups to various object for my instance its heavily populated as follows:
Lookup(Contract,Campaign,Organization,Donation,Product,Asset,Case,Solution,Asset ...
0
votes
3
answers
105
views
Adding a Custom Field to all sObjects in the same edit?
I want to add a custom field to all my salesforce objects, at the same time,
a high level idea, is that they are control ID for an external source, but is there a way to add the fields to all objects ...
34
votes
1
answer
29k
views
Error: MIXED_DML_OPERATION on setup and non-setup objects
In my test class i have the creation of a dummy custom setting and a dummy lead:
Group g1 = new Group(Name='group name', type='Queue');
insert g1;
QueuesObject q1 = new ...
3
votes
0
answers
870
views
Sobject Get on Relationship fields : Invalid Field [duplicate]
I am working on a module where I have to create complex nested JSON dynamically based upon configs stored in custom metadata, The metadata contains Object name, fields names as text fields.
Now the ...
1
vote
1
answer
2k
views
Salesforce datetime field adding user timezone to the field
I have two datetime field in custom object, to which I am inserting values programatically from my apex class.
Fields from my custom object
My apex code used to insert/update records in the custom ...
2
votes
3
answers
6k
views
Retrieve object type via id using apex
I am new to Salesforce and trying to figure out the object type using the ID which I see in the URL on the Salesforce page.
I found many places describing how to do this with the Apex language, such ...
15
votes
1
answer
8k
views
Finding a Custom Object Id (01I...) to get the Setup page URL
I'm trying to find a way to get the "Id" for a custom object's setup page. So I'm NOT trying get a record Id. I'm working on a custom visualforce page and I'm setting up a link so that when the user ...
2
votes
1
answer
2k
views
Iterate over a few objects in a single loop?
I have a few objects that have the same fields (referring to Article Types) such as: FAQ__kav, Tutorial__kav, Video__Kav
Is it possible to add all of these records to a single list (I guess of type ...
0
votes
2
answers
218
views
Wrong IsNillable flag for Name field while querying FieldDefinition object
I am trying to retrieve the list of fields which are mandatory and running below query:
SELECT id, DeveloperName,EntityDefinitionId,IsNillable,Label FROM FieldDefinition where EntityDefinitionId= '...
0
votes
1
answer
130
views
Illegal assignment from List<or_guestsJSON> to or_guestsJSON
I an trying to write a testclass for a JSON object but het the error:
Illegal assignment from List to or_guestsJSON. How do I annotate the list in my testclass?
Class
public class or_guestsJSON ...
0
votes
2
answers
385
views
How to get the value from an object
I have an object which gives me the following when I debug :-
{name=Baltmore, uid=abcdef00-acft-126a-8cfw-efihfcirffw}
I would like to get the uid as a string. I tried agency.get('uid') but this ...
0
votes
1
answer
220
views
Create a Case with SOAP in PHP - Failing to map across Contact ID
I have created a connection via SOAP with PHP and I am trying to create a new Case when the user submits the form. I have the SFDC Contact ID of the user and I am trying to insert the Contact Id into ...
3
votes
1
answer
756
views
Aura Attribute of Type Object is Supported in Flows?
I am working on a Flow Screen and trying to assign a value to a lightning component attribute from a variable in the flow. The flow screen allows me to select the lightning component but it doesn't ...
1
vote
1
answer
191
views
How can I create records that pair to their parents dynamically?
I have batch class which inserts records into a number of different objects from the same logic using dynamic code. My records need to be associated to the correct parent records (i.e. Contacts to ...
0
votes
2
answers
70
views
Figure out which fields are required from Setup
Is it possible to figure out which fields are required from Setup?
I mean, I can of course go and look at each field settings and check the required checkbox, but very often I need to look at a few ...
3
votes
1
answer
68
views
SOSL on Permission Sets error when no ID is included
I am testing SOSL's on Permission Sets for something I am building and noticed that if I don't include the ID in the fields to request, the search fails:
An unexpected error occurred. Please ...
15
votes
3
answers
4k
views
How to send wrapped generic SObjects from Lightning to Apex
I have a lightning component with an apex controller that wraps generic records in an inner class.
When I send the wrapped records to apex and receive them as generic SObjects, I get this error ...
0
votes
2
answers
6k
views
How do I create a Sobject instance in JavaScript, on a Lightning Component controller, to pass to the Apex controller?
I have a lightning component from which I pass some values to a controller. I want to pass the object as a variable and update a field on this object.
How do I make the object variable? See my ...
0
votes
1
answer
24
views
Downfall of creating apex object using existing Id from SOQL with related object
I want to ask if there is any potential downfall of creating object in apex with Id that I would get from SOQL on diffrent object?
Pseudo code
SELECT Id, Foo__r.Id, Foo__r.Name from Bar__c
Foo__c ...
1
vote
0
answers
74
views
Tell a component to update its' content when a related record is added on the same record page
I have a Lightning Component in a Record Page on Order object, and whenever I add a product (new OrderItem is created) in the order, I'd like to somehow notify the component to update its' content.
...
0
votes
1
answer
493
views
Injecting Contact Created in SF on Child BU Journey Builder
I created a Journey in Child BU that uses SF Object Contacts as entry and trigger whenever a Contact Is created. So i tested creating contact and see if it is being accepted under the Child BU JB, but ...
0
votes
1
answer
1k
views
How to find `Selected Quick Actions` in Search layout List View
EDIT:
Adding a listview screen shot:
As you can see I do not have a listview named List View
If I go to quickActions endpoint I can find my quick actions (in my case `New Child Case')
But my ...
1
vote
2
answers
4k
views
Query name/Help Text/Description of custom fields in a custom object
I want to Query Name/Help Text/Description of custom fields in a custom object. Something like:
SELECT Name, HelpText, Description FROM sboject WHERE object = XXX
3
votes
1
answer
2k
views
How to use inner class / wrapper class as scope in Apex Batch
I already successfully collecting the list of data from callout another system as json body to the inner class to accomodate custom information:
Here is the apex class of the inner class:
public ...
4
votes
3
answers
2k
views
How to export object with their field-level securities and/or how to set all fields securities levels at once?
My team and I are working on a project together using Lightning components and a lightning app. Each one of us have our own Salesforce developer edition orgs. We use "Force CLI" to fetch the code to ...
2
votes
1
answer
2k
views
Using ObjectType global variable in lightning component
In the doc (https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_dynamic_vf_globals_objecttype.htm) it is said that the SobjectType global variable can be used in lightning ...