New Batch#100 (10th Nov 2021) - Salesforce Admin + Dev Training (WhatsApp: +91 - 8087988044) :https://t.co/p4F3oeQagK
Subscribe to:
Posts (Atom)
Labels
- 15 digit sfdc id (1)
- 18 digit sfdc id (1)
- 5 minutes (1)
- 50 million records (1)
- A logical segment of your organization's data (1)
- a new record has created in patient object (1)
- Access to object in a test class (1)
- account (1)
- actionfunction (1)
- actionregion (1)
- actionstatus (1)
- actionsupport (1)
- Adding a custom button to page layout in sfdc (1)
- adding additional fields apart from the standard field for the search layouts (1)
- Adding fields to Search Layouts in SFDC (1)
- After deleting a record in master object what will happen for the records of junction object in sfdc (1)
- after triggers (1)
- aggregate query (1)
- Ajax Partial Page Updates in visual force (1)
- annotations (2)
- Annotations in SFDC (1)
- apex (44)
- Apex Classes (2)
- Apex Data Loader (5)
- Apex Data Loader errors (1)
- Apex Programs (3)
- apex:component (1)
- assignTo (1)
- Based on picklist selection (1)
- batch apex (5)
- Batchable Apex (1)
- Before event in trigger (1)
- before triggers (2)
- Bot (IBM Watson) with Salesforce Research (1)
- bulk api (1)
- bulk triggers (1)
- call apex method using javascript (1)
- call by reference and call by value in apex (1)
- Callout from APEX Triggers (1)
- Callout Integration and Apex (1)
- CAMPAIGNS (1)
- CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY (1)
- Cascading Style Sheets (1)
- case (1)
- Cast Iron (2)
- Change Case Owner VF Page (1)
- Changing hyperlink from one color to another color (1)
- Clicking on a commandButton multiple times in a row results in action being fired multiple times (1)
- Cloud Computing Basics (1)
- Collections (3)
- configuration (3)
- Controlling Data with the Force.com Platform (1)
- Controlling Recursive Triggers (1)
- copy field values of one object to another object (1)
- Creating a Many-to-Many Relationship (1)
- CRM (1)
- Cross object update trigger test coverage failure (1)
- css (3)
- CSS for changing the color of a hyper link (1)
- custom login page (1)
- Custom settings (1)
- Data Loader batch size (1)
- Data Loader CLI (1)
- Database .Batchable (1)
- Database.Batchablecontext (1)
- Database.executeBatch (1)
- Database.Stateful (1)
- dataloader (1)
- date (3)
- Date Method to get day of the week (1)
- Define and Insert Queues in Apex Triggers and Test Classes? (1)
- Defining a Manual Sharing Rule (1)
- Delete a record in Aura Datatable (1)
- Difference between 15 digit Id and 18 digit Id in Salesforce (1)
- Difference between abstraction and abstract (1)
- Difference between Interface and Abstract Class (1)
- Difference between Sales Cloud and Service Cloud in sfdc (1)
- Difference between salesforce.com and force.com and developerforce.com (1)
- Difference between SOAP and Restful Webservice (1)
- differentiation (1)
- Disable command buttons on click in visualforce (1)
- Dispaly particular field based on the selection of the particular field (1)
- Display pageblocks based on the picklist selection (1)
- Displaying pop-up summaries on hover in visualforce (1)
- Displaying text in td cell in multiple lines Salesforce (1)
- Div and Span html tags difference (1)
- divisions in sfdc (1)
- dml (1)
- dml statements not required for before events in triggers (1)
- DML Validations (1)
- due to one record entire batch will fail (1)
- Dynamic Apex (1)
- Dynamic Visualforce Naming (1)
- Enhanced List in SFDC (1)
- enterprise wsdl (1)
- Entity deleted (1)
- Error (5)
- exchanging data between heterogenious environment (1)
- execute (1)
- external id (1)
- External Style sheet (1)
- Field sets (1)
- finish methods (1)
- fixed headers datatable (1)
- fixed horizontal and vertical headers in datatable (1)
- for others it should be hide (1)
- Force.com GUI (28)
- Formula (2)
- formula fields (1)
- Gantt Chart (1)
- Generate PDF with apex trigger (1)
- Governor Limits (3)
- Governor Limits for single apex class or entire organization (1)
- Hide/show a pageBlock depending upon the button selection (1)
- hierarchical relationship (1)
- how can I execute 200 records each time in Trigger? (1)
- how can we do it? (1)
- How many ways we can call Apex Classes? (1)
- how to access the encrypted field values (1)
- How to create a site using Apex Code (1)
- How to deactivate security token to be enter? (1)
- How to disable inputfield at particular day? (1)
- How to disable/enable all validation rules for data loading (1)
- how to display corresponding pageblock on VF page (1)
- How to disply custom client-side error messages on VF pge (1)
- How to give the Pagereference for the Save and New ? (1)
- how to lock a record? (1)
- How to publish sites using siteforce? (1)
- How to pull values of records modified 7 days ago? (1)
- how to remove a value from list without using its index (1)
- How to send the failure information in a email for the Batch process? (1)
- How to show visual force error? (1)
- I have 1000 records (1)
- I want to retrieve the records of the custom/standard object of the current user (1)
- if we click any button that country information should only display (1)
- If you click on button a text msg should display on vf page (1)
- Illegal assignment from Account List to Account List (1)
- Inline Style (1)
- Inser failed: inactive user (1)
- Integration between Cast Iron and Microsoft SQL Server 2005 (1)
- Internal Style Sheet: (1)
- Invoking Callouts Using Apex (2)
- Is it possible to refer static resources files in formula fields (1)
- Iterable (1)
- java (1)
- Javascript with Visualforce pages (1)
- Latest Versions in SFDC (1)
- Lead (1)
- lead management (1)
- lightning (1)
- List usage in Apex (1)
- List usage in Salesforce (1)
- list views (1)
- lock (1)
- lookup relationship (1)
- Managing the Heap in Salesforce.com (1)
- Manual Sharing Rule in SFDC (1)
- Manually entered Date value in Apex (1)
- many to many relationship (1)
- Map usage in Apex (1)
- Map usage in salesforce (1)
- Mater detail relationship (1)
- maximum trigger depth exceeded MyObject__c trigger (1)
- monthe (1)
- Moving data from sandbox to production (1)
- Moving data from sandbox to production in sfdc (1)
- Moving pick-list values up and down (reordering) in javaScript (Works only chrome (1)
- Multilevel Master-Detail Relationships (1)
- Multiplication pattern with Apex (1)
- not working for Firefox and IE) (1)
- order of execution of triggers (1)
- Organization Wide Defaults (1)
- Organization Wide Defaults.OWD (1)
- outputpanel (1)
- ownerid (1)
- partner wsdl (1)
- passing dynamic content to system.schedule (1)
- Passing parameters between visualforce pages (1)
- Permission Sets (1)
- Permission Sets in sfdc (1)
- PG) we should use manual sharing (1)
- Pick List in VF (1)
- Pick List in Visual Force (1)
- Process Visualizer in SFDC (1)
- Products (1)
- Querying All Contacts from One Account (1)
- Queues in SFDC (1)
- Radio-buttons simple code (1)
- Random Password Generator (1)
- Record level security (1)
- recursive triggers (1)
- regular expressions (1)
- relationships (1)
- Report should be available only to CEO (1)
- Reports (1)
- rest ful (1)
- restful api (1)
- Retrieving information from child to parent incase of standard objects using SOQL (1)
- retrieving month value from date field in apex class/Trigger (1)
- Review Points in SFDC (1)
- Role hierarchy (1)
- Roll Up Summary Fields using Trigger After events (1)
- rollup summary (2)
- rollup summary programatically (1)
- Rollup Summary using triggers (2)
- runas in Dashboard (1)
- salesforce (1)
- salesforce standard object lead (1)
- salesforce standard products (1)
- salesforce.com (1)
- Schedulable Apex (2)
- Schedulablecontext (1)
- Scheduling Batch Class after 6 minutes whenever a batch finish method executed in salesforce (1)
- Scheduling batch class for every 5 minutes using system.schedule method in salesforce (1)
- schema (1)
- security (3)
- security token (1)
- select list in VF (1)
- select list in Visual Force (1)
- self relationship (1)
- Set usage in Apex (1)
- Set usage in salesforce (1)
- sfdc (1)
- SFDC Governor Limits (2)
- sfdc id (1)
- sfdc products object (1)
- Sharing a Record Using Apex (1)
- Sharing Rules (1)
- Sharing Rules in SFDC (1)
- soap (1)
- soap api (1)
- soql (3)
- SOQL contacts (1)
- Spring '16 Important Features (1)
- srinusfdc (1)
- start (1)
- static variables (1)
- string (1)
- substring (1)
- Summer 15 Release Notes Saelsforce (1)
- system.queryException (1)
- system.schedule (2)
- Testing Apex (1)
- The default workflow user in SFDC (1)
- to create custom change owner functionality for the case record (1)
- To disable other checkboxes in a section if one is selected. (1)
- To display all the fields of sObject using Apex and VF (1)
- To make the Sharing Button visible (1)
- To pass the parameters between the VF pages which have different controllers: (1)
- To perform arithmetic operations (APEX) (1)
- To perform arithmetic operations (VF) (1)
- To return to a same page with empty fields in VF (1)
- To share a particular record to a particular user (1)
- Transient (1)
- Translation Workbench (1)
- trigger (6)
- trigger context variables (1)
- trigger on related object field (1)
- Trigger to update a field in parent record once a task is created (1)
- Triggers (11)
- Try to access info. form sObj for which don't have permissions for user using trigger (1)
- uddi (1)
- Understanding Entity Relationship Diagram (ERD) in SFDC (1)
- Upcoming Posts in SFDC (1)
- Update a record on which we are writing the trigger (1)
- Upsert (1)
- Upserting data from Cast Iron to Salesforce (1)
- Usability: Fields and Page Layouts (1)
- Using 'If' condition in formula field of SFDC (1)
- Using Batch Apex to Change the Account Owners (1)
- Using Batch Apex to Change the Account Owners and call it from trigger (1)
- Using case in formula fields of sfdc (1)
- Using Cross-Object Formula Fields and Hyperlinks in formula of SFDC (1)
- Using Data Loader from the command line (1)
- Using Hierarchy Custom Settings in Salesforce (1)
- Using ISBLANK and ISPICKVAL in Formula fileds of salesforce.com (1)
- Using Regular Expressions in SFDC (1)
- Using the Import Wizard in SFDC (1)
- Validation Rules (1)
- Validation Rules in SFDC (1)
- validations (1)
- Visual Force Basic code (1)
- Visual Force Important Points (1)
- visualforce (28)
- VisulaForceError-System.QueryException: List has no rows for assignment to SObject (1)
- vlookup (1)
- We have three country buttons (1)
- web services (6)
- web services integrations (1)
- Whenever Opportunity stagename fieldset to 'Closed Won' (1)
- Workflow and Trigger differences (1)
- Workflow Rules and Approvals (1)
- Workflows is sfdc (1)
- Wrapper Class (1)
- wsdl (1)
- xml (1)
Constants can be defined using the final keyword, which means that the variable can be assigned at most once, either in the declaration itself, or with a static initializer method if the constant is defined in a class. For example:
ReplyDeletepublic class myCls {
static final Integer PRIVATE_INT_CONST;
static final Integer PRIVATE_INT_CONST2 = 200;
public static Integer calculate() {
return 2 + 7;
}
static {
PRIVATE_INT_CONST = calculate();
}
}
Steps to reduce the code:
ReplyDelete-------------------------
http://developer.force.com/cookbook/category/apex/recent
To eliminate duplicates within sObject use set,
ReplyDeleteTo eliminate duplicates to insert which another object already have two for loops comparision
To put the logic of a trigger in a class and calling the class from the trigger:
ReplyDeletehttp://blog.jeffdouglas.com/2011/08/23/salesforce-trigger-when-rollups-summaries-not-possible/
Use of @IsTest(SeeAllData = True):
ReplyDelete------------------------------------
test methods don’t have access by default to pre-existing data in the organization.
To provide access to that data (From API 24.0 Version) We should use above method.
Test Class for Batch Class:
ReplyDelete----------------------------
@isTest
private class TestBatchClass{
static testMethod void testBatchClass() {
BatchClass bc = new BatchClass();
bc.query = 'Select Id From Account Limit 200';
Test.startTest();
Database.executeBatch(bc, 200);
Test.stopTest();
}
}
Batch Class:
ReplyDeleteUp to five queued or active batch jobs are allowed for Apex
Sample__c s = new Sample__c();
ReplyDeleteinsert s;
insert s;
nothing will insert
To check the current user in permission set:
ReplyDeleteList psusers = [SELECT Id, AssigneeId FROM PermissionSetAssignment WHERE PermissionSet.Name = 'PermissionSetName' AND AssigneeId =:Userinfo.getUserId()];
List psusers =
DeleteNaming Conventions:
ReplyDeletehttp://salesforce.stackexchange.com/questions/890/what-is-a-good-set-of-naming-conventions-to-use-when-developing-on-the-force-com
Creating RollUp Summary Fields:
ReplyDeletehttps://github.com/abhinavguptas/Salesforce-Lookup-Rollup-Summaries
Could not run tests on class [ID]:
ReplyDeletehttp://boards.developerforce.com/t5/Apex-Code-Development/Running-testMethods-Could-not-run-tests-on-class-ID/m-p/681261#M126770
Business Hours Math:
ReplyDeletehttps://github.com/redargyle/BusinessHoursMath
Using Business Hours:
ReplyDeleteDatetime starttime = Datetime.now(); Datetime nexttime = BusinessHours.add(record.id,startTime,1000L);
To get week ends between a date range:
ReplyDeletehttp://www.cloudsuccess.com/blog/apex-function-to-calcuate-weekdays/
Set.containsKey('xyz') allows cases as different won't work for duplicates
ReplyDeleteIt allows xYZ or XYZ or Xyz as different values
String.equalsIgnoreCase(String) to avoid case sensitive
ReplyDeleteprepopulating to populate look up give the name of the parent object to pass the id of the parent object use target object look up field id which should be appended with _lkid.
ReplyDeleteQuery queue name in salesforce:
ReplyDeletehttps://success.salesforce.com/answers?id=90630000000gsFWAAY
Insert Queue Records in SFDC:
ReplyDelete1. insert records into Group object (name, type).
2. Export above inserted records (Id's of above inserted records.)
3.Prepare data with id, type (queue type) and insert into QueueSobject
Reference: http://salesforcedeveloperblog.blogspot.com/2012/05/queue-not-associated-with-sobject-type.html
On before insert no Trigger.newMap since new record id's won't be available and trigger.new will be available
ReplyDeleteSalesforce SOQL Query:
ReplyDeletehttp://simplysfdc.blogspot.in/2013/09/salesforce-soql-query.html
Making Rejection Comments Mandatory:
ReplyDeletehttp://christopheralunlewis.blogspot.com/2012/09/making-rejection-comments-mandatory-in.html
Cannot modify trigger.new in after update.
ReplyDeleteProfile Codes if we use $Profile.Name Value:
ReplyDeleteSystem Administrator PT1
Standard User PT2
---- -
Customer Portal Manager PT14
S
ReplyDeletefor(int i=1;i<=100;i++)
{
if(i%10==0)
continue;
Sysm.out.println(i);
}
Abstract Class Name: MyAbstractClass
ReplyDeleteHow to cover the code for Abstract Class?
Need to write a mock class like below -
public class MyAbstractClassMockClass extends TriggerHandler {
public MyAbstractClassMockClass () {
}
}
Write a Test Class like below -
@isTest
private class TestMyAbstractClass {
static testMethod void myUnitTest() {
MyAbstractClassMockClass mbc = new MyAbstractClassMockClass();
mbc.method1();//which is declared in MyAbstractClass
//Repeat the same for all the methods.
}
}
To generate unique token in Apex saelsforce:
ReplyDeleteDateTime now = System.now();
String formattednow = now.formatGmt('yyyy-MM-dd')+'T'+ now.formatGmt('HH:mm:ss')+'.'+now.formatGMT('SSS')+'Z';
Blob bsig = Crypto.generateDigest('MD5', Blob.valueOf(formattednow ));
String token = EncodingUtil.base64Encode(bsig);
if(token.length() > 255) { token = token.substring(0,254); }
secureToken = Encodingutil.urlEncode(token, 'UTF-8').replaceAll('%','_');
return secureToken;
Apex Trigger Framework:
ReplyDeletehttps://developer.salesforce.com/page/Trigger_Frameworks_and_Apex_Trigger_Best_Practices
Covering Code for CompareTo method in Apex:
ReplyDeleteuse stmt like : value1.compareTo(value2);//It will cover.
hierarchy customsettings or list customsettings won't work without 'seeAllData' in Test Classes.
ReplyDeletetrigger UserTrigger on Account(before insert) {
ReplyDelete}
For the above trigger error is coming as mentioned below:
Error: Compile Error: Incorrect SObject type: Account should be User at line 1 column 1
What would be the reason?
He is creating the trigger from the user object.
Excluding weekdays and holidays in apex:
ReplyDeletepublic void populateExcludingholidaysandweekends() {
List holidaylst = [Select h.ActivityDate, h.Name, h.IsRecurrence From Holiday h];
Integer totalholidays = 0;
for(Holiday h : holidaylst) {
if(h.ActivityDate >= tor.Start_Date__c && h.ActivityDate <= tor.End_Date__c ) {
totalholidays += 1;
}
}
Integer i = 0;
Datetime sdate = Datetime.newInstance(tor.Start_Date__c, Time.newInstance(12, 0, 0, 0));
Datetime edate = Datetime.newInstance(tor.end_Date__c, Time.newInstance(12, 0, 0, 0));
Integer totalnumberDays = tor.Start_Date__c.daysBetween(tor.end_Date__c) + 1;
while (sdate <= edate) {
if (sdate.format('E') == 'Sat' | sdate.format('E') == 'Sun'){
i = i + 1;
}
sdate = sdate.addDays(1);
}
if(totalholidays != null)
i += totalholidays;
Integer workingdays = (totalnumberDays - i);
if(!usr.Non_Exempt_Employee__c)
tor.Total_Hours_Requested__c = workingdays;
else
tor.Total_Hours_Requested__c = (workingdays * 8);
}
Deleting child records if we delete the parent record in case of look-up relationship -
ReplyDeletetrigger ProjectTrigger on Proj__c (before delete) {
List empDelLst = [select id, Project_Latest__c from Employee__c where Project_Latest__c in: trigger.oldMap.keyset()];
delete empDelLst;
}
add all rows in soql query will return perminantly deleted records also.
ReplyDeleteFetching RecordTypeId using Dynamic Apex:
ReplyDeleteSchema.DescribeSObjectResult resSchema = Case.sObjectType.getDescribe();
Map recordTypeInfo = resSchema.getRecordTypeInfosByName();
Id recTypeId = recordTypeInfo.get('Record Type Name').getRecordTypeId();
Creating Test Data PROGRAMMATICALLY:
ReplyDeletehttp://startupsandcrm.com/2013/08/01/dynamic-visualforce-object-permissions-and-sobject-describe-results/
Checking whether the day is a business day or not:
ReplyDelete--------------------------------------------------
BusinessHours bushours = [select id from Businesshours where isDefault = true and Name='Default' limit 1];
Date outputDate = (BusinessHours.add(bushours.id, Datetime.newInstance(inputDate,Time.newInstance(12, 0, 0, 0)), 1000L)).date();
Note: if inputDate and outputDate both are not equal then it is a holiday.
When calling the static method constructor won't be invoked.
ReplyDeletejava -classpath c:\tools.jar;c:\wsc-22.jar com.sforce.ws.tools.wsdlc c:\Enterprise.wsdl c:\stub.jar
ReplyDeleteFollow the syntax like above to generate the jar file from Enterprise WSDL
To generate the jar file we should have jdk(to write code) ,
DeleteNote: jre(executing java)
Useful site for WSC files:
Deletehttp://code.google.com/p/sfdc-wsc/downloads/list
Use partnerWSDL and your service which is generated from the soap exposed class.
DeleteUse trigger.isexecuting in any class to get to know the code is executing from apex trigger or not.
ReplyDeleteFor Queried records we cannot use addError method in triggers.
ReplyDeleteHow to get combination of Two fields unique…… ?
ReplyDeleteEx: whenever we want combination of two fields must not be same
ie. If we have Standard Account object in this 1.Acccount Name 2.Billing country
Combination of these two fields should be unique.
This can be achieved By Work Flow Rule….
1. We need to Create a Text Formula field And make it Unique.
2.Now Create a Work Flow Rule On Account Object.
(1. In This The Evaluation Criteria: Created anytime time edited to meet the Criteria.
2. Rule Criteria
(Account: Account Name NOT EQUAL TO null) AND (Account: Billing Country NOT EQUAL TO null)
3. Now the Work Flow Action is Updating the Unique field ( In This The formula is combining two fields Account Name And Billing country)
/* Description:
ReplyDelete* ============
* Controller Class for VF Page - PageA
* Purpose of the class
*
* Author:
* ========
* User A
*
* Revision History:
* ========
* 01/31/YYYY - Initial development built
*
* Modified By
* ===========
* User B
*
* Revision History:
* ========
* 06/29/YYYY - Modified as part of latest release.
*/
Query from ApexClass to fetch all the apex classes.
ReplyDeleteQuery from ApexTrigger to fetch all the apex triggers.
Triggering DML Exception for Code Coverage:
ReplyDeletehttp://salesforce.stackexchange.com/questions/9888/triggering-a-dml-exception-for-test-coverage
To get the GMT time use Date.newInstanceGMT() method which will bypass the user's current logged in time zone.
ReplyDeleteConverting date for the CreatedDate:
ReplyDeleteDateTime dt = date.today();
Datetime tody = Datetime.newInstanceGmt(dt.year(), dt.month(), dt.day(), 0, 0, 0);
system.debug('@@@'+tody);
Test Class -
ReplyDeleteError: System.VisualforceException: Modified rows exist in the records collection!
Cause: When covering standardSetController due to the stmt setPageSize(), it is causing this error.
Solution: in test class while creating object keep that in try and catch block.
We can convert maximum 100 leads at a time using database.convertLead();
ReplyDeleteOne future method to other future method invocation will happen due to some new enhancements to avoid these kind of scenarios imeplement like below -
ReplyDeletepublic class InvokeClass {
if(system.future())
UtilityClass.syncMethod(some parameters);
else
UtilityClass.asyncMethod(some parameters);
}
public class UtilityClass {
//Invoke if request comes from a non-future method.
@future
public static asyncMethod(some parameters) {
}
//Invokes if request comes from a future method.
public static syncMethod(some parameters) {
}
}
To fetch the first three characters of the object -
ReplyDelete-----------------------------------------------------------------------
String oppKeyPrefix = Opportunity.sObjectType.getDescribe().
getKeyPrefix();
Avoiding duplicates while querying from the database:
ReplyDelete1. create a custom text field and make it as unique and update the field with workflow field update.
2. Use a before trigger (query the records with the names of trigger.new) Note; don't query all the records.
Note: after before trigger workflow rules fire (in between after triggers, assignment and auto responsive rules will fire).
Doing upsert operation with 5 records (3 are new records, 2 records will update), how many times trigger fire?
1. Trigger fires two times.
Note: If consider that it fire only one time trigger.new hold 3 records, trigger.old hold 5 records (always trigger.new count and trigger.old count both are same).
Based on Parent object city all the child's which are having that city should be linked -
ReplyDeletetrigger DepartmentTrigger on Department__c (after insert,after update) {
Set citySet = new Set();
for(Department__c dep : trigger.new) {
citySet.add(dep.Location__c);
}
Map> cityEmpMap = new Map>();
for(Employee__c emp : [select city__c,department__c from Employee__c where city__c in: citySet]) {
if(cityEmpMap.containsKey(emp.city__c)) {
cityEmpMap.get(emp.city__c).add(emp);
}
else {
cityEmpMap.put(emp.City__c,new List{emp});
}
}
system.debug('cityEmpMap'+cityEmpMap);
//Triggering Logic
List empUpdLst = new List();
for(Department__c dep : trigger.new) {
if(cityEmpMap.containsKey(dep.Location__c)) {
for(Employee__c emp :cityEmpMap.get(dep.Location__c)) {
emp.department__c = dep.id;
empUpdLst.add(emp);
}
}
}
if(empUpdLst.size() > 0) {
update empUpdLst;
}
}
For the schema.describe result map keys are Case-Insensitive.
ReplyDeleteBased on the Id update the records instead of querying from the database.
ReplyDeleteMax. batch size if the return type is Database.quryLocator: 2000
ReplyDeleteMax. batch size if the return type is iterable: no upper limit but other governor limit like heap size will might hit if we give more batch size.
Modifying records while running the batch job salesforce.
ReplyDeleteLightning:
ReplyDeletehttps://developer.salesforce.com/blogs/developer-relations/2015/02/lightning-components-sample-app-belgian-beer.html
To split with the pipe symbol -
ReplyDelete-------------------------------
stringname.split('\\|')
Insert failed. First exception on row 0; first error: INVALID_CROSS_REFERENCE_KEY, Record Type ID: this ID value isn't valid for the user: : [RecordTypeId]
ReplyDeleteResolution -
1. check if the recordid is null.
2. In test class plese set the current page on the top of the testMethod.
Apex Managed Sharing Considerations -
ReplyDelete1. In Share Object, for each record one entry will be maintained with Rowcause as 'Owner'.
2. Programmatically while sharing the records if you don't mention the Rowcause then it will default rowcause to 'Manual'
3. While deleting the records programmatically from the share object in filter condition keep it as 'Manual' (should be other than owner).
4. Otherwise following kind of error will come -
first error: DELETE_FAILED, cannot delete owner or rule share rows, share rows salesforce
After inserting the record to access the 'AutoNumbr' field value we should query from the database.
ReplyDeleteChrome Extensions -
ReplyDelete1. RestClient.html
2. Salesforce Code Advanced Searcher
https://chrome.google.com/webstore/detail/salesforce-advanced-code/lnkgcmpjkkkeffambkllliefdpjdklmi?hl=en
ReplyDeleteCapturing the email status -
ReplyDeleteMessaging.SendEmailResult[] results = Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
Queueable Apex - with no governor limits enforced for the future operations.
ReplyDeleteNetwork Issue -
ReplyDeleteIf the Community is not present the if we try to use 'Network', It will throw the compilation error.
Yesterday and today functions are not working for SOQL queries in eclipse where as directly in browser it is working out.
ReplyDeleteSOSL/SOQL present in a account trigger, if the account records are inserted using 150 different DML stmts,
ReplyDeletethese triggers also fire multiple times and every time trigger.new will be 1 in size, if more than 20 records are inserted then
21 SOSL limits will be reached.
If more than 100 times DML stmt executes then 101 SOQL limits will be reached.
After inserting a case, one of the child case should be created for after insert event?
ReplyDeleteRecursive triggers will occur.
Emails in Apex Code -
ReplyDeleteWe cannot send email by calling a method from constructor. (from constructors we cannot send emails )
Database.Batchable --> Database is a namespace not the Class, inside the classes we cannot keep the interface.
ReplyDeleteDescribing object (dynamic apex) -
ReplyDeleteSchema.getGlobalDescribe().get(objectApi).getDescribe().fields.getMap().get(fieldApi).getDescribe().getReferenceTo()[0].getDescribe().getName();
To know the total count of an object if there are more than 50000 records in an object -
ReplyDeletepublic class Test_Aggregate{
public static void TestAgg() {
Integer intCount = 0;
for(AggregateResult result :[SELECT COUNT(Id) intVal FROM Custom_Object__c])
{
intCount+=(Integer)result.get('intVal');
}
System.debug('No of records are: '+intCount);
}
}
Reference:
https://salesforce.stackexchange.com/questions/130013/how-to-get-exact-record-count-for-an-object-using-soql-for-more-than-1-million-r
Working in Multi-Currency Org -
ReplyDeleteSELECT Amount, FORMAT(amount) Amt, convertCurrency(amount) convertedAmount,FORMAT(convertCurrency(amount)) convertedCurrency FROM Opportunity WHERE Amount > USD5000
convertCurrency(amount) --> converting currency to the user locale
FORMAT(convertCurrency(amount)) --> formating to add the currency symbol in output
USD5000 --> currency symbol+amout which will be used in where clause.
DataType name: getType().Name()
ReplyDeleteGit Flow -
ReplyDeletehttp://nvie.com/posts/a-successful-git-branching-model/#decentralized-but-centralized
Password reset email while creating new user in apex -
ReplyDeleteDatabase.DMLOptions dmlo = new Database.DMLOptions();
dmlo.EmailHeader.triggerUserEmail = true;
usr.setOptions(dmlo);
Trigger Scenario -
ReplyDeletehttps://gist.github.com/sriniind19/c394ecfe6a47e8a88fe7f0488e5d238c
While While creating the portal user in apex it is giving error saying the 'account owner should have the role'
ReplyDeleteResolution:
if(account.owner.UseRoleName) {
//Create portal user
}
//Note: make sure to give the role for the contact's parent account's owner.
***************
ReplyDeleteTo match the current datetime with the SOQL query datetime formatGMT
***************
Approach - 1
------------
DateTime dt = datetime.now();
Datetime tody = Datetime.newInstanceGmt(dt.year(), dt.month(), dt.day(), dt.hour(), dt.minute(), dt.second());
system.debug(tody.formatGMT('yyyy-MM-dd\'T\'HH:mm:ss.SSSZ'));
Approach - 2
Datetime now = Datetime.now();
Integer offset = UserInfo.getTimezone().getOffset(now);
Datetime local = now.addSeconds(offset/1000);
system.debug(local.formatGMT('yyyy-MM-dd\'T\'HH:mm:ss.SSSZ'));
*******************
onBeforeInsert() {
ReplyDelete//Multiple methods are called for each requirement,
//Due to this, it is hitting number of soql query limits.
//It is better to know about the apex design patterns.
}
Mac VS Code Path: /Library/Java/JavaVirtualMachines/jdk-11.0.8.jdk/Contents/Home
ReplyDeleteAccount Share Record -
ReplyDeleteAccountShare accShare = new AccountShare(
AccountAccessLevel = 'Edit',
AccountId = event.WhatId,
UserOrGroupId = event.OwnerId,
OpportunityAccessLevel = 'Edit'
);