I have created:
- An Apex controller extension for custom Object that performs field update on the record visualized (@remote method)
- A VF page that embed JS remote invocation to Apex method
- A custom Action of type "Custom Visualforce"
I added the action on Object Page Layout and It works but when I click on the button I visualize, for a few seconds, a blank popup page like this:
This is VF page:
You know any way to perform this requirement ?Thanks in advance for your reply<apex:page standardController="Quote__c" extensions="Test4SyncController" docType="html-5.0" standardStylesheets="false" showheader="false" sidebar="false">
<script type='text/javascript' src='/canvas/sdk/js/publisher.js'></script>
<script>
UpdateAccount();
function UpdateAccount(){
aId = '<apex:outputText value="{!Quote__c.Id}"/>';
Visualforce.remoting.Manager.invokeAction('{!$RemoteAction.Test4SyncController.updateAccount}', aId,
function(result, event){;
if(event.status){
// Success - close the publisher and refresh the feed.
Sfdc.canvas.publisher.publish({name: "publisher.close", payload:{ refresh:"true"}});
} else if (event.type === 'exception'){
console.log(result);
} else {
}
});
}
</script>
</apex:page>
Since you're using LEX, you might want to consider using a Lightning Component that makes a callout to an @AuraEnabled Apex method. This Component would be held in a Visualforce page using Lightning Out. There's a blog about how to do this here. (http://www.crmscience.com/single-post/2016/08/11/Buttons-and-Actions-in-the-Salesforce-Lightning-Experience)