Apex Code:
global class MemberNameCheck
{
webservice static void check(ID memId)
{
Member__c mem = [SELECT Name from Member__c WHERE Id =: memId];
if(mem.Name == 'Test')
{
mem.Name = 'Test Updated';
update mem;
}
}
}
Custom button:
{!REQUIRESCRIPT("/soap/ajax/15.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/15.0/apex.js")}
var r = confirm("Are you sure want to check the name?");
if(r == true)
{
sforce.apex.execute("MemberNameCheck","check",{memId:"{!Member__c.Id}"});
location.reload(true);
}
Output:
global class MemberNameCheck
{
webservice static void check(ID memId)
{
Member__c mem = [SELECT Name from Member__c WHERE Id =: memId];
if(mem.Name == 'Test')
{
mem.Name = 'Test Updated';
update mem;
}
}
}
Custom button:
{!REQUIRESCRIPT("/soap/ajax/15.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/15.0/apex.js")}
var r = confirm("Are you sure want to check the name?");
if(r == true)
{
sforce.apex.execute("MemberNameCheck","check",{memId:"{!Member__c.Id}"});
location.reload(true);
}
Output:
Hello Magulan,As per this step here i got ErrorMessage after alert message....
ReplyDeleteA problem with the OnClick JavaScript for this button or link was encountered:
{faultcode:'soapenv:Client', faultstring:'No operation available for request {http://soap.sforce.com/schemas/package/MemberNameCheck}check, please check the WSDL for the service.', }
Did you solve this issue? if not, Please Change your Controller version 29 to 15
ReplyDeleteHello All,
ReplyDeleteI am also got this error.Please suggest me.
Hello Friend,
ReplyDeleteDo you think is possible for you to show me a simple way to post something using AJAX?
I mean, it could be a textfield. How could you execute the method of the class and then post the response on the textfield?
The idea is to not load all page, could you help me friend?
Thank you very much,
Greetings.