Questions tagged [schema]
Schema is a tag used to describe questions related to the dynamic processing of the system schema through the various describe methods.
216
questions
0
votes
1
answer
24
views
How to change the filterable property in a schema
I was working on an error in one of my queries and found filterable property in schema, and determined that filterable was set to false (using workbench as the aforementioned question answers).
How do ...
0
votes
1
answer
90
views
Schema.sObjectType.(...).isUpdateable() method is returning true but should return false
In short, I'm trying to follow the PMD Source Code Analyzer Project, and I realized that before making an update I must validate whether the user has permission to change the field (ApexCRUDViolation)....
0
votes
1
answer
76
views
Issue getting object API name from relationship field using Schema
In my project we are using fflib_QueryFactory to build queries and also order fields. Example is given below:
fflib_QueryFactory qf = new fflib_QueryFactory(Account.SObjectType)
....
0
votes
2
answers
431
views
How to query managed package objects
I'm trying to retrieve record values of a managed package custom object (call it abc__custom_object__c, where 'abc' is the package namespace, as an example). Trying to run the following SOQL query ...
-2
votes
1
answer
117
views
Export several objects picklist details into CSV file using apex
Context
We need to export picklist label and API values for several objects, in a csv file using apex.
Several posts exist on this subject but the objective is to export picklist values for several ...
0
votes
1
answer
653
views
Efficient way to get field API name using field label
I have an requirement where I need to get the field api name using field label. For example, If I have field called Spouse_Phone__c(label = Spouse Phone), In apex I want to fetch the api name for that ...
1
vote
1
answer
328
views
After Enabling "Set Audit Fields upon Record Creation" Permission check for is createddate Creatable still returning false
I have set Enable "Set Audit Fields upon Record Creation" and "Update Records with Inactive Owners User Permissions" permission checked true in userinterface. After that i am ...
3
votes
1
answer
83
views
getDescribe in standard Activity object returns a Null Pointer
I have the following statement for trying to getdescribe for the standard activity object
Schema.SObjectType s = Schema.getGlobalDescribe().get('Activity') ;
Schema.DescribeSObjectResult r = s....
0
votes
0
answers
26
views
Profile Names and PermissionSet Names are not shown in second Picklist in Lightning Web Component?
HTML :-
<template>
<lightning-card title="Custom Picklist on Profile and Permission Set" icon-name="custom:custom63">
<lightning-layout multiple-rows>...
0
votes
1
answer
204
views
common.apex.runtime.impl.ApexFieldToken
We have using SmartFactory class from long time. But, recently we are facing issues while running smartfactory unit class. Smart Factory Git hub repo. When I try to see the logs I've found out this. I ...
1
vote
1
answer
770
views
Schema.getGlobalDescribe().get(objectType); doesn't work with custom objects
I have a method that returns a map of all the fields where the field's API name is the key and the object Schema.SObjectField is the value.
private static Map<String, Schema.SObjectField> ...
0
votes
1
answer
213
views
Get list of fields for History object via APEX
I need to dynamically retrieve the list of fields for history objects, whether it be Asset or Opportunity etc. I normally use the following code to retrieve these fields for standard and custom ...
0
votes
1
answer
175
views
Some History object still show "MISSING LABEL" message when use Schema to get label or get label plural
I try get some objects label or label plural by using Schema method, but for some of History objects I will get follow message in label and label plural:
"__ MISSING LABEL __ PropertyFile - val ...
1
vote
1
answer
941
views
How to retrieve reference field's value dynamically
sObject record = Database.query(query); // current record values
Map<String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
Schema.SObjectType objSchema = schemaMap.get(objName); ...
2
votes
3
answers
5k
views
Getting error for user fields in LWC component when using schema?
I am trying to retrive field information for user fields using following code.
But except for the Name field of User, it is throwing error for every other field.
Any idea why its not letting me access ...
0
votes
1
answer
391
views
Finding fields for standard data types
I've been trying to complete a challenge on trailhead (link here)
The text says
"Create an Apex trigger that sets an account’s Shipping Postal Code to match the Billing Postal Code if the Match ...
1
vote
0
answers
256
views
How to get the Field Label from the Columns retrieved from the List view Metadata?
I have written an Metadata API from https://github.com/financialforcedev/apex-mdapi to get the List view details.
Below is my code:
MetadataService.MetadataPort service = MetadataServiceExamples....
0
votes
0
answers
72
views
Can't access RecordTypeId of Account object
I'm not sure why I can't access the RecordTypeId or any sort of recordtype field of the Account object.
//error at select
Account[] accs = [SELECT RecordTypeID, TYPE FROM Account];
Schema....
0
votes
1
answer
421
views
need to capture lastmodifiedBy user and date of LWC in salesforce
I have requirement where i need to fetch modified lwcComponent with the user who modified it programmatically.
Is there any soql query we can use or by apex schema we can get it.Audit trail does not ...
4
votes
1
answer
209
views
Can a Number field in a managed package be changed to a Currency field of the same precision and scale?
Such a change can be made using sfdx force:source:push, presumably because there isn't any risk of data loss (mentioned in Notes on Changing Custom Field Types).
Can this change be packaged and orgs ...
0
votes
1
answer
2k
views
(Schema.SObjectType) || Method does not exist or incorrect signature: void
I'm trying to list the Record Types that a user has access to. Unfortunately, this cannot be done through SOQL Query (IIRC) and the only choice I have would be to either use Schema.SObjectType (Apex) ...
1
vote
2
answers
1k
views
Check field is updatable
I have object and field name, but don't understand how to check if that field isUpdatable. It gives me the error:
Variable does not exist: fields
SObjectType objectType = Schema.getGlobalDescribe()....
6
votes
0
answers
274
views
APEX Schema ChildRelationships: why have some relationships their relationshipName = null?
There is some strangeness in the some standard Childrelationships. Most Relationships are as expected, but let us take Account and Quote as an example:
On Quote we have a standard lookup field Quote....
1
vote
1
answer
4k
views
Get parent record fields using getRecord uiRecordApi in lwc
I'm trying to get parent record value using uiRecordApi in my lwc component.
But I'm getting error.
Cannot read property 'value' of undefined
import OPPORTUNITY_ISCLOSED from '@salesforce/schema/...
0
votes
1
answer
852
views
Retrieve the type of field using Schema classes
I am trying to create a generic class to retrieve the type of a field for any sObject.
I am struggling with the following part of the code:
String[] fields = ['Id','Name'];
for(sObject o : ...
0
votes
0
answers
420
views
How to access the value of Schema.sObjectField?
I am new to apex coding, Can anyone please help me here?
I am working on after update trigger and I am using the below code to know what fields were updated. I got a code on StackExchange that serves ...
0
votes
1
answer
130
views
Will a query from Organization ever return more than one row?
I'm curious. Is it possible for the query below to return more than one row? Do Divisions somehow create multiple Organization rows within an org?
SELECT Id, Division
FROM Organization
2
votes
2
answers
1k
views
Dynamically get object info
I see so many examples like below; however, I want to be able to pass a string that holds 'Account' or custom object name for example. The examples I see on SF are hard coding Account.
The reason I ...
0
votes
1
answer
544
views
How to get rid of Master Record Type on custom Record Type Lookup?
I created custom lookup with all possible Record Types to choose by user. I simply retreive List with Record Type Infos from Schema globalDescribe and pass it from apex controller to aura component. ...
1
vote
1
answer
239
views
DescribeSObjectResult cannot find field
Let's say we have a simple code
Schema.DescribeSObjectResult res = Schema.SObjectType.Account;
system.debug(Schema.SObjectType.Account.fields.Name.isAccessible());
system.debug(res.fields.Name....
0
votes
0
answers
582
views
How to query formula field and related object field values by Schema class
I have this below method when I am passing fields dynamically to get passed object records.
relatedObjectName ==> Planner__c
recId ==> RecordId of Planner__c
fields = AccountPlanner__r.Email (...
0
votes
1
answer
1k
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....
-1
votes
1
answer
722
views
Get user's last assignment (or re-assignment) to profile or permission set datetime
Is it possible? Let's say we have a lot of users, profiles and permsets. There is need to get last datetime when user was assigned to particular permset or profile using SOQL. Which fields could help?
1
vote
0
answers
25
views
Customer 360 Audiences Web and Mobile Application JSON Schema
I have gone through the following documentation regarding creating an Event Type JSON schema for the mobile or web application connector in Customer 360 Audiences:
https://help.salesforce.com/...
1
vote
0
answers
487
views
How do I get the API specification or schema for a custom REST endpoint?
How do I get the API specification or schema for a custom REST endpoint?
I'm looking for something basic, similar to the examples provided within this documentation for OpenAPI Specification. The end ...
0
votes
1
answer
5k
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(...
1
vote
1
answer
281
views
Schema.describeTabs() returns empty DescribeTabSetResult
I have a piece of Apex code that does Schema.describeTabs()
When i run this as System Administrator, i get the tabs back just fine.
Some other users running this code get empty List<Schema....
0
votes
1
answer
153
views
Mysterious "Long" DisplayType
I'm trying to figure out what "Long" DisplayType is (it's listed in Schema.DisplayType Enum values). I've checked standard fields for a couple of SF standard objects but didn't find any ...
0
votes
1
answer
716
views
filterable property in schema
how to get fields which are queryable(can be used in query) or filterable(property from schema) from an object like account without using soql queries.
Any suggestions?
how to achieve this.
1
vote
1
answer
765
views
get count of all the fields containing data in a specific object
public static Map<String, decimal> getFieldsCount(String objectName){
Map<string,Schema.SObjectField> get_F_name=Schema.getGlobalDescribe().get(objectName).getDescribe()....
2
votes
1
answer
647
views
Get list of all required fields of sObject dynamically in Salesforce
I want to build a list of fields marked required at the schema level.
I have tried below snippet, It works great but fails for the field with default values.
Map<String, Schema.SObjectType> m = ...
0
votes
1
answer
1k
views
get custom setting fields names in apex class
Requirement-I need to create a map of custom setting in apex class with fields and value like.
"Name":"test",
"cal__c":"tesq",
"industry__c":"...
1
vote
0
answers
119
views
No such field ActivityOriginType even though returned through field map
We have an all fields query that gets the field map from an object's describe in Apex. It then loops over the map and assembles a query.
In one clients org, the field map is spitting out ...
1
vote
1
answer
2k
views
LWC UI Object Info API get only particular Field Label
The lightning/uiObjectInfoApi module includes wire adapters to get object metadata and picklist values.
getObjectInfo -> Can we fetch only metadata of particular field instead of whole object ...
3
votes
1
answer
12k
views
LWC: Unable to fetch custom field through the schema
I have a LWC component in which I am trying to pull the metadata from the schema so I can use updateRecord. I've done this before for a different custom object(and it worked) but this time I am ...
1
vote
1
answer
1k
views
How to pass the parameter to which an object needs to be cast to
I have the following piece of code where I wish to cast a certain object to a specific SObjectType.
public static void someMethod(Object obj, Schema.DescribeSObjectResult objectType){
...
...
0
votes
1
answer
47
views
Capture States on Account where the Account is doing business
I am trying to establish relationship between Accounts of different Recordtypes
Account: CustomerID = BYR1 , RecordType = Buyer, Located IN = OH
Account: L1, RecordType = Lender , Doing Business In ...
1
vote
0
answers
66
views
How to use DuplicateRecordSet field: SobjectType
According to the documentation, DuplicateRecordSet there is a field SobjectType, however, after running the following code in Execute Anonymous, it doesn't appear that this field exists...
Map<...
-1
votes
1
answer
189
views
writing a program for Transferring ownership owner to owner for all objects
I'm writing a program for transferring ownership dynamically. But It has to work for all objects.
Public Class TransferOwnership{
@AuraEnabled
public static string tranferRecordOwnership(String obj,...
0
votes
1
answer
924
views
How to use a SOQL query for Sobjects like Passing Sobject as Variable inside the quey
I'm trying to write a SOQL query, But this query have to work for all object in one query. I want to use same query but I want to change object name dynamically
public class Test {
public static ...