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.
615
questions
4
votes
1
answer
2k
views
Insert multiple SObject data in Salesforce as single transaction using REST calls
I am using following soObject call to insert new row in the Account table at Salesforce server :
curl -H "Authorization:OAuth use your session_id" -H "Content-Type: application/json" -d @Test.json "...
3
votes
1
answer
75
views
problem with sObject as parameter
I get the below error when I try saving CLASS 1 below. The second class that is the problem is also below. I obviously don't understand objects or apex well, so any help would be greatly appreciated.
...
2
votes
1
answer
44
views
getting layout of user using API
I am using this link to get the layout.
I am using a REST client,
Here is my request
https://ap1.salesforce.com/services/data/v28.0/sobjects/Global/describe/layouts/
Authorization: Bearer ...
8
votes
2
answers
6k
views
SObject constructor signature?
when instantiating an SObject type, I can set initial field values by passing them to the constructor. For example like this:
Account a = new Account(name = 'Acme', billingcity = 'San Francisco');
I'...
16
votes
1
answer
26k
views
Get SObject by Id
I have an Id and I want to know if it's possible to get the SObject with this unique ID ?
Something like :
SObject object = getSObjectById(myId);
I didn't find a method allowing that !
23
votes
2
answers
2k
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 ...
3
votes
1
answer
698
views
How can I get the opportunity owner label?
Simple question. How can I get the opportunity owner label name?
I tried the following code but it isn't working. An error occurred.
{!$ObjectType.Opportunity.fields.Owner.label}
I cannot use the ...
8
votes
2
answers
7k
views
Set Contains method is not working correctly after overriding equals() and hashcode() methods
I have created one class name like Test and have overriden its equals() and hashcode() methods and then created its 2 objects like below -
Test obj1 = new Test ();
Test obj2 = new Test ();
and now ...
0
votes
1
answer
2k
views
how to get owner name, record type name, Account name on trigger of Contact
I'm writing custom history tracking code, tracking needs to be done for more than 50 fields
All working fine, but instead of record type name , I'm getting record type id, and the same is happening ...
1
vote
1
answer
11k
views
Get one value from a list as an integer
I am having trouble updating a variable because of various errors. I cannot get the value from my list to work with the value of my other list.
trigger StudentNoUpdate on Class_Size__c (before insert,...
2
votes
1
answer
641
views
How can I dynamically transverse dynamically SOQL'd SObject fields in Apex?
So, in my other post, I figured out for myself how to dynamically transverse SObject fields in Apex.
But within the context of my work, there is a problem with the solution as it currently stands:
...
4
votes
1
answer
658
views
How can I dynamically transverse SObject fields in Apex?
I am trying to dynamically create a CSV file from Case records. The fields for the CSV file will be determined in custom settings (and therefore shouldn't be hardcoded). Moreover, the fields may ...
5
votes
1
answer
12k
views
apex:inputField can only be used with sObjects
I am trying to create a custom visualforce page that saves new opportunity contact roles to an opportunity. I am having trouble creating the first step of listing out all contacts that relate to that ...
3
votes
1
answer
310
views
Issues with a Query within the main Query using DatabaseDotcom Ruby gem
I'm having a issue with pulling the data out of what would be a array of object data in my SFDC query. Im using the databasedotcom gem.
Code
def self.data_query
#@client is defined at a class ...
1
vote
1
answer
81
views
What is the best way to add to an apex collection of String
Is there a more efficient way to Select data into a String collection e.g. Set<String> than using a for loop
Set<String> allTopicSet = new Set<String>();
for (Topic t: [select ...
2
votes
2
answers
1k
views
Can I set sobject id in a method?
Apex code developers guide says
"The ID of an sObject is a read-only value and can never be modified explicitly in Apex unless it is cleared during a clone operation, or is assigned with a ...
2
votes
0
answers
309
views
sObject insert execution not synchronous
I have a custom object and a controller action that creates a new record of this type. The action then returns a page where the list of objects are displayed.
save() {
...
insert myObject;
...
1
vote
2
answers
3k
views
Change the field of another object before insert
I have two Objects : Activities and Services, with each field.
I create a Trigger (Before Insert) on the Activity, in the Trigger I would like to modify the fields of a record of the Service object.
...
3
votes
1
answer
266
views
Can a Web Tab's url be get and set from Apex or the REST Api?
I would like to modify the url of my Web Tab for each SF organization that my managed package is installed on. Is there a way to get and set the url of a Web Tab from Apex or the REST Api? Is there a ...
1
vote
1
answer
8k
views
Calling Apex class from trigger - issues with passing a list
I am trying to call my Apex class from a trigger:
trigger newCrossSellAccounts on Account (before insert) {
crossSellModule.insertAfterAccount2(trigger.new);
}
On the class I have:
public void ...
2
votes
0
answers
33
views
Problem with reports after install
I've recently created a package and I'm facing an unusual problem. Basically, in my development org, this works:
String report = String.valueOf([SELECT Id
FROM ...
1
vote
2
answers
89
views
Customize User SObject field labels
How can I customize the custom field labels of the User SObject?
For other SObjects you can use the "Rename Tabs and Labels" setup entry. However, because the User SObject has no Tab, this isn't ...
2
votes
3
answers
896
views
Can't set property value for SObject using setType function
I'll get my excuses in early: I'm a developer with some experience of working with APIs, but this is my first encounter with Salesforce.
We've been given a spec to interface with a customer's ...
1
vote
3
answers
569
views
System.NullPointerException: Attempt to de-reference a null object for duraion
I am new to Apex coding. Can someone please help me to resolve the issue. I am trying to automatically display the duration when from and todate is selected. For that i have developed a code in the ...
1
vote
3
answers
3k
views
Where can I get more information about Owner?
There were one time that I was trying to get the Owner name from Case. I searched online and knew that I can use the following query to achieve:
Select Id, AccountId, Owner.Name, Owner.Email, Owner....
12
votes
1
answer
211
views
Archaeology: what *was* object type 004?
So we've all eyeballed the various standard object Key Prefixes at some point and noted:
001 is Account
003 is Contact
etc
I've always wondered: what was 004? What about 002?
2
votes
1
answer
6k
views
Create one table of multiple object types
I am looking to create a table, for instance pageBlockTable, with entries from multiple object types. The various objects share some fields, and also have unique fields. The table should display a set ...
7
votes
1
answer
1k
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 ...
8
votes
1
answer
777
views
Access modifiers on sObject properties
Consider the following two classes. The first has simply a private Test__c and its constructor fills it in. The second class uses the first one and creates a Test__c object before instantiating the B ...
7
votes
1
answer
174
views
Why doesn't SFDC allow MIXED_DML_OPERATIONs anymore?
Okay, I know very well by now that SFDC does not want and often does not allow us simply insert and/or update Setup and/or "Non-setup" sObjects in the same context anymore, something I used to do with ...
3
votes
1
answer
977
views
Fetching SObject Id from changes in Lookup fields using History tracking
I have set history tracking for my Custom Object and set a Lookup field for my referenced Object.
CustomObjectX_c[Field1,Field2,Account_c]
Here Account__c is a lookup field to the Salesforce ...
3
votes
1
answer
2k
views
Is it possible to write a method that accepts both SObjects and Apex Class Instances?
I have an Apex method that takes a list of SObjects, a source field name, and a destination fieldname. For each SObject in the list, it looks at the source field, does some work, and populates the ...
7
votes
1
answer
1k
views
Importing string typed data into an sobject
I have a relatively large Map<String, String> which is basically a key/value map of sobject field names and their values. Obviously, all the values are strings, but fields are not (there are ...
6
votes
1
answer
2k
views
Update Record via @RestResource class, return related SObject
I'm trying to create a REST API class that will allow the following:
POST Object ID
Update(ObjId); ('Touching' the record, fires triggers on Salesforce)
Find SObjects on a custom object that have ...
5
votes
1
answer
4k
views
How to retrieve a value from a parent field with SOQL via partner API in java
I have a parent-child relationship with timesheets relating to users.
I am trying to retrieve an Employment ID field from the parent record with SOQL and this is my query, where the UserID is a field ...
2
votes
1
answer
2k
views
Cannot set value on checkbox using sObject via Partner API using Java
I get an error when I try to set a checkbox with the Salesforce Partner API.
I have tried different combinations, but I get the error that an Object is required.
Confirmed__c is a checkbox and this ...
14
votes
1
answer
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....
4
votes
2
answers
2k
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 ...
3
votes
1
answer
6k
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
1
answer
1k
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
0
answers
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
1
answer
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
1
answer
877
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;
...
3
votes
2
answers
236
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++)
{
...
2
votes
1
answer
2k
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
3
answers
7k
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".
...
2
votes
0
answers
470
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 ...
6
votes
1
answer
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
3
answers
4k
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
1
answer
135
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 ...