You need to sign in to do that
Don't have an account?
Mack Dsoza
need Error solution
System.NullPointerException: Attempt to de-reference a null object
I am getting above error while executing the below query on system log...
GoalAssetAssociation__c a = new GoalAssetAssociation__c();
a.Goal__c = 'a0HN0000000lMhDMAU';
a.GoalYearValue__c=2015.0;
update a; OR upsert a;
GoalYearValue__c if a field of type number with numeric value of 16 & decimal value is of 2.
Please tell me how can i store value in it...Since I am getting above error....
Hi,
what datatype is the other field your are inserting. Is your Goal__c a Number data type, but your passing a string in it.
try with
GoalAssetAssociation__c a = new GoalAssetAssociation__c();
a.Goal__c = 1234;
a.GoalYearValue__c=2015.0;
insert a ;
cheers
Bramha
Actually, Goal__c is Lookup field which stores Id of my another object but in my record all values coming properly but only GoalYearValue__c is not coming bcoz of that I tried to insert value in that but I got an error which I have mentioned...
Please tell me, since it is of Type Number then why it is not accepting this value...
In Debug Log, I am getting this error ,
14:48:14.241 (241733000)|EXCEPTION_THROWN|[466]|System.NullPointerException: Attempt to de-reference a null object
Hi,
if that is a look up to another Object, you need to create the other object first and pass it id in it. Check below:
This is your Other Object:
Object1__c obj1 = new Object1__c();
obj1.FiledName__c = 'Hello' ;
insert obj1 ;
And when you come to insert your new GoalAssetAssociation__c Object ,
GoalAssetAssociation__c a = new GoalAssetAssociation__c();
a.Goal__c = obj1.Id;
a.GoalYearValue__c=2015.0;
insert a ;
You need the Lookup record to be already created and then pass the Id of the record.
Cheers
Bramha
Sorry, My apologise for mistake,
Goal__c has masterdetail relationship with my another custom object....
& whatever u are guiding me, I already tried that but still facing problem there....
Can you give me the details of the other Object as well so that i can try here and send you the code. Even though it is in Master detail relationship, it will work.
Cheers
Bramha