Skip to content

Instantly share code, notes, and snippets.

View TheShubhamVsnv's full-sized avatar
😀
I will be there where i want to be tomorrow by being me.

Shubham Vaishnav TheShubhamVsnv

😀
I will be there where i want to be tomorrow by being me.
View GitHub Profile
@TheShubhamVsnv
TheShubhamVsnv / Calculator.tgr
Created June 15, 2021 19:23
Salesforce Apex Trigger to Create a Simple Calculator
trigger Calculator on Calculater__c (before Insert, before update) {
for(Calculater__c s : trigger.new)
{
if(trigger.isInsert || trigger.isUpdate)
{
if(s.operator__c=='/')
{
s.Result__c= s.Value_1__c / s.Value_2__c;
}
@TheShubhamVsnv
TheShubhamVsnv / presentAge.tgr
Last active June 15, 2021 19:29
Salesforce Apex Trigger Program to Calculate Age from Birth Date in (Day, Month, Year)
trigger presentAge on Date_OF_Birth_Calculat__c (before Insert, before update) {
for(Date_OF_Birth_Calculat__c DOB : trigger.new)
{
if(trigger.isInsert || trigger.isUpdate)
{
integer[] month = new list <integer>{ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
Date present_date = System.today();
Integer present_Day = present_date.Day();
Integer present_month = present_date.Month();