You need to sign in to do that
Don't have an account?
sfdc dev 2264
Date Range restriction help needed
Hi,
I need help on the following requirement below as follows,
1) I have a account object where contract is another object related to account
2) Contract object is having contract start date and end date which populates to account
My scenario is
3)If there are 2 active contract associcated to account and the dates contain
1st Active contracts dates are
start date :1.feb 2017
end date : 31st march 2017
2nd active contract dates are
start date : 1st march 2017
end date : 17th sep 2017
then in this scenatio the first active contract end date should be automatically backdated to the previous month below as follows to avoid overlapping between 2 contracts
1st active contract end date should automatically be changed to
end date :28th feb 2017
start date should remain the same as 1 feb 2017.
basically both contracts end dates and start dates shouldnt fall in same range to avoid overlapping
Help me how to achieve this
Thanks in advance
I need help on the following requirement below as follows,
1) I have a account object where contract is another object related to account
2) Contract object is having contract start date and end date which populates to account
My scenario is
3)If there are 2 active contract associcated to account and the dates contain
1st Active contracts dates are
start date :1.feb 2017
end date : 31st march 2017
2nd active contract dates are
start date : 1st march 2017
end date : 17th sep 2017
then in this scenatio the first active contract end date should be automatically backdated to the previous month below as follows to avoid overlapping between 2 contracts
1st active contract end date should automatically be changed to
end date :28th feb 2017
start date should remain the same as 1 feb 2017.
basically both contracts end dates and start dates shouldnt fall in same range to avoid overlapping
Help me how to achieve this
Thanks in advance
You need to write a trigger to achieve the said functionality.
I am not sharing code as of now, but I can guide you on how you can achieve this.
You need to follow below mentioned steps -
1. Need to write an after insert & update trigger
2. In trigger while insert or update you need to check that is there any contract with in the same period -
For ex - you are inserting ABC Contract with Start Date - 1st Feb 2017 & End Date - 31st March. So you need to check that is there any contracts which fall into the same date range using SOQL
3. Depending on the results you will get by performing operation as mentioned in step 2 you need to change the dates of the contracts
Note - It will be difficult to manage this scenario via code, because some or the other use case will always fail in this requirement as far as I can imagine this. I would suggest you that it should be handled by user itself, code should be responsible only to inform the users that there are contracts with some oevrlapping dates, so that user can navigate through those manually and can change those. I feel this option will be better.
Hope this helps you to solve your problem.
Thanks,
Mustafa Jhabuawala
Technical Lead at Zen4orce (http://www.zen4orce.com)
Thanks
use below code,
Thank you,
Amol Salve
Salesforce Developer
I tried the above code , I am getting the following error on save
Error: Compile Error: unexpected syntax: 'mismatched input ',' expecting MAPPED_TO' at line 18 column 11
actually I had done small mistake..please use this map insted of this
there is syntax error at last line
thank you
Amol Salve
Salesforce Developer
Error: Compile Error: unexpected token: '}' at line 18 column 18
Line 18 is
12 =>31, };
Error: Compile Error: unexpected token: '}' at line 18 column 18
Please help me bro
Please remove comma from after 31 from this line12 =>31, };