You need to sign in to do that
Don't have an account?
Sergio Mac-Intosh
Error on Function for chatter actions
Hi People,
I got a function which creates an attachment on a visualforce page. The functionality is working when i call the button from a apex button.
Now i overwrite the chatter save button to get the functionality on this button. When i use this button i get the error:
An error has occurred {faultcode:'UNKNOWN_EXCEPTION', faultstring:'UNKNOWN_EXCEPTION: Site under construction', }
The javascript code of the function is:
Anyone got any idea?
I got a function which creates an attachment on a visualforce page. The functionality is working when i call the button from a apex button.
Now i overwrite the chatter save button to get the functionality on this button. When i use this button i get the error:
An error has occurred {faultcode:'UNKNOWN_EXCEPTION', faultstring:'UNKNOWN_EXCEPTION: Site under construction', }
The javascript code of the function is:
<script> Sfdc.canvas.publisher.subscribe({name: "publisher.showPanel", onData:function(e) { Sfdc.canvas.publisher.publish({name:"publisher.setValidForSubmit", payload:"true"}); }}); Sfdc.canvas.publisher.subscribe({ name: "publisher.post", onData:function(e) { uploadFile(); }}); </script> <script> function uploadFile() { $('#working').toggle(); sforce.connection.sessionId = "{!$Api.Session_ID}"; var cost = document.getElementById('costs').value; var details = document.getElementById('details').value; var input = document.getElementById('file-input'); var parentId = 'a5ZL00000000CF7'; var filesToUpload = input.files; if(filesToUpload.length == 0){ alertify.error('No Attachment Found') $('#working').toggle(); } for(var i = 0, f; f = filesToUpload[i]; i++) { var reader = new FileReader(); // Keep a reference to the File in the FileReader so it can be accessed in callbacks reader.file = f; reader.onerror = function(e) { switch(e.target.error.code) { case e.target.error.NOT_FOUND_ERR: alertify.error('File Not Found!') $('#working').toggle(); break; case e.target.error.NOT_READABLE_ERR: alertify.error('File is not readable') $('#working').toggle(); break; case e.target.error.ABORT_ERR: break; // noop default: alertify.error('An error occurred reading this file.') $('#working').toggle(); }; }; reader.onabort = function(e) { alertify.error('File read cancelled') $('#working').toggle(); }; reader.onload = function(e) { var att = new sforce.SObject("Attachment"); att.Name = this.file.name; att.ContentType = this.file.type; att.ParentId = parentId; att.Description = 'Prijs:' + cost + '-Omschrijving:' + details; att.Body = (new sforce.Base64Binary(e.target.result)).toString(); sforce.connection.create([att], { onSuccess : function(result, source) { if (result[0].getBoolean("success")) { console.log("new attachment created with id " + result[0].id); alertify.success('Nieuwe onkosten zijn toegevoegd') setTimeout(closeAction, 3000); } else { console.log("failed to create attachment " + result[0]); } }, onFailure : function(error, source) { alertify.error("An error has occurred " + error) console.log(error); $('#working').toggle(); } }); }; reader.readAsBinaryString(f); } } function closeAction() { Sfdc.canvas.publisher.publish({name: "publisher.close", payload:{ feed:"true", refresh:"true"}}); } </script>
Anyone got any idea?