Want to fetch field from AggregateQuery

I created a Custom Settings and add some records in it. On the basis of that value i write an aggregate query and i want to store that field value in String. // List to fetch all records from Custom settings List<Region_and_Country_Mapping__c> csList = Region_and_Country_Mapping__c.getall().values(); // Created a map to store fields of custom link … Read more

Compare Lead Statecode field to Custom setting Statecode and update a field on Lead with the Region

I have a custom setting name “StateAbbreviationsInfo” which has fields of Statecode__c and Region__C. The requirement is to create a batch class and check for the lead statecode and find the appropriate Region from the custom setting and update it on the Owner_Division_Region__c on lead. global class UpdateRegion implements Database.Batchable<SObject> , Database.Stateful,Schedulable { global Database.QueryLocator … Read more

i am displaying account fields using vf .according to profile fields should be display?

Based on profiles fields should be display like system admin can see all the account fields other profiles will see limited fields how can solve this by using custom settings? Answer please try below code to find fields which are accessible. public static Account getFields(){ string sObjectType = ‘Account’; SObjectType schemaType = Schema.getGlobalDescribe().get(sObjectType); Map<String, SObjectField> … Read more

Retrieving Values from Custom Settings based on 2 field combination and how to retrieve in trigger

I have 4 fields on my custom setting record type name, record type id status send email notification type Now i have to create a new record based on the case status and status combination like Currently problem is when i am creating a case record for record type R1 with open status it is … Read more

bypass trigger on specific object in salesforce

I need to bypass trigger on account sometime. I have created custom setting for that and added triggerObject__c field. In my code bypassTrigger__c bypass = bypassTrigger__c.getInstance(UserInfo.getprofileId()); if(!(bypass.TriggerObject__c.contains(‘account’))) { its throwing Null pointer exception when there is no value in custom setting triggerObject__c .Please suggest Answer You just need to add one null check. bypassTrigger__c bypass … Read more

Triiger Switched On/Off using Custom Metadata

I want to switch of trigger to run or not based on custom metadata. below is the logic i used ,but getting null exception if no User record in metadata. I dont want triger to fire when user and checkbox is ticked in custom metdata. else no need to run trigger Map<string, Trigger_Configuration__mdt> tcmap =new … Read more

SOQL returns data even if bind apex variable is null

We have a public custom settings Batch_Settings__c of type Hierarchy (Organisation level) and it has a date/time field called “Last_Run__c”. The field Last_Run__c is null, but SOQL filtered on this date still returns data. We have this issue both when executing SOQL from Execute Anonymous script or from batch apex. API version: 46 Refer to … Read more

Reading Custom Settings in Lightning Component

I’m creating a page to display to users when we are having periodic maintenance and I want to use custom settings to determine if we’re “in maintenance mode”. I’ve created a Maintenance_Splash_Settings__c object in Salesforce with the following: InMaintenanceMode__c Checkbox for yes/no to “in maintenance mode” MaintenanceSplashStartDate__c Datetime for the start of “in maintenance mode” … Read more

How to add Custom Settings for an AppExchange product programmatically?

I installed an App Exchange product (https://appexchange.salesforce.com/appxListingDetail?listingId=a0N30000004cSsOEAU) and it allows one to set additional roles as part of custom settings. While it can easily be done in the UI by going to Custom Settings for Chatter Delete, I wanted a programmatic way of doing it. Looking at it, I can see that one can easily … Read more