« first day (2 days earlier)    last day (32 days later) » 

12:44
Hi @Mahmood
How are yOU?
Hello
Im good. You tell
what issue you are facing
Mahmood I have one scenario
Yes thank you for my Kind request
In order I have created the record
There is another field called offset field ? which contains number
two fields are on the order
offset - number
deleivery Date -date field
while creating the order record if i place 2 value in offset field,then deleivery date should be populated after two days. if i put order today means Deleivery date should be wednesday
That means created date of order + 2
saturday and sunday should be weekend
if create the order on monday , offset value will be 2, then deleivery date should be on wednesday
This could be done by before insert trigger and workflow rule which is possible
How to skip saturday and sunday with the help of offset values
Guide me please?@Mahmood
So, you want to ignore weekends?
yes
How?
I want to ignore another two days also
You can create workflow rule to test this
with fld update action.
12:57
please tell
How?
the above days also i want to ignore
in your function check
if( (Day(DeliveryDate)== 6 || Day(DeliveryDate) == 7), Monday, Add offset to order creation date)
another two days also there which is thursday and friday which is stored in Holiday custom object
How to write the workflow rule,what conditions i have to give in criteria met and field update
oh.
Then you need to have trigger
Elaborate the scenario in workflow rule only
If you are accounting for holidays from custom object then trigger
13:02
In workflow rule it is not possible
else just for weekends, workflow will do.
please suggest some code for trigger using before insert i did not have any idea
please help me through code
You should write some code
Before Insert trigger should be implemented.
please send some sample code for this scenario I am facing
Write some code and if you find yourself in trouble then ask for help. :)
13:07
How to start help me please
send some logic , Mahmood please
I dont Know the logic how to skip weekends and holiday object,guide me please Mahmood
trigger OrderTrg on Order (after insert)
{
// get your holiday by soql from holiday custom object in a list or map

// check delivery date of the order and offset

// if the delivery date + offset is falling on weekend and/or holiday , find next working day.
}
ok
These two blocks
/ check delivery date of the order and offset

// if the delivery date + offset is falling on weekend and/or holiday , find next working day.
Guide me some sample code Mahmood,I am getting blank in my mind
first develop something. Take a break if you are exhausted.
This is the way I learnt.
And that's the way I want to help others.
:)
13:16
some basics sample code my scenario
My clear doubt how to skip weekends and Holiday object
How to check this scenario
Give some hint or Formula,I am learning lot of new things from you
You helped me a lot
Create a map of holidays object, with the key being the date of holiday.
and in the trigger.new (which will be order records)search for the order record date fld in your map. using Map.get(key)
something like that
Day function returns the day (in numbers)
you can easily put a check for weekends
13:24
ok and then how to give check for holiday object
please provide that if conditon for skipping weekend dates and holiday object dates
for example below code returns 3 in my org
System.debug('Today is :' + System.today().day() );
ok
Date is returning, for weekends it return dates only na, then how i will skip weekends
Very Confusing me @Mahmood,what i will do I dont Know
Very difficult task
date.day()
it will return a number
you have to figure out what is the number for weekends in your org
weekends should be common
saturday and sunday
It is Difficult task to me @Mahmood, what i will do ? dont Know
Is it possible to return Day name like Monday , tuesday like that
13:43
try
ok
send some samples @Mahmood
send some loop hole, I will continue from that loop hole, for me unable to get idea also
for me major thing in this, how to skip weekends and Holiday,remaining I will try
Datetime dt = DateTime.newInstance(Date.today(), Time.newInstance(0, 0, 0, 0));
String dayOfWeek=dt.format('EEEE');
System.debug('Day : ' + dayOfWeek);
No need of time @Mahmood
only Date enough
It is day name coming
you have to get the datetime.
If i take for skipping i want next two days name
13:51
as the format with string is only available for datetime class.
I have to leave.
Best of luck
for weekends skipping
Is there any default format is available for saturday and sunday
Guide Me Mahmood Please
ok Thank you for Guide me this Much of Information
Hi @Eric
14:08
Greetings
Thank you for My Kind Request. for coming this room @Eric
Hi How are You ?
Let's just say glad it's Friday
I have strucked with the one Major conflict
Two fields are there in order
Offset - Number
Deleivery Date - Date
if i create the order record with todays date and offset value as 2 then deleivery date should be on Tuesday (Saturday and sunday are weekends)
If i create order on Monday the deleivery date should be wednesday
Use business hours class to calculate delivery date. Several examples if you do a search
offset value as 2 , created date of order + 2
For Me I want to skip weekends such as saturday and sunday
14:15
If you are looking for formula searc on exclude weekends and you will find answers
deleivery date should not be placed on these dates how?
using before insert
Is it possible to acheive in trigger code
Yup. See my comments
ok , give sample code guidelines , I will develop from that
@Eric
guide Me Please @Eric
I am not recreating the wheel. Do a search, the answers are there will plenty of examples
if you get stuck, ask a question
ok Thank you@Eric
I will try My best
14:24
Here a the first link from a search - salesforce.stackexchange.com/questions/34827/…
ok Thank you so Much @Eric

« first day (2 days earlier)    last day (32 days later) »