You need to sign in to do that
Don't have an account?
Which trigger event do I use to default a field on the edit page?
trigger setOriginTrigger on Case (before insert) {Case[] accs = Trigger.new;setOrigin.addOrigin(accs);}
public class setOrigin { public static void addOrigin(Case[] accs){ for (Case c:accs){ if (c.Origin != 'Customer Portal') { c.Origin = 'Customer Portal' ; } } } static testMethod void runPositiveTest() { string mySubject = ''; string validateNewSubject = 'Customer Portal'; System.debug('Create test case and insert it into the database'); Case c = new Case(Subject = '', Due_Date__c = System.today(), new_subject__c = 'Customer Portal' ); insert c; for(Case c1: [select Subject, new_subject__c from Case where Due_Date__c = TODAY and Subject = null ] ) { mySubject += c1.new_subject__c; } System.assertEquals(validateNewSubject, mySubject); } }
Thank you.
You can't do this using a trigger. The insert trigger is only fired when the user clicks the save button. The before insert trigger does not fire when the new button is clicked.
You can achieve setting a field to a certain value overwritting the "New" button using a s-control where you call an url where the parameter is set.
All Answers
You can't do this using a trigger. The insert trigger is only fired when the user clicks the save button. The before insert trigger does not fire when the new button is clicked.
You can achieve setting a field to a certain value overwritting the "New" button using a s-control where you call an url where the parameter is set.
How would one do this based on a selected record type?
For example, I have a lead record type "Individual" and I'd like to pre-load the value of "Invidual" in the required "Company' field.
Thanks.