Using a Before trigger/ Workflow has not helped me fill in or provide a default value to a standard field(NAME) while saving a new record.
I was asked to build a Visual force page and then override the 'NEW' button to add a default value to the token field, type Name, which will then allow to save a record.
Visual force page code used to override 'NEW':
<apex:page standardController="Certification__c"
action="{!URLFOR($Action.Certification__c.New, NULL, ['Name'='DoNotEdit'], true)}"/>
My 'NEW' button before overriding:
My 'NEW' button after overriding.
My Contact look-up field value tends to disappear after i override the new button page. Token is the standard field, type Name. My 'Cancel' button is also not working after the override.
How can i bring everything from the default page, but only add a default value to the token(Name) field.
UPDATE - explained further
Field Label = Token, Field Type = Name, Data Type = Text(80), Indexed, required (cannot be empty)
Name field is required in order to save the record, hence a before trigger won't work here. Name type fields don't take default values and is always a required/mandatory field. So the field Token is a 'text' field which goes like contact.Name, account.Name etc..(goes by .Name) This type of field requires a value upon saving. you cannot also provide a default value. I tried using a workflow, or a before trigger. But these work only after the record is saved but not just before it is saved. I want my user to not input this token every time they create a new record, but pull the value from it's parent object field.
SOLVED: As Brian suggests below, I created a new button. You can use this link URL Hacks My final button URL looks as follows (note always have the retURL or return url) :
/a09/e?CF00NE0000004Nt36={!Contact.Name}&CF00NE0000004Nt36_lkid={!Contact.Id}&Name={!Contact.C_Token__c}&retURL=/{!Contact.Id}
URLFOR
parameters and options. You should be able to set the Contact ID as a parameter in theURLFOR
, as well as a return URL when you press the cancel button.