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

calling a function from a Button
We have a situation where we are requiring to call a function from custom button OnClick Javascript. The function is located in utility class we created.
Whenever the button is pressed, we get a message stating that 'SysUtil is not defined'. SysUtil is the class we created.
I am assuming either I am just not using the proper sytax (very likely as I am very new to this langauge, and to Java as well) or its just not possible. Any help is greatly appreciated.
{!REQUIRESCRIPT("/soap/ajax/14.0/connection.js")}
var recordsId = {!GETRECORDIDS( $ObjectType.Address__c )};
var GetUserInfoResult=sforce.connection.getUserInfo();
if(recordsId[0] == null)
{
if (GetUserInfoResult.userLanguage == 'fr') {
alert('SVP faites une sélection');
}
else
{
alert("Please select at least one address record to create a new pickup request.")
}
}
else if(recordsId.length > 1){
if (GetUserInfoResult.userLanguage == 'fr')
{
alert('Pour cloner une adresse, SVP faites seulement une sélection.');
}
else
{
alert("Please select only one address record to create a new pickup request.")
}
}
else if(SysUtil.isAddressScheduledForDeletion(recordsId[0]))
{
alert('This address cannot be used to create a pickup request as it is marked for deletion. Please choose another.');
}
else
{
parent.window.location.href = '/apex/vf_pickupRequest?addressid='+recordsId;
}
If I understand the question correctly it is possible to call an Apex (webservice) method from a custom button that executes javascript. The instuctions are in the Developer's Guide: http://www.salesforce.com/us/developer/docs/apexcode/index_Left.htm#StartTopic=Content%2Fapex_and_ajax.htm|SkinName=webhelp
Hope that helps.
All Answers
If I understand the question correctly it is possible to call an Apex (webservice) method from a custom button that executes javascript. The instuctions are in the Developer's Guide: http://www.salesforce.com/us/developer/docs/apexcode/index_Left.htm#StartTopic=Content%2Fapex_and_ajax.htm|SkinName=webhelp
Hope that helps.