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.

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

Variable does not exist: Name compilation Error

I am trying to create a new case once the rating of a Hotel is < 45% Here Hotel__c is the parent object and Customer_Reviews__c is child Object with MDR Even though there is a field called Name i ...
8 votes
3 answers
6k views

Get object sharing setting on Organization-Wide Defaults

Is it possible to know, via apex code, if a certain object is Private, Public Read-Only or Public Read/Write?
3 votes
1 answer
827 views

Possible to get sObjectName in Utility Bar LWC?

I'm creating a LWC that I want to have context from the currently focused tab. I want to have both the recordId and the sObjectName. In fact, I've successfully done this for the recordId based on this ...
0 votes
1 answer
824 views

How to get a list of Field Set names in Apex [duplicate]

I need to create combobox with Field Set names. I know how to get fields for any Field Set, but how to get a list of all Field Set names. Map<String, Schema.FieldSet> canMap = Schema.SObjectType....
0 votes
1 answer
63 views

how to check that custom (or standard) field represents Id

Let's say i want to get Set upon some particular field from recordset public Set<Id> getIdSet(List<SObject> source, String idFieldName) { Set<Id> result = new Set<Id>(); ...
2 votes
3 answers
1k views

Considerations for Map Keys with Trigger.new records in Before Insert Context

I have a scenario where, on insert of Events (Activities), I need to insert records related to the Events, and then tie them back to the Event by populating a custom field on the Event object with the ...
0 votes
2 answers
274 views

How do I automatically fill in an object field knowing the label?

I have a custom object whose fields correspond to abbreviated currency names. Exchange Rate (Custom Object) Fields: USD - label USD__c - API name EUR - label EUR__c - API name I also have a Map that ...
0 votes
1 answer
154 views

how to loop through a list of lists of different objects?

Let's say I have several different lists of objects: typeA[] Alist = [ ... ]; typeB[] Blist = [ ... ]; typeC[] Clist = [ ... ]; And I want to perform the same operation on each list: for (List<...
1 vote
2 answers
1k views

Can I create a list of sobjects in a for loop where the name of the list will be dynamic?

I want to create lists of sobject where sobject types will be input from a custom label or a custom metadata. Can I create a list of sobjects in a for loop where the name of the list will be dynamic? ...
0 votes
1 answer
333 views

Upsert list<SObject> with external id

I want to upsert a list of generic sobject with the external id field. This list of generic sobject contains records from different sobjects, where the sobject type will be unknown and will be ...
1 vote
1 answer
305 views

How do I retrieve Account fields from Event in LWC?

I am generating a table of Events by looping a List of Events and need to populate rows with fields that don't belong to the Event object. More specifically, I need to display Account.Name and Account....
0 votes
1 answer
779 views

Pass object of custom class as parameter to another class

