Not signed in (Sign In)

Vanilla 1.1.5a is a product of Lussumo. More Information: Documentation, Community Support.

    • CommentAuthorcraigh
    • CommentTimeDec 24th 2009
     
    Is there a way to have the date (when the survey was filled out) automatically calculated and stored as a field on the survey?
    • CommentAuthordbuschho
    • CommentTimeDec 28th 2009
     
    If you are wanting to only collect it for your own reference, putting:
    Date()
    will give you the standard javascript date string, something like:
    "Mon Dec 28 2009 11:16:03 GMT-0600 (Central Standard Time)"

    For anything beyond that, you would need a custom function in the custom code block, that you then call in the formula section of your form, such as (this formats to Salesforce's expected format):

    <script>
    function sf_date(){
    var now = new Date();

    var dy = now.getDate();
    var mo= now.getMonth()+1;
    var yr = now.getFullYear();

    var ind = "AM";
    var hr = now.getHours();
    if(hr >= 12){
    ind = "PM";
    hr = hr - 12;
    }
    if(hr == 0){
    hr = 12;
    }
    var min = now.getMinutes();
    if(min < 10){
    min = String.concat("0",min);
    }

    return mo+"/"+dy+"/"+yr+" "+hr+":"+min+" "+ind;
    }
    </script>

    Then add the following formula to the fields you wish to have Salesforce formatted current dates:
    sf_date()

    Let me know if you need further assistance,
    FA Support.