Dependent Dates


I need help setting dates to automatically fill in once I fill in "required" dates that I've created.

I have several dates dependent on several other dates/events.

For example, let's say my main event happens on 1/10/2014. Now, say I have events that now should fill in with automatic dates from that original date. Let's say one event is that main event date - 10 days and the second event is 10 after the main event date. So, they automatically should fill in to being 12/31/2013 and the other should go to 1/21/2014.

More complex, is that those date calculations can change based on the TYPE of main event. So, for example, I'll have two choices for main event: Hot and Cold

Well, on Hot, I need the prior dates to be or - 10 and with Cold, I need the dates to be or - 23 or something.

How can I get that all to work??
Parents

  • You'll need to use a custom form if you want this to happen dynamically (as user is entering Main Event Date).

    Add an Action:

    When Main Event Date field changes value Then execute {some JavaScript}.

    The Javascript to execute might look like this. I only did the "Before" field but you'll probably get the picture. Watch out for GetSatisfaction wrapping lines at exactly the wrong place :-(



    // POC for:

    // http://communities.serena.com/serena/topics/dependent_dates

    // Current value of the Main Event field.

    var dat_MainEventDate = GetFieldValue('Main Event Date') ;

    if (dat_MainEventDate) {

    // # of days to add to Main Event date

    // depend on the Main Event type.

    // Use a data-driven approach instead

    // of a bunch of if/then/else stuff.

    var obj_EvtOffset = {

    'hot': {Before:-10 , After: 10} ,

    'cold': {Before:-23, After: 23} ,

    'default': {Before:0, After:0}

    } ;

    // The determining factor. If field is empty

    // 'default' is returned, so use the 'default'

    // entry from the lookup table.

    var str_MainEventType =

    GetFieldValue('TITLE','default').toLowerCase() ;

    var dat_Before ;

    // msec per day = 60 * 60 * 24 * 1000 = 86400000

    // If Main Event Type is found in the lookup,

    // do the math
Reply

  • You'll need to use a custom form if you want this to happen dynamically (as user is entering Main Event Date).

    Add an Action:

    When Main Event Date field changes value Then execute {some JavaScript}.

    The Javascript to execute might look like this. I only did the "Before" field but you'll probably get the picture. Watch out for GetSatisfaction wrapping lines at exactly the wrong place :-(



    // POC for:

    // http://communities.serena.com/serena/topics/dependent_dates

    // Current value of the Main Event field.

    var dat_MainEventDate = GetFieldValue('Main Event Date') ;

    if (dat_MainEventDate) {

    // # of days to add to Main Event date

    // depend on the Main Event type.

    // Use a data-driven approach instead

    // of a bunch of if/then/else stuff.

    var obj_EvtOffset = {

    'hot': {Before:-10 , After: 10} ,

    'cold': {Before:-23, After: 23} ,

    'default': {Before:0, After:0}

    } ;

    // The determining factor. If field is empty

    // 'default' is returned, so use the 'default'

    // entry from the lookup table.

    var str_MainEventType =

    GetFieldValue('TITLE','default').toLowerCase() ;

    var dat_Before ;

    // msec per day = 60 * 60 * 24 * 1000 = 86400000

    // If Main Event Type is found in the lookup,

    // do the math
Children
No Data