1

How can I reference today's date in a URL hack?

I have a custom button that is of source content URL that is displayed on the Opportunity related list of the Account page layout. I would like to know how I can map the Opportunity Stage name to be string value: 'Opportunity for Account x - Created today' (where today returns today's date).

I don't see any merge field which I can leverage for this.

My URL hack so far is:

/006/e?retURL=%2F{!Contract.Id}&RecordType=012250000004Vbx&ctrcid={!Contract.Id}&opp3=Opportunity+for+{!Account.Name}&opp4_lkid={!Contract.AccountId}

where opp3 is the field Id for the Opportunity StageName field and where opp4_lkid is the lookup to the Account Id.

I don't see any way I can append opp3 with something like +created today+Date(Today)+ (which would return today's date), or something similar.

Thanks

2 Answers 2

2

You can use the {!TODAY} merge field.
I believe the following should work for you.

/006/e?retURL=%2F{!Contract.Id}&RecordType=012250000004Vbx&ctrcid={!Contract.Id}&opp3=Opportunity+for+{!Account.Name}+{!TODAY}&opp4_lkid={!Contract.AccountId}
0
0

I tried this solution within OnClick Javascript Custom Button code but unfortunately didn't work. If you are encountering the same issue here is what I managed to work out as the solution:

{!REQUIRESCRIPT("/soap/ajax/20.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/20.0/apex.js")}

var year = {!YEAR( Today() )};
var month = {!MONTH( Today() )};
var day = {!DAY( Today() )};

var today = month + "/" + day + "/" + year;

var link = "https://cs70.salesforce.com/a2H/e?DATE_FIELD_ID_HERE=" + today

window.location.href= link;

(The "DATE_FIELD_ID_HERE" is a placeholder for whatever your date field ID is - likely obvious, but I'm a fan of clarify : ).

You must log in to answer this question.

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