function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
TheLearnerTheLearner 

Trigger to populate the recent value in the fileds

Hi Experts,

My requirment is  i have object called Site__C it contains fields called , Public_Site_Clear__c,Private_Site_Clear__c,Site_Clear__c so what we need to do that 

When Public Site Clear(Public_Site_Clear__c) and Private Site Clear(Private_Site_Clear__c) dates are both populated, trigger the update (on initial population only) of the Site Clear(Site_Clear__c) field with the latest date. i.e Public Site Clear = 23/10/2015, Private Site Clear = 02/11/2015, therefore Site Clear = 02/11/2015. If the dates are subsequently changed then do nothing.

Could anyone help me pleaase

 
Andy BoettcherAndy Boettcher
This is a use case that you can satisfy with standard workflow or Process Builder - no code needed.
Swayam@SalesforceGuySwayam@SalesforceGuy
If you want to write code, You Can Use  Before Insert Trigger and Check for the Condition, Alos you can use workflow which is more eaiser Just point and click compare to trigger.


--
Regards,
Swayam
@Salesforceguy
Andy BoettcherAndy Boettcher
Remember!  CLICKS BEFORE CODE - never write code when the platform provides you non-code options to do so.
TheLearnerTheLearner
HI All,

Could you tell me how i need to write workflow as they mentioned ,i need to check Public Site Clear(Public_Site_Clear__c) and Private Site Clear(Private_Site_Clear__c) dates when they are populuated then i need to populate  Site Clear(Site_Clear__c) date with latest date
Sanpreet SainiSanpreet Saini
Hello Learner,

Try these steps to resolve your problem 


go to workflow. 

Choose the object 

In evaluation criteria select "created, and every time it is edited"

Rule criteria >> formula evaluates to true 

Use below formula. 

ISCHANGED(Private_Site_Clear__c) ||  ISCHANGED( Public_Site_Clear__c )

go to workflow action select field update

choose field to update "Site_Clear__c"

Use below formula to update the field. 

if( Private_Site_Clear__c  >  Public_Site_Clear__c , Private_Site_Clear__c,Public_Site_Clear__c)


Mark this as resolved if the issue is resolved. Feel free to reach if you still have any further concern. 

Regards, 
Sanpreet