2

Hi I am having a custom button"Convert", I need to disable this button once it has clicked. Kindly anyone tell how resolve this either by apex code & Visualforce code. Kindly reply me to resolve this issue.

Thanks , Regards, Lavanya.

1

If you wanna disable by using Visualforce page.This code may help you

<apex:page >
    <apex:form >
    <apex:pageblock >
        <apex:actionStatus id="disablebtn">
     <apex:facet name="stop">     
           <apex:commandButton action="{!save}" status="disablebtn" value="Save" disabled="false"     rerender="mySaveStatus"/>     
     </apex:facet>     
     <apex:facet name="start">
      <apex:commandButton action="{!save}" status="disablebtn" value="Processing..." disabled="true"/>                  </apex:facet>
</apex:actionStatus>
</apex:pageblock>
    </apex:form>
</apex:page>
1

It sounds like you have a custom button that you've hooked up to a visualforce page that you'd only like to display on the page layout until it's been clicked.

Currently you're limited in that buttons can't be put on the page layout in a disabled method. I see two options for you.

First, you could update the visualforce page so it errors if clicked twice. A simple message to the effect of "Record already converted" should suffice. However the button would still be clickable.

Second, you can use a record type change to switch the page layout shown. In the second page layout you can remove the Convert button so it's not visible. Your convert page can handle the record type conversion, or you could use workflow to make the switch.

0

If it is a button with Content Source OnClick JavaScript - i would try to add this javascript code to the end of the main code:

this.disabled = true;
this.className = "btnDisabled";
  • Hi, thanks for the reply.In this button Content Source=visualforce page. This button is similar as convert button in lead. Once it has convert into account, contact. It should not able to do again. this is my requirement. – Lavanya Sanathkumar Apr 8 '13 at 11:22
  • @LavanyaSanathkumar So after clicking on your button the user will be redirected to another custom visualforce page. Just give the user notice on this page (apex:pageMessage) that the required action has been done and can not be executed again, hide all input elements and show just one "Back" button. – Sergej Utko Apr 8 '13 at 11:29
  • @LavanyaSanathkumar You must edit your visualforce page and it controller to check whether the current object was converted or not. – Sergej Utko Apr 8 '13 at 11:37
  • I am having a custom button "convert" once i click that that button i will create an account & contact. Then once again i went to the same record now i want the convert button show be disable because that record already convert.can anyone tell how resolve this. – Lavanya Sanathkumar Apr 9 '13 at 3:46
0

It sounds as though you need to have your controller look to see if the new object has been created, then add boolean logic which if True disables the button and if False enables it. If for example this is a Lead that you're converting, you'd want to add something like this to your controller:

Boolean bttndisabled;
If(this.Lead.IsConverted = True){ 
  bttndisabled=true;
}else { 
  bttndisabled=false;
}

If you're querying the Lead each time the page is updated, then you'd could replace this.Lead.IsConverted with queryresults.Lead.IsConverted. It all depends on how your controller is designed and how your passing the values to it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.