You need to sign in to do that
Don't have an account?
AlbertoEmpaua
How to call apex function from Visualforce in Salesforce1
Hi everybody,
I have the following situation, We have in our org a JS button in the layout that call a method in an apex class to send an Email. But in salesforce1 this doesnt works then what I did is create a VF with the same code as the button and calling this VF with a custom Action. Now in Salesforce1 I can see the action but the only thing that do this action is open a blank page with the name of the VF and the buttons cancel and save but doesn't execute the class.
The code in the VF page is:
Anyone can help me with this??
Thanks
I have the following situation, We have in our org a JS button in the layout that call a method in an apex class to send an Email. But in salesforce1 this doesnt works then what I did is create a VF with the same code as the button and calling this VF with a custom Action. Now in Salesforce1 I can see the action but the only thing that do this action is open a blank page with the name of the VF and the buttons cancel and save but doesn't execute the class.
The code in the VF page is:
<apex:page standardController="Invoice__c"> <apex:includeScript value="/soap/ajax/15.0/connection.js"/> <apex:includeScript value="/soap/ajax/15.0/apex.js"/> <script> var result = sforce.apex.execute('sendInvoice', 'send',{invoiceId:'{!Invoice__c.Id}'}); if(result == ''){ window.location.reload(); }else{ alert(result); } </script> </apex:page>and the class is:
global with sharing class sendInvoice { webservice static String send(ID invoiceId) { Invoice__c inv = [Select Id, Status__c From Invoice__c Where Id =:invoiceId]; if(inv != null && inv.Status__c =='Approved'){ try { //....More code here return ''; } catch(Exception e) { System.debug('@@@@ Error: ' + e); return 'Unexpected error, please contact with your Administrator'; } }else{ return 'Invoice status should be Approved'; } } }In salesforce classic this works fine but in Salesforce1 I can't find a solution.
Anyone can help me with this??
Thanks
<apex:page standardController="Invoice__c" extensions="LogicExecutionClass">
You may need to change your code since you are already in APEX, so no need to use AJAX
Thx
All Answers
<apex:page standardController="Invoice__c" extensions="LogicExecutionClass">
You may need to change your code since you are already in APEX, so no need to use AJAX
Thx