Wednesday 31 March 2021

Apex Triggers in Salesforce

 Hello All, 

Before we write any example let us first understand what are Triggers.

Just like database triggers that execute on/after/before certain event to execute a set of statements, Apex triggers also server the same purpose.

Triggers allows us to do custom actions on events, i.e. do some field setting, fire SOQL statement, execute some complex equation,

supported events ,

  • before insert
  • before update
  • before delete
  • after insert
  • after update
  • after delete
  • after undelete

sample Trigger syntax,

trigger TriggerName on ObjectName (trigger_events) {                  

//code here 


TriggerName is unique Name for Trigger, Object Name is Entity Name,

Note : in the below example we are using Context to get the current record details,
for(Opportunity opp : Trigger.New)


1. set a Field value when a Opportunity record is updated

trigger SetBuyingTimeFrame on Opportunity (before update) {
for(Opportunity opp : Trigger.New)
opp.Buying_Time_Frame__c = '1-Immediate';

2. Using a If Else condition in trigger

trigger SetBuyingTimeFrame on Opportunity (before update) {
for(Opportunity opp : Trigger.New)
opp.Buying_Time_Frame__c = '1-Immediate';
opp.Buying_Time_Frame__c = '5-Within 3 Months';

2. Using a switch statement in trigger

ttrigger SetBuyingTimeFrame on Opportunity (before update) {
for(Opportunity opp : Trigger.New)
switch on opp.Enquiry_Classification__c{
when '1-Excellent' {opp.Buying_Time_Frame__c = '1-Immediate';}
when '2-Very High' {opp.Buying_Time_Frame__c = '2-Within 1 Week';}
when '3-High' {opp.Buying_Time_Frame__c = '3-Within 2 Weeks';}
when else {opp.Buying_Time_Frame__c = '5-Within 3 Months';}

the examples are endless :-), more details are available on link, 

Creating a Lookup Relation in Salesforce

 Hello All, 

Many times we require data from other entity being stored and referenced in source entity. i.e. Account Details in Opportunity.

We have Lookup relationship type for implementing the requirement, so lookup defines a way to get fields data from some Target entity to the source Entity

let see a simple scenario, we require to bring Financer to Opportunity (Financer is a type of Account with Type having value Technology Partner)

1. Setup- Objects - Fields ,click New

Select Lookup Relationship

2. Select the Target Entity, Since i need to fetch account details i will choose Account.

3. Provide Field Label and Description, 

there are Option to make the Fields Required, by Ticking the Required Flag

and option for deleting the Relationship (clear the value or do not delete)  

4. Now Comes the Important part, setting the Filter Criteria

As mentioned in the beginning, i need to show Account in the Lookup, that have Type as Technology Partner.

Select the field in Account on which we need to Filter 

Account:Type ,and in value choose Technology Partner from the Popup List.

Now when we see the Financer in the Form , we see only Records that match the Filter Criteria specified. Save and add field on the layout. 

I will be covering some more complex scenarios in upcoming posts.

Tuesday 30 March 2021

Validation Rules in Salesforce

 Hello All, 

Very often we require to make system throw errors based on Values of Different fields.

i.e. Suppose field Purchase Type has value "Finance" then, Finance Stage and Financer must be filled else there should be error popup.

This can be configured with Validation Rules, and no Apex code is required for this, 

Lets see the steps for this,

1. Go to Setup -- Customize -- select the Entity to customize(Opportunity in my case) -- select Validation Rules

2. List appears for the validation Rules, here we need to write a New rule or Edit an Existing one.

3. Writing the Formula, 

we need to Give a meaningful name to the Rule, 

The expression builder is very user friendly, we can select the Field from Select Field Button, and Insert Operator button to Insert functions, 

Check syntax to validate the expression, and Provide the error message as desired.

Tips to write expression , 

to check if Finance field is  null 

ISBLANK() function can be used for this, as the name suggest it returns Y for Blank values 

to check if Finance Stage Picklist has null value

ISPICKVAL(Name,""), can be used as for picklist field we cannot use ISBLANK() function 

and then clubbing the Equation to be 

ISPICKVAL(Purchase_Type__c,"2-Finance") && (ISPICKVAL(Finance_Stages__c,"") || ISBLANK(Financer__c))

Which is equivalent to

IF (Purchase type = '2-Finance' AND (Finance Stage is NULL OR Financer is NULL))

this can be written to handle more complex cases see examples here

Changing the Default Form Layout in Salesforce

 Hello All, 

Setting up Layout form of any entity, is very basic step when developing a form/Process for the client.

Salesforce provides vanilla layout and new fields are added automatically on the layout, but grouping, Layout and Read-only Behavior need to be edited as per the Business requirement.

so Lets start this customization step wise , 

1. Go to Page Layout Option , Setup -- Customize -- Entity (Opportunity in my case) -- Page Layout

2. Once page Layout is clicked the default layouts are visible for different applications, select the one for your Application and Click Edit,

3.The below Wizard appears , here we can drag drop and arrange the fields as per requirement,

There are option to remove a fields, Edit its property or Replace it to other place by click and Dragging it 

4. Once done, Click on Page Layout Assignment and Edit Assignment, 

Here assign the page to role as per requirement

Suppose You need to Assign the New Layout to Sales Profile then choose Sales in Profile and Select the Page Layout you Just Changed

Update Layout, 

very basic, yet Most Important :-)

Wednesday 17 March 2021

Replacing Special Characters in Siebel

 Hello All, 

Recently i had a requirement where i had to replace some special character's like &,@ from SMS body that was sent as notification.

solution is very simple and basic :-), we need to use string function replace() for this and pass the pattern to replace.

var str= "Dolce & Gabbana";

var pat = "&";

var rtn = str.replace(pat, "%26");

TheApplication().RaiseErrorText(rtn );                                            

We can write a business service for this and call this in WF or Script which we are using to send the SMS/EMAIL.

Tuesday 2 February 2021

Collapsible Applets in Siebel - Making Applets Mobile Friendly

 Hello All , 

With complex business process comes lot of Fields :-) , and with increased fields UI becomes more cumbersome.

Lets see a generic UI screen 

This can be converted in more manageable and UI friendly Applets.

Improved isn't it, share your thoughts in Comments

Disable Copy Record in Siebel Applets

 Hello All, 

This is very common requirement where we need to disable some particular operation on a applet i.e. New Record, Delete Record, Copy Record.

SRF solutions are many for these types of requirements ,Applet User Property, No Delete ,No Update, No Copy properties at applet and BC level.

Lets Try to Do this the Non-SRF way.

1. Create a Run Time Event , with Applet Object and SubEvent as CopyRecord

2. Create a Action Set, with below Configuration

Reload the events and see the changes, We have successfully Disable Copy Record without any SRF change :-)

Siebel GoTo View - Handling Realtime cases

 Hello All,  We all must have used GoTo view functionality of siebel to navigate to a particular view from current view. What if the require...