You need to sign in to do that
Don't have an account?
Puneeth Kumar
How to Enable or disable a onclick js button on certain criteria.
Hi All,
I have constructed a button "Request portal access" which is onclick javascript button on detail page. Associated an apex class where it checks the logic "if contact record has 'Portal access' flag uncheck, then check it and make button disable". How can I implement in my code for Disable of that button. And also another button "Reject Portal Access" where on clicking it unchecks the flag and button gets disabled.
While executing the logic either of the buttons should not be disabled or enabled at the same time, cause it is like contradiction. How can I execute this behaviour in my code for the button?
Please advise
Thanks
Puneeth
I have constructed a button "Request portal access" which is onclick javascript button on detail page. Associated an apex class where it checks the logic "if contact record has 'Portal access' flag uncheck, then check it and make button disable". How can I implement in my code for Disable of that button. And also another button "Reject Portal Access" where on clicking it unchecks the flag and button gets disabled.
While executing the logic either of the buttons should not be disabled or enabled at the same time, cause it is like contradiction. How can I execute this behaviour in my code for the button?
Please advise
Thanks
Puneeth
can u add ur code!
You can write functions like below
I suggest you refer below post which has a similar discussion.
http://stackoverflow.com/questions/11112537/disable-button-onclick-but-enable-another-button (http://stackoverflow.com/questions/11112537/disable-button-onclick-but-enable-another-button)
Please let us know if this helps you.
Thanks and Regards
Sandhya
Thanks for your suggestion Sandhya. Here is my code how can I redesign please suggest.
Onclick JS Button
-------------------------
{!REQUIRESCRIPT("/soap/ajax/25.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/25.0/apex.js")}
var agree = confirm("Are you sure you want to give Portal access to this contact?");
if(agree){
var result = sforce.apex.execute("DssPortalAccess","CheckDssPortalAccess",{ContactId:"{!Contact.Id}"});
if(result == 'true'){
alert('This contact already has Portal access');
}else{
alert('This contact is given access to Portal now');
}
}
Here is my Class Dssportalaccess
------------------------------------------------------
global class DssPortalAccess {
webservice static boolean CheckDssPortalAccess(ID ContactId){
Boolean DssFlag;
List<boolean> bol = new list<boolean>();
contact con = [SELECT Id, name,Email,DSS_Portal_Access__c FROM contact WHERE Id=:ContactId];
List<Contact> con1 = [SELECT Id, name,Email,DSS_Portal_Access__c FROM contact WHERE Email=:con.Email];
DssFlag = con.DSS_Portal_Access__c;
for(contact con2 : con1){
if(con2.DSS_Portal_Access__c == true){
bol.add(true);
}
}
if(bol.isEmpty()== True && DssFlag == false){
con.DSS_Portal_Access__c= true;
update con;
}
else{
DssFlag= true;
}
return DssFlag ;
}
}