1. On Visualforce email template, I want to display only date from CreatedDate field (it's a Date time field).
Answer:
1 2 3 4 5 6 7 8 | <messaging:emailTemplate subject="ACTION REQUIRED!" recipientType="User" relatedToType="Interaction__c"> <messaging:HtmlEmailBody> <p>{!relatedTo.Code_Label__c} has been submitted on <apex:outputText value=" {0,date,dd-MM-yyyy}"> <apex:param value="{!relatedTo.createddate}" /> </apex:outputText> is still pending approval.</p> </messaging:HtmlEmailBody> </messaging:emailTemplate> |
1 2 | <apex:outputText value=" {0,date,dd-MM-yyyy}"> <apex:param value="{!relatedTo.createddate}" /> |
2. I want to test 100 email templates then which email-Id you will use?
Answer: While testing email templates, we don't need to use our original emails. We can use disposable email services. Try this it is very interesting.
1. yopmail
2. mailinator
Advantages are:
- No registration
- Auto-generated inbox
- No Password
- Messages are kept for 8 days.
Answer: There are times where we need to initialize the Map (at the time of Map variable creation).
Assume, I have an object called "LocationUnit" which has a total of 600 records. This object contains 3 categories of data, let's say "District", "State" and "city". These categories are identified with a TEXT(will store Alphanumeric value) field which contains 10 characters.
Here,
District is identified like this:
7th + 8th characters should be greater than zero.
9th character =0
10th character =0
District example: XYZ4567800
Now, my requirement is to fetch all the "District" (LocationUnit) record Ids and pass it to another SOQL query to fetch other object records.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | //Below Map is initialized because if we retrieve a specific character from the text field it will give us ASCII value so to get the decimal number I created this Map. Map<Integer,Integer> aciiMap = new Map<Integer,Integer>{48=>0,49=>1,50=>2,51=>3,52=>4,53=>5,54=>6,55=>7,56=>8,57=>9}; String LocationUnitNumber; set<Id> locationIds = new set<Id>(); for(OrgUnit__c ou: [Select Id,LocationUnitNumber__c from LocationUnit__c]) { orgUnitNumber = ou.LocationUnitNumber__c ; if(!String.isEmpty(LocationUnitNumber) && LocationUnitNumber.length()==10 (aciiMap.get(LocationUnitNumber.charAt(6)) + aciiMap.get(LocationUnitNumber.charAt(7)))>0 && aciiMap.get(LocationUnitNumber.charAt(8))==0 && aciiMap.get(LocationUnitNumber.charAt(9))==0) { locationIds.add(ou.Id); } } |
Answer: Assume, I have a Junction object named as "LocationBasedAmount" below is the sample data of this Object.
LocationId | AmountId |
Loc1 | Am1 |
Loc1 | Am1 |
Loc1 | Am2 |
Loc2 | Am1 |
Loc2 | Am1 |
Loc3 | Am3 |
Loc1 - Am1
Loc1 - Am2
Loc2 - Am1
Loc3 - Am3
To achieve this I have 2 options
Option 1: we can use Map.
1 2 3 4 5 6 7 8 9 10 11 12 13 | Map<Id,set<Id>> locMap = new Map<Id,set<Id>> (); for(LocationBasedAmount__c ba : [Select AmountId__c,LocationId__c from LocationBasedAmount__c]) { if(!locMap.containsKey(ba.LocationId__c)) { locMap.put(ba.LocationId__c ,new set<Id>{ba.AmountId__c}); } else if(locMap.containsKey(ba.LocationId__c) && !locMap.get(ba.LocationId__c).contains(ba.AmountId__c)) { locMap.get(ba.LocationId__c).add(ba.AmountId__c); } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | Class MainClass { List<WrapperClass> LocAmountIdsList = new List<BudWrapper>(); for(LocationBasedAmount__c ba : [Select AmountId__c,LocationId__c from LocationBasedAmount__c]) { if(!locMap.containsKey(ba.LocationId__c)) { locMap.put(ba.LocationId__c ,new set<Id>{ba.AmountId__c}); WrapperClass bw = new WrapperClass(ba.AmountId__c,ba.LocationId__c); LocAmountIdsList.add(bw); } else if(locMap.containsKey(ba.LocationId__c) && !locMap.get(ba.LocationId__c).contains(ba.AmountId__c)) { locMap.get(ba.LocationId__c).add(ba.AmountId__c); WrapperClass bw = new WrapperClass(ba.AmountId__c,ba.LocationId__c); LocAmountIdsList.add(bw); } } class WrapperClass { public Id AmountID; public Id LocationId; public WrapperClass(Id AmountID,Id LocationId) { this.AmountID = AmountID; this.LocationId = LocationId; } } } |
5. Examples for Validation rules, Workflows, Process builder?
Answer :
Validation rules: Link 1
Workflows: Link 1, Link 2
Process builder: Link 1, Link 2, Link 3, Link 4, Link 5
tHiNk gooD and dO thE bEsT.........MANJU NATH 🌝
Comments
Post a Comment