Custom Detail Button using @remoteAnnotation and navigation to updated record in Salesforce1

Custom detail buttons failed update the field and navigate back to the record detail page in salesforce 1. If you wants to make it work , you need to implement @remoteAnnotation.

Code follows as below.

<apex:page standardController="Opportunity" extensions="CallDetails">


<apex:form >
<script src="/soap/ajax/29.0/connection.js"></script>
<script type='text/javascript' src='/canvas/sdk/js/publisher.js'/>
<script src="https://mobile1.t.salesforce.com/soap/ajax/30.0/connection.js" type="text/javascript" />
<script type="text/javascript">

window.onload=function(){
Visualforce.remoting.Manager.invokeAction(
        '{!$RemoteAction.emailOperations.sendEmailSF2}',
        '{!Opportunity.Id}',
          function(result, event) {
            if (event.status) {
                //do whatever rendering of the list you want
            } else if (event.type === 'exception') {
                //handle errors
            } else {
                //handle unknown responses
            }
        },
        {escape: true}
    );
if(typeof sforce != 'undefined'&&sforce != null ) {  alert('continue?');
sforce.one.back(true);
alert('continue?');
Sfdc.canvas.publisher.publish({name: "publisher.refresh", payload:{ refresh:"true"}});

}
}

</script>
</apex:form>
</apex:page>




Post a Comment

0 Comments