I want to make something like in the code below, but it didnt work. Erorr: Method does not exist or incorrect signature: void method1() from the type SObject. public with sharing class Test1{ ...
1 vote
1 answer
231 views

Convert sObject Time datatype to Time datatype

I want to convert a sObject query response parameter to a Time object which will be displayed in the front-end, and I am a bit confused since there is no method valueof() in the class Time in Apex ...
0 votes
1 answer
636 views

" Error: Could not establish connection. Receiving end does not exist." when trying to create object record

I am trying to insert record in Salesforce after a button click but I receive this error when clicking on the button. Below are provided my JS and apex class for the handling of this operation. No ...
0 votes
1 answer
47 views

Security with Mixed SObjects

I am attempting to find best practices around mixed SObject security. When I am using DML statements I validate either through "with SECURITY_ENFORCED" or through {SObject}.SObjectType....
1 vote
1 answer
111 views

Parsing map to get list of objects based on Key

Is there an easy way to extract the list of objects from a map containing list of objects? For ex, below is an example map that I need to deal with. map<Id, List<Contact>> ...
7 votes
2 answers
4k views

How to accept generic "SObject" in Lightning Web Component for Flows?

I've got a custom built LWC to be used within a screen component in a flow. My component basically renders a collection of SObjects in a distinct way. It can also deal with different types of sObjects....
3 votes
1 answer
7k views

Apex cast List<Object> into List<SObject>

My method returns a list of Object. I wanted to add that to a list of specific SObject. List<Account> accList = new List<Account>(); List<Object> objList = new List<Object>(...
1 vote
3 answers
4k views

How to access lookup object field in apex

So, I'm getting the values of the properties of a custom sObject in my org, in an Apex method. So, this is how it works, basically I receive via parameter a list of strings that are the fields that I ...
0 votes
1 answer
71 views

Not able to insert Parent Record and child record in the same Apex function

I have a function that have 2 List of Objects in parameters (Schedule__c recList and scheduleTable__c recList2). Once I insert the recList, I am looping through the ID and insert child records to it. ...
0 votes
2 answers
172 views

API Question on relationships standard and custom

I have a query (below) but I want to connect to account and query name of the account. I have tried doing account.Name, account__r.Name but I get errors. select Customer_ID__c, Product2Id, ...
0 votes
1 answer
1k views

How do I convert an object to an array?

I have a searchContact method in the helper. I get from the component a list of contacts of type object and try to convert it to an array. I want to be able, after conversion, to refer to each element ...
-1 votes
1 answer
2k views

error: illegal assignment from string to decimal

public class DemoSObject { public void Demomethod(){ SObject obj; obj = new Account(Name = 'Test', phone = '998877'); Account acc = new Account(); acc.Name =...
1 vote
1 answer
2k views

Test class for Object<ANY>

I'm having issues understanding some concepts of Object in apex and trying to write a test class for it. Here is my class global void myLeadsCities(Map<String,Object> inputJsonMap) { Set<...
1 vote
1 answer
341 views

Apex get fields of ANY object

I have a JSON response that returns a List which contains city names. I need to de-duplicate this list. Here is my apex: global void myLeadsCities(Map<String,Object> inputJsonMap) { ...
2 votes
1 answer
827 views

Querying parent-->Child-->Grand child data using salesforce API

Is it possible to query below data structure using salesforce OOTB API(Rest, Soap or Composite)? Lets assume that from account all objects below have 1:M relationship with their parents There can be ...
0 votes
1 answer
617 views

I need an SOQL query to find all the fields in an Object which are referencing to other Objects

I need an SOQL query to find all the fields in an Object which are referencing to other Objects. For Example Account is an sObject which has different fields which refer to the other sObjects. The ...
0 votes
2 answers
743 views

Invocable Sobject Class Returning Number of Results Does Not Match

I have resolved this error in the past when the input is more records than the output (i.e. sending 10 recordIds and returning a single List) however, here I am getting error for autolaunched flow ...
18 votes
2 answers
2k views

Adding an error on a dynamic referenced field

Is there a way to add an error on a dynamically referenced field? Let's take this simple example: opp.get('Name').addError('Invalid name'); This is not working, I'm looking for a similar minded way. ...
0 votes
1 answer
770 views

Iterate over fields from a list

I'm doing a query which returns always 1 record, but I need to iterate over the fields from that list, how can I do that? I was trying to do the way below but this doesn't work, I really need to ...
0 votes
1 answer
78 views

Is possible the same user to have many Team Member Role in the same Account?

How can I do it? P.s: I'm talking about the Sobject AccountTeamMember,
0 votes
1 answer
925 views

System.SObjectException: Illegal assignment from String to Date

I am trying to create an sObject from a Json string but get the error: System.SObjectException: Illegal assignment from String to Date This happens in line: newSobject.put(sObjectFieldsMap.get(key), ...
0 votes
1 answer
511 views

How to find the mandatory fields on Sobjects in RestAPI /describe

I am trying to create an oAuth based app that integrates with salesforce to create the objects from the app. To let users know what all fields that users needs to put in at minimum to create the ...
4 votes
3 answers
6k views

Maps: adding more (related) sObjects than key values using PUTALL method

Here's the scenario: you've loaded a bunch of account IDs as keys into your map. But now, instead of loading account records as the sObject values, you're going to load a related object, such as ...
7 votes
3 answers
21k views

Is it possible to convert an SObject to a Map?

Is it possible to convert an SOBject to a Map in a very few short lines of codes?
0 votes
1 answer
121 views

soap api Owner object type changed after updating WSDL file

We have a vb.net app that use the salesforce soap API. The Enterprise wsdl file originally compiled was dating from 2019, so i updated it to the latest version (API Version 50.0). After Updating the ...
0 votes
1 answer
275 views

Error: Invalid conversion from runtime type List<ANY> to Map<String,ANY>

I am trying to dynamically deserialize a jsonstring (fieldmaplevels wil also be in custom metadata settings) but get the error: Error: Invalid conversion from runtime type List to Map<String,ANY>...
2 votes
1 answer
216 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> ...
0 votes
1 answer
2k views

How to use custom metadata to map generic JSON

I want to create a generic REST API Webservice where the configuration of mapping fields can be done trough custom meta data. How would I set this up?. I want to be able to have an administrator add ...
0 votes
1 answer
2k views

How to get clone source Id for the records coming from database

Account acc0 = new account(name="acme"); Insert acc; Account acc1 = acc0.clone(); insert acc1; System.debug(acc1.getCloneSourceId()); //Producing expected result as the record(Acc1) is in ...
0 votes
1 answer
3k views

Deserialize a JSON to a List<SObject>

I have an Apex class which has a method having an Object type parameter public with sharing class DmlOnSObjectRecords { @AuraEnabled(cacheable=false) public static void dmlOperationOnSObjectRecords(...
6 votes
1 answer
255 views

Why are SObject fields returned to an LWC via @AuraEnabled Apex immutable?

I get this error: TypeError: 'set' on proxy: trap returned falsish for property 'cvcp__ReturnToWorkType__c' when attempting to set a value via JavaScript inside an LWC (Lightning Web Component): sob....
1 vote
1 answer
389 views

Object and SObject what are they and what are they used for [closed]

Google says that SObjects are records from database and nothing more and Object is the class that is at the top of the hierarchy of inheritance and I think it's not enough to answer properly so any ...
0 votes
1 answer
138 views

Is there any way to list all objects that have no parent object?

We are trying to test backup service and delete as much as we can and then restore it. The restoration process works in a way that restores all the child objects when you restore the parent object and ...
3 votes
0 answers
366 views

How to check for/retrieve record-specific error message, e.g. by errors added through sObject.addError or validation rule?

I'm wondering about the documentation for the sObject class (API 50). It clearly states this for hasErrors(): Returns true if an SObject instance has associated errors. The error message can be ...
1 vote
1 answer
1k views

Why does Salesforce automatically put the record Id in the Name field?

When I create an object, it automatically creates a name field. And when I want to create any record for this object from Salesforce create new button, it's okay. Record created. But when I tried to ...
0 votes
1 answer
497 views

System.QueryException: No such column 'CurrencyIsoCode' on entity 'OpportunityContactRole' while using fflib library

I am using fflib library and querying OpportunityContactRole object in trigger. But its throwing below error -> Opportunity_Trigger: execution of BeforeUpdate caused by: System.QueryException: No ...
2 votes
1 answer
256 views

Attempt to de-reference a null object when using alternative to getGlobalDescribe

In the following code String myString = 'Account'; SObjectType sObjType = ((SObject) Type.forName(myString).newInstance()).getSObjectType(); When myString = a object name does not exist i get a ...
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 ...

1 2
3
4 5
13