Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [sobjectfield]

A token representing a custom or standard SObject field in Apex. Provides a clearly typed way to reference a field. The token's getDescribe method must be called to get detailed information.

0
votes
1answer
32 views

How to create an efficient helper method that return an object given a map of field-values?

One of the most tedious task when writing test class is to create test data with no particular requisites. The idea is to have a helper method that is able to return the object given a map of field-...
0
votes
1answer
29 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(...
2
votes
1answer
41 views

How can I correctly convert List<SObjectField> into a list of comma-separated field names to build a SOQL String?

I've created a generic selector class as follows: public inherited sharing class DAO_SObjectSelector { public List<SObject> selectFor(Query query) { return Database.query(query.toString()); ...
3
votes
1answer
283 views

Get List<Schema.SObjectField> from field set

I know that the name of the object is Obje and the name of the field set for this object if Fieldse. Now I would like to get a List<Schema.SObjectField> (i.e. fields from the field set). Right ...
2
votes
1answer
905 views

Convert Schema.SObjectfield to string

I have a List of Schema.SObjectfield and I want to convert it to String. I am getting below error. System.JSONException: Apex Type unsupported in JSON: Schema.SObjectField Here is my approach. ...
0
votes
1answer
257 views

Is Scientific notation allowed in double

Apex document clearly says, Scientific notation (e) for Doubles is not supported. But again, Salesforce Object Reference guide says, Values can be stored in scientific notation if the number is large ...
8
votes
3answers
160 views

Any way to check a field's updateablity ignoring profiles?

The DescribeFieldResult.isUpdateable method incorporates the "Edit Access" setting of the Field level Security for a field i.e. it considers the field settings in the current profile. Is there a way ...
0
votes
2answers
46 views

How can I find the exact field names and calculations, from a reporting field's friendly name?

I'm diving into a new system, and I see reports with a "Amount (converted)" field, from the Opportunity table. I'd like to look at this in SOQL, but there's no field which obviously matches; there ...
1
vote
2answers
139 views

Null pointer exception in SchemaMap

I am trying to find whether a given field resides in a particular Sobject. I am using the code When I try to run this code, I am getting null pointer exception in line no. 3. I guess schemaMap ...
0
votes
2answers
293 views

How do I find the field type of parent/grandparent fields etc?

I have in my SQL relationship fields. The have written this query under a custom object. ex: SELECT name,Contact__r.Account.CreatedBy.Name FROM Four_Level_Check__c LIMIT 5 My need is to find the ...
0
votes
1answer
3k views

How can I get the list of all fields(API name,Label,type) of any sObject?

I'm trying to build a Dynamic list(table) of records by selecting the Sobject and its fields.So I need to get all the fields with its API name,label,type.But I can't get the label and type.(Tried ...
1
vote
1answer
718 views

Salesforce API for getting all case comments from Case ID

I am new to Salesforce and using its API for getting comments. I am getting resource id like of Case, Feed or Idea I need to get its CaseComment, FeedComment, and IdeaComment. I am requesting Resource ...
0
votes
2answers
84 views

How to refer parent account while creating an account

I need to display the account name with a slash between account name and the parent account name , if the parent account field is filled. I tried to do that using SObjectType methods. But couldn't do ...
1
vote
1answer
1k views

is it possible only get writable fields from schema.sobjectfield

I have this code: Map<String, Schema.SObjectField> fields = Schema.getGlobalDescribe().get(Account).getDescribe().fields.getMap(); It gets all the fields of account but I need only ...
4
votes
1answer
442 views

setType & setField methods not available in SObject - Apex SOAP API

I'm trying to create an object of SObject class and then setting its type to Lead and setting one of the fields for Email. Eventually, I want to pass this object in findDuplicates() method. But the ...
1
vote
1answer
33 views

Trying to resolve the security scanner issue creates problem while installing the managed package?

The following class inserts Data in a custom object(SAPConfiguration__c),when a user enters data in a Visualforce page. In order to rectify the Security Scanner issue(Query: FLS Create) I have added ...
2
votes
2answers
728 views

Where is SobjectType.newSObject useful

I was going through a document at the SObjectType class where there was a method named - newSObject(recordTypeId, loadDefaults). I see that using this method one can create a new Sobject with default ...
2
votes
2answers
270 views

Sobject put set value of managed field in case of same field api name as unmanaged field

We are developing a managed package that contains a custom object and a REST API to do CRUD operation on that object. We are not using standard salesforce REST API for valid business reasons. In this ...
1
vote
0answers
301 views

How to size database columns for storing Salesforce fields; length or bytelength?

All fields in Salesforce have two lengths; a unicode character length and bytes length; our org uses UTF-8. We're sizing tables/columns in Oracle to accomodate our data from the cloud, my question is ...
0
votes
1answer
410 views

From Parent ID, dynamically derive child's lookup field name/token

I'm trying to save a new record dynamically, but I'm having a problem with a lookup field. For instance, I'm able to get the parent object with the id. Id relatedID = '<someId>'; SObjectType ...
8
votes
1answer
544 views

“System.SObjectException: Contact.AccountId does not belong to SObject type Contact” error often in Summer '16

We are seeing a test failure in a couple of our Continuous Integration builds (that deploy the same code) with the error: System.SObjectException: Contact.AccountId does not belong to SObject ...
0
votes
2answers
126 views

Find Latest CreatedDate from a list of sObjects

I have a sObject List AttachList Boolean retVal = false; DateTime AttachCreatedDate = ''; ID attachId = ''; for(AttachDetails__c attachDetail : AttachList) { ...
7
votes
1answer
644 views

DMLException.getDmlFields Fails When Inserting List of SObjects?

When a DML operation on a list of records of a concrete object type, e.g. Account fails, calling getDmlFields on the thrown DMLException returns the fields that caused the failure, as described in the ...
1
vote
1answer
61 views

Why is get.sobject('Id') method appending a 3-char string? [duplicate]

I am creating a custom DML Log in our Salesforce sandbox, and I created a Class & method that fires based on an Apex Trigger Here's the class: public class Util { public static void ...
1
vote
2answers
408 views

Unable to retieve dynamic sObject field value

Trying to retrieve value of field from any given query on sobject. But when i have to traverse across multiple objects to fetch the value, I am not getting expected result. Ex: to get value of owner....
2
votes
1answer
922 views

Dynamic Schema getDescribe

I have two variables: public String selectedObject {get; set;} //selectlist public String selectedField {get; set;} //selectlist public String selectedDataType {get; set;} //text They are the ...
1
vote
1answer
1k views

VisualForce Email Template Error: Invalid field for SObject

I am trying to save a visualforce email template that has both plain text and html elements-- I just tried saving a plain text version to confirm the error is not being caused by an HTML nesting/...
11
votes
2answers
655 views

Case-Insensitive Maps?

How is it that describes seem to return case-insensitive maps? For instance, if I create a new custom setting, the following succeeds: Map<String, SObjectField> fields1 = SObjectType....
5
votes
2answers
643 views

Utility Method Returning Different Type (Set instead of List)

Previously I had posted this question awhile back: Utility Methods flexible enough for all sObject Types Now I want to expand my method a bit to return a Set<Object> instead of a List<Object&...
6
votes
2answers
3k views

Address field: Set Address via Apex

I'd like to create a lead via apex and set it's address. I've read that Address is a compound field and that it is totally read only unless via SOAP/REST API. Looking at the docs, I could only find ...
3
votes
1answer
60 views

Can I find the field that will be updated from a WorkflowRule

So I have two workflow rules that fire when an Opportunity is created/updated. These two workflows set the same variable to either true/false depending on which criteria is met. I'm looking at ...
13
votes
4answers
6k views

Utility Methods flexible enough for all sObject Types

QUESTION I am trying to create a few utility methods that can work with any sObject that gets passed to it and return dynamic data-types. Unfortunately I'm starting to wonder, is this even possible? ...
3
votes
1answer
45 views

Are SObjectField tokens safe in cross-managed package calls?

We have some code and SObjects and fields in a managed package that works when executed by other calls in that managed package as your would expect. The code looks like this. private SObjectField ...
2
votes
2answers
2k views

Boolean Field v. Yes/No Picklist

Consider two fields with the following types: checkbox/boolean picklist with "yes" and "no" as valid values along with validation that forces one of the two values to be picked, effectively making it ...
1
vote
2answers
644 views

Lookup Field Object

I have to get the object name of the lookup field in any object. I am using: sobjectType objectType=Schema.getGlobalDescribe().get('SA_S3_File__c'). then, to get the lookup field name, i am using "...
4
votes
1answer
216 views

How to detect if a custom field is present using only a Visualforce expression?

I have a field (defined by a 3rd party package) that I need to include in some forms in my package if the field is present on the Contact object (i.e. if the 3rd party package is installed). I'm ...
2
votes
1answer
875 views

Google Apps Script returns null for a cell value

The values in a cell return null if they are of type number, date, etc. I get the field names and values from Salesforce object firstly. I change them and update them. If the fields are text fields in ...
7
votes
2answers
446 views

Finding the SObjectType from the SObjectField

As part of the implementation of an API, I would like to be able to find the SObjectType from the SObjectField: public class MyClass { // Fields are from various SObjects public void myMethod(...