However, Salesforce has recently updated their documentations on how you can add your own action to these two buttons using Publisher SDK. I first saw this on Visualforce Mobile Trailhead, but they have updated Salesforce1 Mobile App Developer Guide to include it as well.
To add your own Javascript action to the "Save" button, you would first include Publisher SDK:
<!-- Publisher SDK --> <script type='text/javascript' src='/canvas/sdk/js/publisher.js'></script>
Then, you would modify following Javascript function inside your Visualforce page.
// When the panel is displayed, enable the submit button Sfdc.canvas.publisher.subscribe({name: "publisher.showPanel", onData:function(e) { Sfdc.canvas.publisher.publish( {name: "publisher.setValidForSubmit", payload: "true"}); }}); // Action to be performed when submit button is pressed Sfdc.canvas.publisher.subscribe({ name: "publisher.post", onData: function(e) { // *************************************************** // Add your own action here /* myOwnAction([params], // Callback function(error, records) { if (error) { // Do something on error } else { // Close the window Sfdc.canvas.publisher.publish( { name: "publisher.close", payload:{refresh:"true"}}); } }); */ }});
No comments:
Post a Comment