function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
EliHEliH 

Pass chosen opportunity record type into logic of custom button

I want to create one custom button that creates an opportunity from a contact record, but I want the value of the close date field to pre-fill based on the record type chosen by the user. Despite the fact that the edit page clearly shows which record type I have chosen, the URL doesn't seem to be able to pick this up. Any ideas for a workaround that doesn't involve creating separate buttons for each record type?

Here is my URL:
/setup/ui/recordtypeselect.jsp?ent=Opportunity
&opp9={!IF( CONTAINS(Opportunity.RecordType,"012U0000000QBTe"),TODAY()+90,TODAY()+60)}
PatrickSheilPatrickSheil
I think the problem is that the Opportunity record type is not actually accessible through a formula until after the new record is saved, so your IF statement is not evaluating properly. 

Does the user need to be able to modify the close date, or will it always be hard-coded to a 60 or 90 day offset depending on record type?  If it doesn't need to be modified, I suggest making the "Close Date" field read-only and calculating it using a workflow rule after the record is created.  This will allow you to access the record type of the Opportunity record using the same formula you used here.  If the user needs to modify this date, however, you could configure the workflow field update to only fire if the close date field is blank. 

Just as an additional tip, you can access the name of the record type with Opportunity.RecordType.Name, which I've found to be preferable since it is org-agnostic which will facilitate migration.  (e.g. IF( Opportunity.RecordType.Name = "Foo" , TODAY()+90, TODAY()+60 )

Let me know if I can be any more help!