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

How to disable a Custom Button once it is clicked.
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.
<apex:commandButton action="{!Convert}" value="Convert" disabled="{IF(LeadObj.IsConverted==true,true,false)}"/>
Thanks ,
Regards,
Lavanya.
Hi,
Try this,
<apex:commandButton action="{!Convert}" value="Convert" rendered="{!IF(Lead.IsConverted==true,false,true)}"/>
This will remove that button from the page, if it is converted.
Hi Lavanya,
There is two ways to resolve this issue.
1) By using java script
2) By flag(boolean) variable used in apex and visualforce page.
1) Using JS, In this method put you button in <div> block. and this block is hidden by JS.
eg.
<script>
function callConvertMethod()
{
Convert();
}
function hideButton()
{
document.getElementById('{!$Component.buttonDiv}').style.display="none"; //Please enter here proper full id.
}
</script>
<Apex:actionfunction action={!convertMethod} name="Convert" oncomplete="hideButton()"/>
<div style="display:block" id="buttonDiv">
<input type="button" value="Convert" onclick="callConvertMethod"/>
</div>
2) Using flag variable, this flag variable is boolean type. You need to flag value is true at the starting then on complete of action method you can call another action method, and from this method you can set value is false of this flag variable. for hidding the button.
used this variable in command button
<apex:commandButton value="convert" onclick="ActionFunctionName" rendered="{!flag}"/>
if you find this as solution, Please mark as solution for the other help on a same query.
Thank you,
Raj Jha
I Use this always:
<apex:commandbutton value="Sample Example" onclick="disableButton(this);" onComplete="enableButton(this);" action="<Some Action method call>" rerender="<Rerender some components in page>"/>
<script language="javascript">
function disable(obj) {
if (obj) {
obj.disabled = true;
obj.style.color = '#C0C0C0';
}
}
function enable(obj) {
if (obj) {
obj.disabled = false;
}
}
</script>
Thanks & Regards,
Vivek V.
Error: Unknown property 'CustomLead__cStandardController.leadObj'.
Can anyone tell how to resole this issue
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
Hi,
Is it a out of the box page or a VF page (Page where convert button is in)??
If it is a out of the box page then you can do a javascript message on button lick.
If it is VF page You stamp a flag (isconverted) in the record where it is set when user clicks on this button first time. Then on the rendred proprtty of the Convert button refer to this field in the flag and set true/false for this rendered property.
Thanks & Regards,
Vivek V.
Gmail: vriavm@gmail.com
<apex:page standardController="CustomLead__c" cache="true" action="{!convertlead}" extensions="LeadConversion" >
<br/><br/>
<apex:messages style="color:red; font-weight:bold; text-align:center;"/>
<apex:form >
<center>
<apex:outputField value="{!CustomLead__c.Name}" rendered="false"/>
<apex:outputField value="{!CustomLead__c.CompanyName__c}" rendered="false"/>
<apex:outputField value="{!CustomLead__c.LastName_c__c}" rendered="false"/>
<apex:outputField value="{!CustomLead__c.opp_name__c}" rendered="false"/>
<apex:commandLink value="Redirect to Lead" style="color:blue; font-weight:bold;" action="{!RedirectToLead}"/>
</center>
</apex:form>
</apex:page>
In this what changes i need to do for this.
Which is the button you want to hide/disable in the above code.
I dont see your convert button.
Where is the code. In the previous post there is no convert button.
Regards,
<br/><br/>
<apex:messages style="color:red; font-weight:bold; text-align:center;"/>
<apex:form >
<center>
<apex:commandButton action="{!convertlead}" value="Convert" disabled="true"/>
<apex:outputField value="{!CustomLead__c.Name}" rendered="false"/>
<apex:outputField value="{!CustomLead__c.CompanyName__c}" rendered="false"/>
<apex:outputField value="{!CustomLead__c.LastName_c__c}" rendered="false"/>
<apex:outputField value="{!CustomLead__c.opp_name__c}" rendered="false"/>
<apex:commandLink value="Redirect to Lead" style="color:blue; font-weight:bold;" action="{!RedirectToLead}"/>
</center>
</apex:form>
</apex:page>
Hi,
Since you are using a custom object, create a custom field called isconverted(Checkbox) in that object.
Next after the account record and contact record is inserted, then in your custom functionality make this isconverted to true.
Now in your vf page
<apex:commandButton action="{!convertlead}" value="Convert" disabled="{!if(CustomLead__c.isconverted__c==true,false,true)}"/>
Regards,