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
11
votes
2answers
9k 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<...
14
votes
1answer
4k views

Proper method to get an Sobject instance from an Id

What is the "proper" way of getting an object from an Id? The method I use at the moment is SOQL, and that feels wrong..... Example: Account account = [SELECT Id FROM Account WHERE Id=:inserted....
3
votes
3answers
15k views

Invalid conversion from runtime type LIST<ANY> to MAP<String,ANY>

I'm trying to make a webcall to pull data from an external webservice. After that call I would like to insert my data that comes in the form of JSON into my custom object called Company. However I am ...
33
votes
1answer
6k views

Generic Apex Trigger

So I was kind of throwing round the idea of making a generic apex trigger that is callable by multiple objects. Say you have the following sObjects: Account Sales__c Sales_Contacts__c And I wanted ...
2
votes
2answers
1k views

Is there an object browser for the built-in or custom objects?

Being a noob, it's difficult to get my head wrapped around the vastness of the salesforce expanse. In Visual Studio and other environments like the standard Java Eclipse, they typically have an ...
2
votes
1answer
4k views

“New Action” vs “New Button or Link” for a custom object

A custom object's setup page has a section "Buttons, Links, and Actions". I've created buttons and links in the past, but do not remember the "action" option being there. Can anyone explain what "...
0
votes
1answer
990 views

Accessing Sobject using javascript

I want to access a Sobject field using javascript in a visual force page and based on its value perform an action. How can I access a Sobject field using javascript?
1
vote
0answers
2k views

Trying to determine fields I want to set dynamically rather than hardcode - very close / not possible

I am messing around with the dynamic nature of Salesforce. I want to clone Opportunity into a custom object. It's a very easy requirement in itself. What I am trying to do is make if completely ...
1
vote
1answer
4k views

Getting an initial term of field expression must be a concrete SObject error:

I'm getting the following error: Save error: Initial term of field expression must be a concrete SObject: LIST Force.com save problem Here are the snippets of code in question: List <...
5
votes
1answer
735 views

Error when I populate lookup with external id using .put method

You can populate lookup fields using an object with an external id field populated like so: Custom_Object__c o = new Custom_Object__c(Account__r=new Account(External_ID__c='123')); insert o; ...
28
votes
1answer
19k 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
2answers
185 views

Why (referenceTos[0] != null) check is being performed in following code?

I was going through a salesforce.com developer documentation code // Iterate through the list of describe sObject results for (int i=0;i < describeSObjectResults.length; i++) { ...
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. ...
2
votes
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
912 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
3k 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
315 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
388 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
17k 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
976 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
8k 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
945 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
550 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
2answers
668 views

Naming convention [duplicate]

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
453 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
704 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 ...
6
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
149 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?
23
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 '...