You need to sign in to do that
Don't have an account?

Help with creating a trigger which populates DATETIME fields with weekly dates:
Hi,
So I think I need a trigger to populate dates of Sessions.
We have a custom object called 'Sessions' (child). Sessions are created automatically (via a trigger) for a 'Course' (parent). Now depending on the value of the 'Level' field (on the Course) object, a different number of 'Sessions' are created. (There are different types of sessions, I need it to work for 'Knowledge Module Sessions')
Each of these Sessions has dates which are currently filled manually. Every single session occurs weekly (on the same day i.e every Wednesday). I need help creating a formula to calculate these date and populate them (ALL ARE DATETIME FIELD VALUES).
All dates will be populated based on the Session 1 Planned Date, here is the structure it needs to follow:
If Session Name CONTAINS 'Knowledge Module Session 2' then populate 'Session Planned Date' = Session 1 + 7
If Session Name CONTAINS 'Knowledge Module Session 3' then populate 'Session Planned Date' = Session 1 + 14
If Session Name CONTAINS 'Knowledge Module Session 4' then populate 'Session Planned Date' = Session 1 + 21
If Session Name CONTAINS 'Knowledge Module Session 5' then populate 'Session Planned Date' = Session 1 + 28
If Session Name CONTAINS 'Knowledge Module Session 6' then populate 'Session Planned Date' = Session 1 + 35
If Session Name CONTAINS 'Knowledge Module Session 7' then populate 'Session Planned Date' = Session 1 + 42
If Session Name CONTAINS 'Knowledge Module Session 8' then populate 'Session Planned Date' = Session 1 + 49
If Session Name CONTAINS 'Knowledge Module Session 9' then populate 'Session Planned Date' = Session 1 + 56
If Session Name CONTAINS 'Knowledge Module Session 10' then populate 'Session Planned Date' = Session 1 + 63
If Session Name CONTAINS 'Knowledge Module Session 11' then populate 'Session Planned Date' = Session 1 + 70
UNTIL SESSION 80.
Any help is MUCH appreciated :)
Thanks,
Natasha
So I think I need a trigger to populate dates of Sessions.
We have a custom object called 'Sessions' (child). Sessions are created automatically (via a trigger) for a 'Course' (parent). Now depending on the value of the 'Level' field (on the Course) object, a different number of 'Sessions' are created. (There are different types of sessions, I need it to work for 'Knowledge Module Sessions')
Each of these Sessions has dates which are currently filled manually. Every single session occurs weekly (on the same day i.e every Wednesday). I need help creating a formula to calculate these date and populate them (ALL ARE DATETIME FIELD VALUES).
All dates will be populated based on the Session 1 Planned Date, here is the structure it needs to follow:
If Session Name CONTAINS 'Knowledge Module Session 2' then populate 'Session Planned Date' = Session 1 + 7
If Session Name CONTAINS 'Knowledge Module Session 3' then populate 'Session Planned Date' = Session 1 + 14
If Session Name CONTAINS 'Knowledge Module Session 4' then populate 'Session Planned Date' = Session 1 + 21
If Session Name CONTAINS 'Knowledge Module Session 5' then populate 'Session Planned Date' = Session 1 + 28
If Session Name CONTAINS 'Knowledge Module Session 6' then populate 'Session Planned Date' = Session 1 + 35
If Session Name CONTAINS 'Knowledge Module Session 7' then populate 'Session Planned Date' = Session 1 + 42
If Session Name CONTAINS 'Knowledge Module Session 8' then populate 'Session Planned Date' = Session 1 + 49
If Session Name CONTAINS 'Knowledge Module Session 9' then populate 'Session Planned Date' = Session 1 + 56
If Session Name CONTAINS 'Knowledge Module Session 10' then populate 'Session Planned Date' = Session 1 + 63
If Session Name CONTAINS 'Knowledge Module Session 11' then populate 'Session Planned Date' = Session 1 + 70
UNTIL SESSION 80.
Any help is MUCH appreciated :)
Thanks,
Natasha
Use CASE function in the formula and try