You need to sign in to do that
Don't have an account?
Money Care 7
Javascript error on click custom button
Hi Friends
I have created a custom button for sending mail.but i am facing error like this
A problem with the OnClick JavaScript for this button or link was encountered:
{faultcode:'soapenv:Server', faultstring:'java.lang.NullPointerException Error Id: 165621172-94001 (-590911820)',
I have created a custom button for sending mail.but i am facing error like this
A problem with the OnClick JavaScript for this button or link was encountered:
{faultcode:'soapenv:Server', faultstring:'java.lang.NullPointerException Error Id: 165621172-94001 (-590911820)',
if({!ISBLANK(Challan__c.Accounts_Email_Id__c)}) { alert('Please Accounts email address'); } else { {!REQUIRESCRIPT("/soap/ajax/16.0/connection.js")} {!REQUIRESCRIPT("/soap/ajax/16.0/apex.js")} var msg =sforce.apex.execute("Send_Challn_To_Accounts","Send_Challn_To_Accounts",{id:"{!Challan__c.Id}"}); window.alert(msg); }
global class Send_Challn_To_Accounts { public static blob b; WebService static string Send_Challn_To_Accounts(string id) { try { Challan__c qt=[Select id,Call_up_order_id__c,Freight_Charge_Applicable_Extra__c,Challan_id__c,Basic_Price_Each_item__c,Basic_Price_per_1000__c,Accounts_Email_Id__c,Sale_Confirmation_Order_ID__c,Account_Id__c,Account_Name__c,Company_Name__c,Account_Name__r.Name,Challan_Number__c,Sale_Confirmation_Order__r.name from Challan__c where id=:id]; PageReference pdf =new PageReference('/apex/view_challan_form?scontrolCaching=1&id='+Id); pdf.setRedirect(true); if(Test.isRunningTest() == false){ b = pdf.getContent(); } //--------create a mail object to send a single email.-------- Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); string[] toaddress =String.valueOf(qt.Accounts_Email_Id__c).Split(','); mail.setToAddresses(toaddress); // mail.setToAddresses(new string[] {qt.email__c}); // Internal_Email_User_Id__c text fied mail.setBccAddresses(new String[] {'test@globalnest.com'}); mail.setBccSender(true); mail.setSenderDisplayName(qt.Account_Name__c); mail.setSubject('Challan For'+' '+qt.Company_Name__c+' : '+qt.Sale_Confirmation_Order__r.name); //------------- Create the email attachment----------------- Invoice_Dispatch_details__c invoice=new Invoice_Dispatch_details__c(); // invoice=[select id,Account_Lookup__c,Purchase_Order__c from Invoice_Dispatch_details__c where Challan__c=:id]; Messaging.EmailFileAttachment efa = new Messaging.EmailFileAttachment(); efa.setFileName('Challan.pdf'); efa.setBody(b); //----------------------------------------------------------- mail.setFileAttachments(new Messaging.EmailFileAttachment[] {efa}); mail.setPlainTextBody('Hi Accounts Team, Please find the Challan for '+qt.Company_Name__c +' '+'attached to this mail.'+'\n'+'\n'+'\n'+'\n'+'Freight Charge Applicable Extra:'+qt.Freight_Charge_Applicable_Extra__c+'\n' +'Account Name:'+qt.Company_Name__c+'\n'+'SCO no:'+qt.Sale_Confirmation_Order__r.name+'\n'+'Challan No:'+qt.Challan_Number__c+'\n'+'Basic Price (Each item):'+qt.Basic_Price_Each_item__c+'\n'+'Basic Price (per 1000):'+qt.Basic_Price_per_1000__c+'\n'+'\n'+'Thanks & Regards'+'\n'+'Care Team'); //------------------------Attach sales order to a contract-------------------- Attachment formAttach = new Attachment(); formAttach.Name = 'Challan'+qt.Account_Name__c+'.pdf'; formAttach.body = b; formAttach.ContentType='application/pdf'; formAttach.parentId =id; if (!Test.isRunningTest()) { insert formAttach; } //send the email Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail } ); return 'Challan has been sent'; } catch(exception ex) { string ex1=string.valueof(ex); return ex1; } } }
Can try renaming the method of the class to a different name?