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
Nilesh More 5Nilesh More 5 

Validation Rule to restrict user from creating new record on the "XYZ" Standard object with certain conditions.

Validation Rule to restrict user from creating new record on the "XYZ" Standard object.
conditions:
 (only for "Overtime" record type) that "Start Time" field(Date/Time) cannot be less than 4pm and "End Time" field(Date/Time) cannot be more than 8pm on the same day.

I tried to write it from my way but It's not workking as expected.
The validation rule I have written is:

AND(ISNEW(), RecordType.DeveloperName ='Overtime', VALUE( MID( TEXT( Start - 5.5 ), 12, 2 ) ) < 16,VALUE( MID( TEXT( End- 5.5 ), 12, 2 ) ) > 20, DATEVALUE(Start)  =  TODAY() 
)


Can anybody help me to solve this?

Thanks

Best Answer chosen by Nilesh More 5
Nilesh More 5Nilesh More 5

Perfect working
Just done with the validation rules from my end
Created two validation rule for it
Rule1:
IF(Start<>End, AND(ISNEW(), RecordType.DeveloperName ='Overtime', VALUE( MID( TEXT( Start), 12, 2 ) ) < 16, DATEVALUE(Start-5.5) <> DATEVALUE(End)), false)

rule2:
IF(Start<>End, AND(ISNEW(), RecordType.DeveloperName ='Overtime', VALUE( MID( TEXT( End), 12, 2 ) ) > 20, DATEVALUE(Start) <> DATEVALUE(End-5.5) 
), false)

 

thanks for your help guys

Thanks
Nilesh

All Answers

Ajay K DubediAjay K Dubedi
Hi Nilesh,
Try this:-
AND(
IF(CASE( VALUE(MID(TEXT(Start - 5.5),12,2)) , 
0, 19,
1, 20,
2, 21,
3, 22,
4, 23,
5, 0,
6, 1,
7, 2,
8, 3,
9,  4,
10,  5,
11,  6,
12,  7,
13,  8,
14,  9,
15,  10,
16,  11,
17,  12,
18,  13,
19,  14,
20,  15,
21,  16,
22,  17,
23,  18,
0)<4,ISNEW(),false),
CASE( VALUE(MID(TEXT(End- 5.5 ),12,2)) , 
0, 19,
1, 20,
2, 21,
3, 22,
4, 23,
5, 0,
6, 1,
7, 2,
8, 3,
9,  4,
10,  5,
11,  6,
12,  7,
13,  8,
14,  9,
15,  10,
16,  11,
17,  12,
18,  13,
19,  14,
20,  15,
21,  16,
22,  17,
23,  18,
0)>20,
RecordType.DeveloperName ='Overtime'
)
Kindly mark it as best if it helps.

Thanks
Ajay
Nilesh More 5Nilesh More 5

Hey Ajay,

Seems it's not working.

Thanks

Rahul KumarRahul Kumar (Salesforce Developers) 
Hi Nilesh,

May I suggest you please check the below link for reference. hope it helps.

Thanks
Rahul Kumar
Nilesh More 5Nilesh More 5
Hi Rahul,
Thanks for your reference, any other solution?

Thanks
Nilesh
Ajay K DubediAjay K Dubedi
try using 4 instead of 16 and 8 instead of 20.

Thanks 
Ajay
Nilesh More 5Nilesh More 5
Still it's not wroking

Thanks
Nilesh
Nilesh More 5Nilesh More 5

Perfect working
Just done with the validation rules from my end
Created two validation rule for it
Rule1:
IF(Start<>End, AND(ISNEW(), RecordType.DeveloperName ='Overtime', VALUE( MID( TEXT( Start), 12, 2 ) ) < 16, DATEVALUE(Start-5.5) <> DATEVALUE(End)), false)

rule2:
IF(Start<>End, AND(ISNEW(), RecordType.DeveloperName ='Overtime', VALUE( MID( TEXT( End), 12, 2 ) ) > 20, DATEVALUE(Start) <> DATEVALUE(End-5.5) 
), false)

 

thanks for your help guys

Thanks
Nilesh

This was selected as the best answer
legit daralegit dara
Buy real and fake driver's license. passports, ID cards, VISA (legitdocuments120@gmail.com) 

We offer both fake and original high-quality IDs and Passport ,Visa,Driving License,ID CARDS,marriage certificates,diplomas etc buy now high quality
-We have the best HOLOGRAMS AND DUPLICATING MACHINES With over 13million of out documents circulating over the world. -IDs Scan-yes...

-HOLOGRAMS: IDENTICAL 
-BAR CODES: IDS SCAN
-UV:  YES 
-Passports FAKE IDS WITH FAST SHIPPING 
-EMAIL SUPPORT : (legitdocuments120@gmail.com)

Fake ID's Over state drivers license cards and State ID cards available. Includes state driver's license hologram and magnetic strip or bar code on back. 2 business day shipping order (shipping and handling). The BEST authentic fake ID's on the web. Same quality, high resolution that Department of Motor Vehicles use. Send current .JPG or .GIF of current license with picture and changes in NAME, DOB, #LICENSE, RESTRICTIONS, etc. we produce the best fake ID online we sell UK/EU fake ID, Canadian fake ID, Australian fake ID and fake IDs for many other countries from fake passports to fake driving licenses to fake bank statements we have your identification needs covered. Our fake IDs include all security features such as genuine holograms, ultraviolet watermarks, intaglio printing, special paper, fluorescent dyes, RFID chips, bar codes corresponding to your details and more. Our fake IDs are identical to the real thing no other site will offer you this quality we are the best. new identity protect your privacy and take back your freedom..

Contact e-mails:=========== (legitdocuments120@gmail.com)
 
legit daralegit dara
Buy real and fake driver's license. passports, ID cards, VISA (legitdocuments120@gmail.com) 

We offer both fake and original high-quality IDs and Passport ,Visa,Driving License,ID CARDS,marriage certificates,diplomas etc buy now high quality
-We have the best HOLOGRAMS AND DUPLICATING MACHINES With over 13million of out documents circulating over the world. -IDs Scan-yes...

-HOLOGRAMS: IDENTICAL 
-BAR CODES: IDS SCAN
-UV:  YES 
-Passports FAKE IDS WITH FAST SHIPPING 
-EMAIL SUPPORT : (legitdocuments120@gmail.com)

Fake ID's Over state drivers license cards and State ID cards available. Includes state driver's license hologram and magnetic strip or bar code on back. 2 business day shipping order (shipping and handling). The BEST authentic fake ID's on the web. Same quality, high resolution that Department of Motor Vehicles use. Send current .JPG or .GIF of current license with picture and changes in NAME, DOB, #LICENSE, RESTRICTIONS, etc. we produce the best fake ID online we sell UK/EU fake ID, Canadian fake ID, Australian fake ID and fake IDs for many other countries from fake passports to fake driving licenses to fake bank statements we have your identification needs covered. Our fake IDs include all security features such as genuine holograms, ultraviolet watermarks, intaglio printing, special paper, fluorescent dyes, RFID chips, bar codes corresponding to your details and more. Our fake IDs are identical to the real thing no other site will offer you this quality we are the best. new identity protect your privacy and take back your freedom..

Contact e-mails:=========== (legitdocuments120@gmail.com)