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
16
votes
1answer
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. ...
1
vote
1answer
1k views

How to give an object's all fields visibility to all profiles

I have an object which has around 100 fields now need to give all fields visibility to all the profiles. One possible solution is to edit each field and give its visibility to all profile but if i ...
5
votes
3answers
6k views

Serialize Class to JSON with correct sObject API field names

I want to use the standard Force.com REST API to create a case remotely from another Salesforce instance in my instance. I want to populate two fields on creation: "Subject" and "txt_UserId__c". ...
6
votes
4answers
865 views

Determine sobject Type From Id Using SOAP API

I'm using C# and would like to determine the type of an sObject based on it's id. I would like to pass an id to my app and have it return a list of accounts related to it. I need to identify the ...
6
votes
1answer
1k views

Is there a Class.forName() equivalent for Apex

I'm looking to dynamically instantiate a class by its name. How can I do that in Apex? I thought about a factory method with a series of if-else statements, but am not satisfied with that as it isn't ...
8
votes
3answers
2k views

Is it possible to pass sObjects to the REST api

I only found solutions that pass objects or primitiv datatypes to the REST API, so do I need to pass these to rebuild my sObject or is it possible to pass it as an sObject JSON? I tried to, but I can'...
2
votes
1answer
130 views

Adding related list item to layout on install

I have an application that has a custom related list. At the moment, the related list needs to be added manually after the app has been installed through the page layout. Is it possible to add this ...
3
votes
1answer
6k views

Get values of custom fields of a custom object using DescribeResult

I have a custom object Custom__c and I am accessing its fields by using Public Custom__c custom1 {get;set;} Map<String, Schema.SObjectField> map = Schema.SObjectType.Custom1__c.fields.getMap();...
4
votes
1answer
310 views

Can't find ForecastingItem sObject in DescribeGlobalResult

We recently upgraded to salesforce API v27 (from 21). Documentation says that there are some new objects added between v21 and v27. ForecastingItem object is one such object. But when I get all the ...
2
votes
3answers
384 views

SOQL to get attachment(s) on PollPost

Just curious what SOQL I would use to get the Poll Items (attachments) on a FeetItem with the Type PollPost? So if we had a poll saying, "Whats your favourite color?" How would I get the line item ...
4
votes
3answers
16k 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 ...
3
votes
2answers
1k views

SOQL query help using specific combinations of two variables that also appear in another object

I have two different custom objects. Each object is related to both an Account and a Campaign via a lookup field. So both objects have the following fields: sObject.Account__c sObject.Campaign__c So ...
7
votes
1answer
950 views

Track Activities value for a custom object

I have a custom object. I enable Track Activities for this custom object and then I create a managed beta. If this managed beta is installed in a new org, the track activities will be enabled for ...
2
votes
1answer
6k views

Sending dynamic checkbox values from a VisualForce

I created a VisualForce wherein I display values from a map (returned from a custom controller with a SOQL request) using an apex:repeat. Each time I display this VisualForce page, the amount of ...
4
votes
3answers
7k 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?
6
votes
2answers
889 views

Testing code that depends on an SObject

I have a page which displays an entity that belongs to another package. In order not have a hard dependency to this package, I build a wrapper object and make this wrapper object accessible to the ...
6
votes
2answers
2k views

Quick way to delete/truncate all records in an org

I have a development org with a quite complex object structure and a ton of demo data. To refactor thr structure I want to get rid of all this data. My first thought was to use the new "Truncate" ...
2
votes
1answer
547 views

Can standard field “Name” for sObject be longer than 80 Characters?

Question is the title of this question...or do I have to use a custom field?
0
votes
1answer
2k views

How to query CodeCoverage from SOQL? [duplicate]

Possible Duplicate: How can I get code coverage programatically through Apex? How to query CodeCoverage of a class by writing an SOQL inside Apexclass? Is there an sobject which stores the ...
7
votes
3answers
4k 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?
0
votes
1answer
8k views

