Setting field value rule for Date/Time field tyoe

Forums General discussion Setting field value rule for Date/Time field tyoe

This topic contains 1 reply, has 2 voices, and was last updated by  Alexander Bautz 1 week, 1 day ago.

  • Author
    Posts
  • #24752

    Scott Van Eerden
    Participant

    Hi Alexander,

    In DFFS, I have a rule that’s using the [today] value to populate a date/time column upon form load. I have been able to add days to that value (ex: [today]+3) to return the value 3 days from today, but I have not been able to figure out how to set the value with [today] plus 4 hours, for example. I’ve tried everything I can think of and have researched solution upon solution, but have been able to figure it out.

    Do you have any ideas on how I could set this up?

    Thank you

  • #24754

    Alexander Bautz
    Keymaster

    Hi,
    Unfortunately the Set field value function in the rule cannot set the time part so you must use some Custom JS. Just add this function to your Custom JS:

    function setDateColPlus4Hours(){
    	var dateVal = new Date();
    	dateVal.setHours(dateVal.getHours() + 4);
    	spjs.utility.setDateFieldFromDateObject("DateColumnName",dateVal,0);
    }

    Change DateColumnName to match your field name and insert the function name setDateColPlus4Hours in the Run these functions / trigger these rules field in your rule.

    Alexander

You must be logged in to reply to this topic.