function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Mack DsozaMack Dsoza 

Please explain me error

14:48:14.241 (241756000)|SYSTEM_METHOD_EXIT|[466]|Decimal.doubleValue()

14:48:14.241 (241551000)|METHOD_ENTRY|[460]|01pN00000004EQf|GoalMappingBean.populateGoalAseetMapping(Object, String, String, String, Double, Double, Integer, Integer, String, String, Double, Double, Double)
14:48:14.241 (241695000)|SYSTEM_METHOD_ENTRY|[466]|Decimal.doubleValue()
14:48:14.241 (241733000)|EXCEPTION_THROWN|[466]|System.NullPointerException: Attempt to de-reference a null object 
Bramha1Bramha1

You are referencing a null object some where else. Means you havent got that object and ur trying to use it.

 

Quick Note: If you could send me the whole i would solve your problem. 

 

 

Cheers

 

Bramha

Mack DsozaMack Dsoza

GoalAssetAssociation__c goalAssetAssociation;

goalAssetAssociation = goalAssetMappingMap.get(detailedBean.assetId).get(mapping.goalId);

 

Please expalain me this two line bcoz I checked my code & goalAssetAssociation is not fetching value..

So plz explain me this so i can check that one...

Devendra NataniDevendra Natani

As per your code you have two maps.

 

goalAssetMappingMap.get(detailedBean.assetId)

This returns a map and you are again fetching the value from that map by "mapping.goalId"

 

Are you sure both maps have values for the keys which you have given? Please check for the key from map 

 

"map.containskey(key)" before fetching the value.

 

Please let me know if there is any issue.

 

Thanks,
Devendra Natani 

Bramha1Bramha1

Hi,

 

  I am sure where your error is with this 2 lines of code. I am sorry for that. Is it you who has written this code or any one else ?

 

 

try this

 

GoalAssetAssociation__c goalAssetAssociation = new GoalAssetAssociation__c ();

goalAssetAssociation = goalAssetMappingMap.get(detailedBean.assetId).get(mapping.goalId);

 

If not post the whole code so that any one here can have a look where the problm lies.

 

 

Cheers

 

Bramha

 

 

 

 

Mack DsozaMack Dsoza

As I putted two line of code & in that it is calling method whose definition is here...

public Map<ID,Map<ID,GoalAssetAssociation__c>> getAssetGoalAssociationMaps(String entityId) 
{       
	Map<ID,GoalAssetAssociation__c> goalAssetAssociationByGoal = new Map<ID,GoalAssetAssociation__c>();
Map<ID,Map<ID,GoalAssetAssociation__c>> goalAssetAssociationByAsset = new Map<ID,Map<ID,GoalAssetAssociation__c>>();
        
     try {
          List<GoalAssetAssociation__c> goalAssetAssociationList = databaseObj.getGoalAssetAllocationList(entityId);
                            
          for(GoalAssetAssociation__c goalAssetAssociation : goalAssetAssociationList) {
              goalAssetAssociationByGoal = goalAssetAssociationByAsset.get(goalAssetAssociation.asset__c);
              if(goalAssetAssociationByGoal == null) {
                  goalAssetAssociationByGoal = new Map<ID,GoalAssetAssociation__c>();         
                  goalAssetAssociationByAsset.put(goalAssetAssociation.asset__c,goalAssetAssociationByGoal);
              }
        goalAssetAssociationByGoal.put(goalAssetAssociation.goal__c,goalAssetAssociation);                          
      }
    }catch(Exception ex) {
         throw new GeneralException('AssetAllocationService.getAssetGoalAssociationMaps : Internal Error ' + ex.getMessage());  
        }
      
        return goalAssetAssociationByAsset; 
    }
Please explain me this & tell me whether it will get only those values which are in query...or it might also take values from anywhere else...
Bramha1Bramha1

Hi,

 

 

List<GoalAssetAssociation__c> goalAssetAssociationList = databaseObj.getGoalAssetAllocationList(entityId);

 

this will retrieve the values you wanted as per the entityid. you get only values associated with that entityid.

 

// Here you iterate through the List what you got fro the above query 

 for(GoalAssetAssociation__c goalAssetAssociation : goalAssetAssociationList) {

 

   // Here you are checking the goalAssetAssociationByAsset  map if there is any value for asset__c and returning a  map

    goalAssetAssociationByGoal = goalAssetAssociationByAsset.get(goalAssetAssociation.asset__c);

 

// Here you are checking if the above doesnt have any value returned

if(goalAssetAssociationByGoal == null) {

goalAssetAssociationByGoal = new Map<ID,GoalAssetAssociation__c>();

 

// here you are putting an new Map into goalAssetAssociationByAsset .....is that what you want here or

 

goalAssetAssociationByAsset.put(goalAssetAssociation.asset__c,goalAssetAssociationByGoal);

// Now you are putting value into goalAssetAssociationByGoal 

goalAssetAssociationByGoal.put(goalAssetAssociation.goal__c,goalAssetAssociation);

 

 

I guess you should put the value into goalAssetAssociationByGoal  before you put the goalAssetAssociationByGoal Map into goalAssetAssociationByAsset .

 

 

Some thing like below:

 

  

try {
          List<GoalAssetAssociation__c> goalAssetAssociationList = databaseObj.getGoalAssetAllocationList(entityId);
                            
          for(GoalAssetAssociation__c goalAssetAssociation : goalAssetAssociationList) {
              goalAssetAssociationByGoal = goalAssetAssociationByAsset.get(goalAssetAssociation.asset__c);
              if(goalAssetAssociationByGoal == null) {
                  goalAssetAssociationByGoal = new Map<ID,GoalAssetAssociation__c>();    
goalAssetAssociationByGoal.put(goalAssetAssociation.goal__c,goalAssetAssociation);      
                  goalAssetAssociationByAsset.put(goalAssetAssociation.asset__c,goalAssetAssociationByGoal);
              }
                                  

 

 

Cheers

 

Bramha

Mack DsozaMack Dsoza

Please explain me this one,

On click of save button I called this save method which has code as,

 public AssetAllocationBean assetAllocationBean { get;set;}

public pageReference save(){

System.debug('Asset Allocation Bean Value : '+assetAllocationBean);

try {

service.saveAllocation(assetAllocationBean,entityId);

                assetAllocationBean = service.fetchAssetAllocationRecords(entityId);

       }

       catch(Exception ex) {

                ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,ex.getMessage()));

       }

}

While seeing in Debug log I got the error as assetAllocationBean is getting following error as follow,

DEBUG|Asset Allocation Bean Value : AssetAllocationBean:[assetMap=null, assetRecordTypeBeanList=(AssetAllocationBean.AssetRecordTypeBean]

 

here is the Bean from where this assetMap is coming...

 

public class AssetAllocationBean {

public MAP<ID,Asset__c> assetMap {

                                         get {

                                            if(assetMap == null) {

                                                    assetMap = new Map<ID,Asset__c>();                                                                                          }                                           return assetMap;                                       

                             }

                                        set;                                   

}

   }

Please tell me that what this bean will do & from where it will fetch the value....

Bramha1Bramha1

Hey posting your code bit by bit cannot be understood. If it is possible for you, please try to post the entire class and the related classes associated to it. This makes it easy for others to check it and give you proper solution.

 

Cheers

 

Bramha