Relation between lead, Account, oppurtunity and contact

Please explain me the relation between these 4 sobjects. How lead, Account, Opportunity and Contact are related to each other.
1
vote
1answer
645 views

Naming convention

What is the best naming convention developers around have been using for defining Record names to maintain uniqueness that can also be searched easily : foreg: opportunity name : Opportunity ...
2
votes
3answers
5k views

System.QueryException: List has no rows for assignment to SObject

following apex code public String getLastUpdatedAt() { String timeStr; DatadoctorStatus__c last = [SELECT LastUpdated__c FROM DatadoctorStatus__c ORDER BY LastUpdated__c DESC LIMIT 1]; if (last == ...
2
votes
0answers
450 views

Invalid sObject type 'DataDotComEntitySetting'

We have Data.com, namespace jigsaw_clean, v 2.16.2 installed and I am encountering an sObject type error when I try to do a simple DML statement in a unit test script. The test method instantiates a ...
10
votes
4answers
3k views

Required Field on VisualForce Triggers “SObject row does not allow errors” message?

I must be missing something here..I have a visualforce page, that enables a user to create a Campaign - I have a pageblock/section with the Campaign Fields, including name, and Name is marked required....
7
votes
6answers
5k views

Can you limit the visibility of fields based on record ownership?

I know with permission sets and sharing rules you can limit visibility and how users can interact with entire records. Is there any way to limit visibility of fields? We are looking to make the basic ...
7
votes
2answers
1k views

Why does JSON serialization give different results when the Sobject is created from a SOQL query and when the Sobject is instantiated normally?

I am getting some very odd behavior from the JSON serializer where if the Sobject was originally instantiated from a SOQL query it will exclude any fields that were not part of my query from the ...
4
votes
1answer
666 views

In Memory Init of sObject with Id for Update

Let's say I have a Contact, we'll say from Trigger.new. If I want to update its parent account, I skip a query by initializing it in memory like this. Account acct = new Account(Id = contactInstance....
37
votes
1answer
14k views

Infering sObject Type from Id or collection of Id's

If I have an instance of an Id variable that has been populated with a value, is there way to infer the sObject type of that Id using a describe call. So if I did: Set<id> parentIds = new ...
5
votes
1answer
4k views

Find out the default record type of any Object in Apex

I've to find out the default record type of an Object so that I can use in Apex to insert/update records. Found out that it is at the user level(user profile based). Is there any other way which I ...
0
votes
2answers
2k views

Making Approval Comment Mandatory

Is it possible to make approval comments mandatory? There is one discussed here. http://christopheralunlewis.blogspot.in/2012/09/making-rejection-comments-mandatory-in.html I've a two step approval ...
3
votes
1answer
148 views

Insert sObject share for task that the user doesn't own

As a regular user (not system administrator) is it possible to create a share for a object that I'm not the owner of in APEX? Or will the DML statement throw an error?
22
votes
2answers
1k views

Does 'default value' do anything if the object is created through Apex?

I created a currency field on OpportunityLineItem that has a default value set to 0.00. In my test method I create a record and insert it. I then query it back out and try to assert that the field is ...
4
votes
3answers
4k views

Reports for two lookup objects that relate to a parent

I got a request this week from our customer service group that stumped me. We use person-account, case, and a custom object called order (that person bought something). Both case and order have ...
3
votes
2answers
2k views

Setting Type of Event or Task via SOAP/REST API

I am looking at Object Reference for Event and Task sObjects and seeing that both have Type and Subject. I wanted to use Type as one of meeting, call, email and Subject as event/task title. But, if I ...
3
votes
3answers
2k views

SOAP API Request with body larger than 16 Kilobytes results in Timeout Exception

I stumbled upon an interesting limitation, it seems that SOAP API endpoint handles requests larger than 16Kb differently --- whenever body is larger than that request just times out. We're using '...