Sample Code:
IF (FLOOR((EndDateTime__c - StartDateTime__c)) > 0, TEXT(FLOOR((EndDateTime__c - StartDateTime__c)) ) & " Days ", "")
& IF(FLOOR(MOD((EndDateTime__c - StartDateTime__c)* 24, 24 )) > 0, TEXT(FLOOR(MOD((EndDateTime__c - StartDateTime__c)* 24, 24 ))) & " Hours ","")
& TEXT(ROUND(MOD((EndDateTime__c - StartDateTime__c)* 24 * 60, 60 ), 0)) & " Minutes "
& TEXT(ROUND(MOD((EndDateTime__c - StartDateTime__c)* 24 * 60*60, 60 ), 0)) & " Seconds"
Loading...
Sample Code:
trigger AccountTrigger on Account (before delete, before update, before insert, after insert, after update) {
if (trigger.isDelete) {
for (Account acc : trigger.old) {
acc.addError('You cannot delete account records');
}
}
}
Loading...
Sample Code:
public class ContactProcessBuilderHandler {
@InvocableMethod
public static void sendContacts(List<Contact> conList) {
string jsonData = JSON.serialize(conList);
sendContactsToOracle(jsonData);
}
@future(callout = true)
public static void sendContactsToOracle(string jsonData) {
HttpRequest req = new HttpRequest();
HttpResponse res = new HttpResponse();
Http http = new Http();
req.setEndpoint('https://your endpoint url');
req.setMethod('POST');
req.setHeader('Authorization', 'Authorization Header');
req.setHeader('Content-Type', 'application/json');
req.setBody(jsonData);
req.setCompressed(true);
res = http.send(req);
}
}
Loading...
Using .KeySet()
on a map, we will get a list of all the keys returned.
Map<Id, Master_Obj__c> masterMap = new Map<Id, Master_Obj__c>([SELECT Id, Name FROM Master_Obj__c]);
List<Detail_Obj__c> objDetailList = [Select Id, Name FROM Detail_Obj__c WHERE Master_Obj__c IN :masterMap.KeySet()]
Loading...
For Custom Controller
//Page reference to your VF Page
PageReference pageRef = Page.TestPage;
Test.setCurrentPage(pageRef);
//Pass necessary parameter
pageRef.getParameters().put('Id',id);
//init controller
CustomCtrl objCtrl = new CustomCtrl();
//Call pageRef mymethod
PageReference objPageRef = objCtrl.mymethod();
//Put system asserts
System.assertEquals (null,pageRef);
For Standard Controller
//First create record
Account acc = New Account();
acc.Name = 'Test Account';
INSERT acc;
//Page reference to your VF Page
PageReference pageRef = Page.TestPage;
Test.setCurrentPage(pageRef);
//Pass necessary parameter
pageRef.getParameters().put('Id',acc.id);
//Pass your object to controller
ApexPages.StandardController stc = new ApexPages.StandardController(acc);
//Call controller
CustomCtrl objCtrl = new CustomCtrl(stc);
//Call pageRef mymethod
PageReference objPageRef = objCtrl.mymethod();
//Put system asserts
System.assertEquals (null,pageRef);
Loading...