2

I'm missing something simple here probably, but it's escaping me.

FormToUpdate.set("RETURNFUNDS_Sales_Rep_Signature_Date__c", {!today()} ); 

I've tried now() and today() above at the end, and it's failing. What can I put in lieu of that to simply stamp that field with the current date?

EDIT - Screenshot of error:

enter image description here

EDIT 2 for @techtrekker:

enter image description here

EDIT 3 - Solution Code (thanks @techtrekker for the assist)

var padmonth = {!MONTH(TODAY())};
if( padmonth.toString().length == 1 ) { padmonth = '0'+padmonth } 
var padday = {!DAY(TODAY())};
if( padday.toString().length == 1 ) { padday = '0'+padday } 
   ........
FormToUpdate.set(  "RETURNFUNDS_Sales_Rep_Signature_Date__c"  , '{!YEAR(TODAY())}-' + padmonth + '-'+ padday  ); 

1 Answer 1

3

{!TODAY()} will yield

Wed Apr 10 00:00:00 GMT 2013

{!NOW()} will yield

Wed Apr 10 20:07:18 GMT 2013

Neither of which will count as valid dates probably when passing to a webservice ?

{!DAY(TODAY())}/{!MONTH(TODAY())}/{!YEAR(TODAY())}

will yield

10/4/2013

Not a 100%, but you might also be able to leverage some Javascript Date Formatting functions.

Please try YYYY-MM-DD

{!YEAR(TODAY())}-{!MONTH(TODAY())}-{!DAY(TODAY())}

Just for display, you can also use

<apex:outputText value="{0,date,yyyy-MM-dd}">
        <apex:param value="{!TODAY()}" /> 
 </apex:outputText>

which renders

2013-04-10

8
  • FormToUpdate.set( "RETURNFUNDS_Sales_Rep_Signature_Date__c" , "{!DAY(TODAY())}/{!MONTH(TODAY())}/{!YEAR(TODAY())}" ); --- without added quotes, same error.. WITH added quotes, new error (will add to Question). Logical solution, but.. (?!)
    – AMM
    Commented Apr 10, 2013 at 20:18
  • Tried both double and single quotes, same error.
    – AMM
    Commented Apr 10, 2013 at 20:20
  • @AMM Added an edit - please try with YYYY-MM-DD format, which is likely the expected soap date format Commented Apr 10, 2013 at 20:25
  • Tried it. Same error (with expected y/m/d reference).
    – AMM
    Commented Apr 10, 2013 at 20:25
  • 1
    Got it... added a "var padmonth = [ref]" then checked length and added "0" to front of it, and used it in the date. Works like a charm. Thanks, @techtrekker.
    – AMM
    Commented Apr 10, 2013 at 20:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .