You need to sign in to do that
Don't have an account?

Email is triggered when i hit clone button
Hi All,
I am creating a custom clone button on account. this is my VF page and controller. Button works fine but the issue is :
we have workflow rules that send an email as soon as record is created...when i hit clone the email is triggered...and when i hit save the email goes out again...I want email to go out only when i hit save.....please help
I am creating a custom clone button on account. this is my VF page and controller. Button works fine but the issue is :
we have workflow rules that send an email as soon as record is created...when i hit clone the email is triggered...and when i hit save the email goes out again...I want email to go out only when i hit save.....please help
<apex:page standardController="Account" extensions="AccountController" action="{!autoRun}"> <apex:sectionHeader title="Auto-Running Apex Code"/> <apex:outputPanel > You tried calling Apex Code from a button. If you see this page, something went wrong. You should have been redirected back to the record you clicked the button from. </apex:outputPanel> </apex:page>
public with sharing class AccountController { public Account objAccount {get;set;} public string AccountID; private Account objNewAccount; Map<String, Schema.SObjectField> mapAccountFields; public AccountController(ApexPages.StandardController controller) { } public PageReference autoRun() { AccountID = ApexPages.currentPage().getParameters().get('id'); if(AccountID != null) { mapAccountFields = Schema.SObjectType.Account.fields.getMap() ; objNewAccount = [ select id,OwnerId,AccountId,Status__c from Account where id = :AccountID ] ; objAccount = objNewAccount.Account(false,true,false,false); insert objaccount; PageReference cloneaccount = new PageReference('/'+accountid+'/e?clone=1'); cloneaccount.setRedirect(true); return accountPage; } return null; } }
Please help