You need to sign in to do that
Don't have an account?
Ankit Chauhan 10
How to pass the sObject to Apex webService method using custom button javaScript 'onClick' section
Hi All,
I'm a novice to salesforce and facing some technical hiccups while implementing the custom button javascript onClick section. My problem statement is-
1. I have created a custom button for lead SO.
2. I will add this custom button on the Lead page layout (New).
3. When user creates a new Lead and click on this custom button, I would like to validate the email address what user has entered on the lead page.
4. I need to know in Javascript as to how to pass the sObject to the Apex- Webservice method, so that I can retrieve the email address. Also post verification I can update the same on the lead page. Please mind that the new record is still not saved.
5. Post validation user can click on SAVE button on Lead page and save the record.
Please note that this is a non-override approach.
Any help please?
I'm a novice to salesforce and facing some technical hiccups while implementing the custom button javascript onClick section. My problem statement is-
1. I have created a custom button for lead SO.
2. I will add this custom button on the Lead page layout (New).
3. When user creates a new Lead and click on this custom button, I would like to validate the email address what user has entered on the lead page.
4. I need to know in Javascript as to how to pass the sObject to the Apex- Webservice method, so that I can retrieve the email address. Also post verification I can update the same on the lead page. Please mind that the new record is still not saved.
5. Post validation user can click on SAVE button on Lead page and save the record.
Please note that this is a non-override approach.
Any help please?
Javascript:
{!REQUIRESCRIPT("/soap/ajax/30.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/30.0/apex.js")}
var myvar = sforce.apex.execute("InteractiveEmailAddressVal", "validateEmailAddressRT", {i_sObj: {!lead}});
Apex-Webservice method
global class InteractiveEmailAddressVal{
webService static String validateEmaiAddressRT(SObject i_sObj)
{
Lead lead = i_sObj;
String emailValiadted = validateEmail(lead.Email);
//update the record
lead.Email = emailValiadted;
return '';
}
}
Is there any other better way to achieve this?