i have a problem with a NullPointerException. It occurs only on tablets, it work without problems on smartphones.  I have identified the problem, the button newDemoAccount is null, but i don't know why. The other button addAcount works without problems. Both buttons are correct declared in the xml.          View footerView = ((LayoutInflater) this                 .getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(                 R.layout.account_list_footer, null, false);         addAccount = (Button) findViewById(R.id.account_footer_btn);         newAccount = (Button) findViewById(R.id.new_account_button);         newDemoAccount = (Button) findViewById(R.id.new_Demo_account);   Someone any idea why it don't work only on tablets?
129
What are Null Pointer Exceptions (java.lang.NullPointerException) and what causes them?  What methods/tools can be used to determine the cause so that you stop the exception from causing the program to terminate prematurely?
20439
I am trying to get this trigger to work but it is giving me an error and I am not able to figure out why. The error I am getting is "attempt to de-reference a null object)  Why trigger? We have a Destinations object which is linked to Supplier products object via a lookup relationship. There are two types of supplier products(marketplace and curated) We want to count the number of live Supplier products and put them in a separate fields(live counts for each type).  I have gotten so far to actually count the number of live products and it is giving me an error. Can any one help? I am posting the code below  Trigger code :   trigger NoOfLiveProducts on Supplier_Product__c (after insert, after Delete, after update, after undelete) {       set&lt;string&gt; destinationids = new set&lt;string&gt;();      if(trigger.isInsert) {         for(Supplier_product__c products : Trigger.new) {             destinationids.add(products.Destination__c);         }     } else if(trigger.isDelete) {         for(Supplier_product__c products : Trigger.old) {             destinationids.add(products.Destination__c);         }     }else if(trigger.isUnDelete) {         for(Supplier_product__c products : Trigger.new){             destinationids.add(products.Destination__c);         }      } else if(trigger.isUpdate) {         for(Supplier_product__c products : Trigger.new) {             destinationids.add(products.Destination__c);         }     }      if(destinationids.size() &gt; 0){         Productcounter pc = new Productcounter();         pc.updateproductCount(destinationids);     }    }   Class code :  public class Productcounter {      public void updateproductcount(set&lt;string&gt; productIDs) {           if(productIDs == null){                return;         }          if(productIDs.size() == 0){             return;         }           list&lt;Supplier_Product__c&gt; ProductList = new list&lt;Supplier_Product__c&gt;();         ProductList = [Select ID,Destination__c                     From Supplier_Product__c                     Where Destination__c = :productIDs];          integer totalCount;         map&lt;string, integer&gt; DestinationIDToProductCountMap = new map&lt;string, integer&gt;();                for(Supplier_product__c ProductItem : ProductList){             if(DestinationIDToProductCountMap.containsKey(ProductItem.Destination__c)){                 totalCount = DestinationIDToProductCountMap.get(ProductItem.Destination__c);             }else{                 totalCount = 0;             }             totalCount += 1;             DestinationIDToProductCountMap.put(ProductItem.Destination__c, totalCount);         }          list&lt;Destination__c&gt; DestinationUpdateList = new list&lt;Destination__c&gt;();         Destination__c DestinationTemp;         for(string ProductID : DestinationIDToProductCountMap.keySet()){             DestinationTemp.ID = ProductID;             DestinationTemp.No_of_Live_Curated_Products__c = DestinationIDToProductCountMap.get(ProductID);             DestinationUpdateList.add(DestinationTemp);         }         if(DestinationUpdateList.size() &gt; 0){             update DestinationUpdateList;         }           }           }
80179
i have created a trigger which creates an opprtunity when the accounte is created and i have a custom field No of contact on account which displays the count of related contact for a particular account whenever it is updated.  I have tested seperated that the opportnity is created but for the second part ,it displays a big error when i try to save a record.  I am not getting any error while saving a record.Can someone help      trigger insertOpp on Account(After insert,after update,before update) { List&lt;Opportunity&gt; opplist=new List&lt;Opportunity&gt;(); for(Account acc:Trigger.new){  Opportunity op=new Opportunity(); op.Name='Cook'; op.accountid=acc.id; op.CloseDate=System.today(); op.StageName='Qualification'; opplist.add(op); }  insert opplist;     if(trigger.isupdate) {         Integer no_of_contact;         String accID;      for(Account c:Trigger.new )     {         accid = c.id;      }      account acclist = new account();     acclist = [select No_of_Contacts__c from account where id = :accid ];     no_of_contact = [SELECT count() FROM Contact WHERE AccountId = :accid];     acclist.No_of_Contacts__c = no_of_contact;     //update acclist;  }  }   ERROR:       Review all error messages below to correct your data. Apex trigger   insertOpp caused an unexpected exception, contact your administrator:   insertOpp: execution of AfterUpdate caused by: System.DmlException:   Update failed. First exception on row 0 with id 00128000002r8gKAAQ;   first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, insertOpp: maximum   trigger depth exceeded Account trigger event AfterUpdate for   [00128000002r8gK] Account trigger event AfterUpdate for   [00128000002r8gK]
103625
Often when I am writing an answer in the Android app I need to refer back to the question to confirm a point I have read, so I click the "back to question" button at top right.  When I go back to the question a button "edit your answer draft" appears at the bottom of screen as expected.   Clicking this button often takes me to an empty answer form with my draft work lost. A further "back" click takes me back to the question with no "edit answer draft" button.  Am I doing something wrong or is this a bug in the Android app?  Equipment: Samsung Galaxy S5 phone, Android 5.0
113486
I am getting an exception of System.CalloutException: You have uncommitted work pending. Detail of the Exception is given Below:     Exception: :System.CalloutException: You have uncommitted work   pending. Please commit or rollback before calling out   I am using Apex for calling a Webservice. Based on the data returning from the WebService, performing upsert operation in Salesforce Instance. I am performing the following operation on the Salesforce Instance.  1 Performing upsert operation in Campaign Object.  2 Performing upsert Operation in Account Object.  3 Performing upsert Object in Contact Object using AccountID of the earlier inserted Account.  4 Then Adding Contacts as CampaignMember in the Campaign that I have Created earlier.  My code is working fine when There is only one record in the Webservice API but when there are more than one record in the API then getting the Exception of System.CalloutException: You have uncommitted work pending. I have spend one week but did not able to get rid off the exception.  Any help will be much appreciated.  Thanks in advance.
15754
The Edit Answer Draft button is broken.    Press Back with text in an answer box. The Edit answer draft bar does not appear.     Seems like an onBackPressed() issue.  Also:   Press ← with text in the answer box The bar appears. Click the bar The answer box is blank.   Seems like the answer isn't properly carried between the Fragments.  Either way, you lost everything you wrote.  Can somebody test this? And especially without a confirm dialog, it is a brush of the finger to lose a long post of code or something.   I hope this report will help because I like the app (I'd say 4/5 stars) but the bugs are preventing a solid 5 stars.   Stack Exchange 1.0.73 Samsung Galaxy S II Skyrocket I727 Android 4.1.2
73868
I need help. I am currently trying to test this code before uploading  public class CoreValuesExt { ApexPages.StandardController sc; public boolean readonly {get; set;} public Core_Values__c cv {get; set;} public integer countEdit = 1; public string buttonValue {get; set;} public integer recordScan;  public CoreValuesExt(ApexPages.StandardController sc) {     this.sc = sc;     cv = new Core_Values__c();     cv.Account__c = sc.getid();      readonly = true;     buttonValue = 'Edit';     recordScan = [SELECT COUNT() FROM Core_Values__c WHERE Account__c = :cv.Account__c];    if (recordScan != 0){    cv = [SELECT id, HSE__c, Professionalism_Integrity__c, Quality_Accuracy__c, Technology_Innovation__c, Timeliness__c, Value_for_money__c FROM Core_Values__c WHERE Account__c = :cv.Account__c];     }  }  public ApexPages.PageReference Save() {     return sc.Save(); }  public void ApplyAction() {     countEdit++;     Integer modolus = Math.mod(countEdit, 2);     String total = cv.HSE__c + cv.Professionalism_Integrity__c + cv.Quality_Accuracy__c + cv.Technology_Innovation__c + cv.Value_for_Money__c + cv.Timeliness__c;     if(modolus == 0)     {         readonly = false;         buttonValue = 'Save';     }     else     {         if(total != 'nullnullnullnullnullnull')            {         if (recordScan == 0){         insert cv;         readonly = true;         buttonValue = 'Edit';         }         else         {         update cv;         readonly = true;         buttonValue = 'Edit';         }         }     }    }   }  With this trigger.  trigger CoreValuesTrigger on Core_Values__c (before insert) {  Core_Values__c cvs = Trigger.new; CoreValuesExt.ApplyAction(cvs);  }   But when I try to save, I get a message saying:      Illegal assignment from List to   CoreValuesExt__Core_Values__c at line 3 column 1   "  How do I go through with this? I need help. Thanks
60323
My first post,pretty excited.I want to make a soap api call which insert multiple records. I am using 2 different salesforce instances. destination side  global with sharing class SoapDemo1 {    global class AccountWrapper    {       webservice string Name;       AccountWrapper(Account a)       {         this.Name=a.Name;       }    }     webservice static List&lt;Account&gt; CreateMultipleAccounts(List&lt;Account&gt; accs)    {        List&lt;Account&gt; FinalList=new List&lt;Account&gt;();         for(Account a:accs)        {           Account a1=new Account();           a1.Name=a.Name;            FinalList.add(a1);           }         if (FinalList.size() &gt; 0)        {           Database.Insert(FinalList);        }         return FinalList;     }     }   I generated the class wsdl file and also partner wsdl file  ****source side:**** I upload the class wsdl file generated from destination, when I parse no errors, but when I click Generated Apex code, it shows error as:     Unable to find complexType for   {}anyType    I changed anyType to string and again repeated the process but it shows error as:     Unable to find complexType for   {}JunctionIdListNames   Please help me out
120685
It seems to me that a lot of my debugging time is spent chasing down null-reference exceptions in complex statements. For instance:  For Each game As IHomeGame in _GamesToOpen.GetIterator()   Why, when I get a NullReferenceException, can I get the line number in the stack trace, but not the name of the object that equals null. In other words, why:  Object reference not set to an instance of an object.   instead of  _GamesToOpen is not set to an instance of an object.   or  Anonymous object returned by _GamesToOpen.GetIterator() is null.   or  game was set to null.   Is this strictly a design choice, meant to protect the anonymity of the code or is there a compelling reason in compiler design not to include this information in the debug-time exception?
20340
I am trying to use the "navigateToSObject" to redirect to the detail page. But the method $A.get("e.force:navigateToSObject") is always returning null. I dont have a namespace. SO this isn't namespace related issue I assume.  Here is the code of my component  &lt;aura:component &gt; &lt;aura:attribute name="contactName" type="String"&gt;&lt;/aura:attribute&gt; &lt;aura:attribute name="lastName" type="String"&gt;&lt;/aura:attribute&gt; &lt;aura:attribute name="cid" type="String"&gt;&lt;/aura:attribute&gt; &lt;div onclick="{!c.navigateToRecord}" &gt;       &lt;h1&gt;{!v.lastName}&lt;/h1&gt;     &lt;h3&gt;{!v.contactName}&lt;/h3&gt;     &lt;h3&gt;{!v.cid}&lt;/h3&gt; &lt;/div&gt; &lt;/aura:component&gt;   Here is the code of my java-script controller      ({     navigateToRecord : function(component, event, helper){         var cid=component.get("v.cid")        console.log('inside navigateToRecord '+cid);       var navEvent = $A.get("e.force:navigateToSObject");        navEvent.setParams({         "recordId": cid,            "slideDevName": "detail"     });      navEvent.fire();  } })   I am getting null in navEvent hence am not able to set parameters into it. The error is "Uncaught error in $A.run() : Cannot read property 'setParams' of null"
61737
I would like to use Class.newInstance() but the class I am instantiating does not have a nullary constructor. Therefore I need to be able to pass in constructor arguments. Is there a way to do this?
49131
I'm playing with a trigger exercise, that consists of creating a trigger to create 10 Opportunities whenever a account with more than 100 employees are created. I made the following: trigger AccountTrigger on Account (after insert) {     List&lt;Contact&gt; Contacts = new List&lt;Contact&gt;();     for (Account acct : Trigger.new){                for(integer i = 0; i &lt; 2; i++){             Contact cont    = new Contact();             cont.LastName   = acct.Name+ i;             cont.AccountId  = acct.Id;             Contacts.add(cont);         }         insert Contacts;      if (acct.NumberOfEmployees &gt; 99){         List&lt;Opportunity&gt; Opportunities = new List&lt;Opportunity&gt;();         for(integer i = 0; i &lt; 10; i++){             Opportunity opp = new Opportunity();             opp.Name        = acct.Name + i;             opp.CloseDate   = system.today()+ 30;             opp.StageName   = 'Open';             opp.AccountId   = acct.Id;             Opportunities.add(opp);         }         insert Opportunities;     }                      }  }   And I'm getting the following error: execution of AfterInsert caused by: System.DmlException: Insert failed. First exception on row 0; first error: DUPLICATES_DETECTED, Use one of these records?:  I didn't created any, or changed the dupe rule of account neither Opportuinities. Can you help me understand what kind of error is this? And how can I change the trigger to workaround it? Thanks in advance!!
10381
I'm trying to sideload an application, as seen in the picture below.    I have allowed the installation of applications from unknown applied actions in settings, but I can't seem to press the install button. The cancel button works correctly and installing applications via adb install works correctly. What's the problem?  EDIT: For those who have this problem, using ChainFire's  will correct it because the app uses hardware compositing, and Android doesn't notice a "layer" on top of the current screen.
116323
The title says it all. When I try to place the reputation widget on my home screen, I get this:  When I try again, I get this error, presumably because the Stack Exchange service has stopped.  Is this a bug? If so, where should I report it?  I am running Android 5.1 armeabi on a DigiLand DL718M tablet.
8114
I have same exception can please   The previous post issue is resolved.  Exception: :System.CalloutException: You have uncommitted work pending. Please commit or rollback before calling out  Visualforce Page   &lt;apex:page controller="Controller" action="{!init}" showHeader="false" sidebar="false"&gt;     &lt;center&gt;         &lt;apex:pageBlock title="Request Listener"&gt;&lt;/apex:pageBlock&gt;               &lt;/center&gt; &lt;/apex:page&gt;   Controller :            PUBLIC with sharing class Controller {        PUBLIC String fromNumber      = ApexPages.currentPage().getParameters().get('From');     PUBLIC String toNumber        = ApexPages.currentPage().getParameters().get('To');     PUBLIC String body            = ApexPages.currentPage().getParameters().get('Body');        PUBLIC PageReference init()     {                    System.debug('From Phone Number :' +fromNumber);         System.debug('To phone NUmber :' + toNumber);         System.debug('Message Body :' + body);          TwilioRestClient Client = TwilioAPI.getDefaultClient();                                                                SYSTEM.DEBUG('FROM AND To  Number is NOT NULL');                      String formattedNumber='+919876543210';                 IF(body != NULL)                 body = body;             ELSE                 body = '';             Case c = NEW Case (Subject = formattedNumber,Description = body,Origin = 'Phone');             INSERT c;                               Map&lt;String,String&gt; params1 = new Map&lt;String,String&gt;             {                'To'   =&gt; fromNumber,                'From' =&gt; '+1908280****',                'Body' =&gt; 'Conformation to customer'             };             TwilioMessage message = client.getAccount().getMessages().create(params1); /* Valid conformation SMS sent to the Customer.*/                                            return null ;     } }   While loin as admin then click preview on visualforce page executed but case is not created.I have checked the the debug log it throw the exception.
1271
We have a community built with custom lightning components and the locker service update is active. The onclick event has been defined on several components. The onclicks are working fine in Chrome, Firefox and IE11.   &lt;a href="" onclick="{!c.updateUser}"&gt;Save&lt;/a&gt;   There seem to be some issues in MS Edge though. When we click on an element with an onclick defined, we get the following error:     This page has an error. You might just need to refresh it. Error in $A.getCallback() [Unable to get property 'apply' of undefined or null reference] Failing descriptor: {markup://aura:html}    We have been testing on 5 different laptops. 3 of them have the error, while the other 2 don't have the issue in Edge. This was all tested in a Spring 17 sandbox. We also tested on a Winter 17 org with one of the laptops that has the issue and then everything seems to work fine.  Another test we did, was to remove all of the logic within the controller method and just have a console.log in it, but it never reached that point of the code since we didn't get the log. We also replaced the expression for the onclick with an alert, but that also doesn't work.  Does anyone have an idea how we can resolve this?
1905
I ran into an interesting (and very frustrating) issue with the equals() method today which caused what I thought to be a well tested class to crash and cause a bug that took me a very long time to track down.   Just for completeness, I wasn't using an IDE or debugger - just good old fashioned text editor and System.out's. Time was very limited and it was a school project.  Anyhow -   I was developing a basic shopping cart which could contain an ArrayList of Book objects. In order to implement the addBook(), removeBook(), and hasBook() methods of the Cart, I wanted to check if the Book already existed in the Cart. So off I go -  public boolean equals(Book b) {     ... // More code here - null checks     if (b.getID() == this.getID()) return true;     else return false; }   All works fine in testing. I create 6 objects and fill them with data. Do many adds, removes, has() operations on the Cart and everything works fine. I read that you can either have equals(TYPE var) or equals(Object o) { (CAST) var } but assumed that since it was working, it didn't matter too much.  Then I ran into a problem - I needed to create a Book object with only the ID in it from within the Book class. No other data would be entered into it. Basically the following:  public boolean hasBook(int i) {     Book b = new Book(i);     return hasBook(b); }  public boolean hasBook(Book b) {     // .. more code here     return this.books.contains(b); }   All of a sudden, the equals(Book b) method no longer works. This took a VERY long time to track down without a good debugger and assuming the Cart class was properly tested and correct. After swaapping the equals() method to the following:  public boolean equals(Object o) {     Book b = (Book) o;     ... // The rest goes here    }   Everything began to work again. Is there a reason the method decided not to take the Book parameter even though it clearly  was  a Book object? The only difference seemed to be it was instantiated from within the same class, and only filled with one data member. I'm very very confused. Please, shed some light?