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
laxman rajlaxman raj 

insert account records only monday to friday using triggers don't want to insert on saturday and sunday

logontokartiklogontokartik
You can get the day of week from Date functions and put an if clause in your trigger. something like
DateTime todaysDate = system.now();
String dayOfWeek = todaysDate.format('E');

// Sat, Sun, Mon, ....

if(dayOfweek == 'Sat' || dayOfWeek == 'Sun'){
 // do not execute trigger
}else{
// execute trigger
}


Shyam BhundiaShyam Bhundia
You could make use of Salesforce's Business Hours functionality. 

You setup the business hours here : Setup > Company Profile > Business Hours

Then you can use the below code in the trigger to check if the curent time is within the business hours.

// Get the business hours
BusinessHours bh = [SELECT Id FROM BusinessHours WHERE Name = 'BusinessHoursName' ];

// Find whether the time is within the  business hours
boolean isWithin= BusinessHours.isWithin(bh.id, DateTime.Now());
Hope this helps!

laxman rajlaxman raj
Can you please list out full of code ..


Thanks &Regards,
Laxman 
Shyam BhundiaShyam Bhundia
do you have a trigger on the account already?