RecordType.Name Visibility
Clash Royale CLAN TAG#URR8PPP
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;
up vote
2
down vote
favorite
I am going slightly crazy over here. I want to pull the RecordType.Name off of the Opportunity and write some logic depending on what the name is.
public void onlineCalculatorShortenedLink(Map<Id, FPC_Funding_del__c> newfundIds, Map<Id, FPC_Funding_del__c> oldFundIds){
if (calculatorHelperClass.firstRun) {
List<Id> fList = new List<Id>();
for (Id f : newfundIds.keySet())
I continue to get a error even though I can see with the debug that there is a value. What gives?
11:10:29.0 (111669296)|USER_DEBUG|[57]|DEBUG|calculatorHelperClass.firstRun:: true
11:10:29.0 (140108821)|USER_DEBUG|[58]|DEBUG|trigger new AND old:: ....too much data to include in this post....
11:10:29.0 (140428329)|USER_DEBUG|[63]|DEBUG|f:: a0Dm0000004bPSmEAM
11:10:29.0 (140767494)|SOQL_EXECUTE_BEGIN|[64]|Aggregations:0|SELECT RecordTypeId, RecordType.Name FROM Opportunity WHERE Id = :tmpVar1
11:10:29.0 (144891311)|SOQL_EXECUTE_END|[64]|Rows:1
11:10:29.0 (145131119)|USER_DEBUG|[66]|DEBUG|recordtypename:: (Opportunity:RecordTypeId=01280000000BZwlAAG, Id=006m00000093pC0AAI), Working Capital Oppty
11:10:29.0 (145255596)|SYSTEM_MODE_EXIT|false
11:10:29.0 (145541450)|FATAL_ERROR|System.NullPointerException: Attempt to de-reference a null object
apex opportunity permissions record-type record
 |Â
show 1 more comment
up vote
2
down vote
favorite
I am going slightly crazy over here. I want to pull the RecordType.Name off of the Opportunity and write some logic depending on what the name is.
public void onlineCalculatorShortenedLink(Map<Id, FPC_Funding_del__c> newfundIds, Map<Id, FPC_Funding_del__c> oldFundIds){
if (calculatorHelperClass.firstRun) {
List<Id> fList = new List<Id>();
for (Id f : newfundIds.keySet())
I continue to get a error even though I can see with the debug that there is a value. What gives?
11:10:29.0 (111669296)|USER_DEBUG|[57]|DEBUG|calculatorHelperClass.firstRun:: true
11:10:29.0 (140108821)|USER_DEBUG|[58]|DEBUG|trigger new AND old:: ....too much data to include in this post....
11:10:29.0 (140428329)|USER_DEBUG|[63]|DEBUG|f:: a0Dm0000004bPSmEAM
11:10:29.0 (140767494)|SOQL_EXECUTE_BEGIN|[64]|Aggregations:0|SELECT RecordTypeId, RecordType.Name FROM Opportunity WHERE Id = :tmpVar1
11:10:29.0 (144891311)|SOQL_EXECUTE_END|[64]|Rows:1
11:10:29.0 (145131119)|USER_DEBUG|[66]|DEBUG|recordtypename:: (Opportunity:RecordTypeId=01280000000BZwlAAG, Id=006m00000093pC0AAI), Working Capital Oppty
11:10:29.0 (145255596)|SYSTEM_MODE_EXIT|false
11:10:29.0 (145541450)|FATAL_ERROR|System.NullPointerException: Attempt to de-reference a null object
apex opportunity permissions record-type record
1
Is yourfList
initialized?
â Jayant Das
Aug 23 at 17:23
Yeah you've clearly demonstrated that you can dereference everything butflist
.
â Adrian Larsonâ¦
Aug 23 at 17:24
Also it looks like your code snippet and debug logs are a bit out of sync. Because you debug statement within the if block should have been printed before the exception. Can you confirm if this is exactly how your code looks like?
â Jayant Das
Aug 23 at 17:58
yea sorry I didn't include that in the snippet. flist is initialized. I will update with the whole code
â Olivia
Aug 23 at 18:03
You really should bulkify your queries
â Halfwarr
Aug 23 at 18:06
 |Â
show 1 more comment
up vote
2
down vote
favorite
up vote
2
down vote
favorite
I am going slightly crazy over here. I want to pull the RecordType.Name off of the Opportunity and write some logic depending on what the name is.
public void onlineCalculatorShortenedLink(Map<Id, FPC_Funding_del__c> newfundIds, Map<Id, FPC_Funding_del__c> oldFundIds){
if (calculatorHelperClass.firstRun) {
List<Id> fList = new List<Id>();
for (Id f : newfundIds.keySet())
I continue to get a error even though I can see with the debug that there is a value. What gives?
11:10:29.0 (111669296)|USER_DEBUG|[57]|DEBUG|calculatorHelperClass.firstRun:: true
11:10:29.0 (140108821)|USER_DEBUG|[58]|DEBUG|trigger new AND old:: ....too much data to include in this post....
11:10:29.0 (140428329)|USER_DEBUG|[63]|DEBUG|f:: a0Dm0000004bPSmEAM
11:10:29.0 (140767494)|SOQL_EXECUTE_BEGIN|[64]|Aggregations:0|SELECT RecordTypeId, RecordType.Name FROM Opportunity WHERE Id = :tmpVar1
11:10:29.0 (144891311)|SOQL_EXECUTE_END|[64]|Rows:1
11:10:29.0 (145131119)|USER_DEBUG|[66]|DEBUG|recordtypename:: (Opportunity:RecordTypeId=01280000000BZwlAAG, Id=006m00000093pC0AAI), Working Capital Oppty
11:10:29.0 (145255596)|SYSTEM_MODE_EXIT|false
11:10:29.0 (145541450)|FATAL_ERROR|System.NullPointerException: Attempt to de-reference a null object
apex opportunity permissions record-type record
I am going slightly crazy over here. I want to pull the RecordType.Name off of the Opportunity and write some logic depending on what the name is.
public void onlineCalculatorShortenedLink(Map<Id, FPC_Funding_del__c> newfundIds, Map<Id, FPC_Funding_del__c> oldFundIds){
if (calculatorHelperClass.firstRun) {
List<Id> fList = new List<Id>();
for (Id f : newfundIds.keySet())
I continue to get a error even though I can see with the debug that there is a value. What gives?
11:10:29.0 (111669296)|USER_DEBUG|[57]|DEBUG|calculatorHelperClass.firstRun:: true
11:10:29.0 (140108821)|USER_DEBUG|[58]|DEBUG|trigger new AND old:: ....too much data to include in this post....
11:10:29.0 (140428329)|USER_DEBUG|[63]|DEBUG|f:: a0Dm0000004bPSmEAM
11:10:29.0 (140767494)|SOQL_EXECUTE_BEGIN|[64]|Aggregations:0|SELECT RecordTypeId, RecordType.Name FROM Opportunity WHERE Id = :tmpVar1
11:10:29.0 (144891311)|SOQL_EXECUTE_END|[64]|Rows:1
11:10:29.0 (145131119)|USER_DEBUG|[66]|DEBUG|recordtypename:: (Opportunity:RecordTypeId=01280000000BZwlAAG, Id=006m00000093pC0AAI), Working Capital Oppty
11:10:29.0 (145255596)|SYSTEM_MODE_EXIT|false
11:10:29.0 (145541450)|FATAL_ERROR|System.NullPointerException: Attempt to de-reference a null object
apex opportunity permissions record-type record
apex opportunity permissions record-type record
edited Aug 23 at 18:11
asked Aug 23 at 17:05
Olivia
1,142318
1,142318
1
Is yourfList
initialized?
â Jayant Das
Aug 23 at 17:23
Yeah you've clearly demonstrated that you can dereference everything butflist
.
â Adrian Larsonâ¦
Aug 23 at 17:24
Also it looks like your code snippet and debug logs are a bit out of sync. Because you debug statement within the if block should have been printed before the exception. Can you confirm if this is exactly how your code looks like?
â Jayant Das
Aug 23 at 17:58
yea sorry I didn't include that in the snippet. flist is initialized. I will update with the whole code
â Olivia
Aug 23 at 18:03
You really should bulkify your queries
â Halfwarr
Aug 23 at 18:06
 |Â
show 1 more comment
1
Is yourfList
initialized?
â Jayant Das
Aug 23 at 17:23
Yeah you've clearly demonstrated that you can dereference everything butflist
.
â Adrian Larsonâ¦
Aug 23 at 17:24
Also it looks like your code snippet and debug logs are a bit out of sync. Because you debug statement within the if block should have been printed before the exception. Can you confirm if this is exactly how your code looks like?
â Jayant Das
Aug 23 at 17:58
yea sorry I didn't include that in the snippet. flist is initialized. I will update with the whole code
â Olivia
Aug 23 at 18:03
You really should bulkify your queries
â Halfwarr
Aug 23 at 18:06
1
1
Is your
fList
initialized?â Jayant Das
Aug 23 at 17:23
Is your
fList
initialized?â Jayant Das
Aug 23 at 17:23
Yeah you've clearly demonstrated that you can dereference everything but
flist
.â Adrian Larsonâ¦
Aug 23 at 17:24
Yeah you've clearly demonstrated that you can dereference everything but
flist
.â Adrian Larsonâ¦
Aug 23 at 17:24
Also it looks like your code snippet and debug logs are a bit out of sync. Because you debug statement within the if block should have been printed before the exception. Can you confirm if this is exactly how your code looks like?
â Jayant Das
Aug 23 at 17:58
Also it looks like your code snippet and debug logs are a bit out of sync. Because you debug statement within the if block should have been printed before the exception. Can you confirm if this is exactly how your code looks like?
â Jayant Das
Aug 23 at 17:58
yea sorry I didn't include that in the snippet. flist is initialized. I will update with the whole code
â Olivia
Aug 23 at 18:03
yea sorry I didn't include that in the snippet. flist is initialized. I will update with the whole code
â Olivia
Aug 23 at 18:03
You really should bulkify your queries
â Halfwarr
Aug 23 at 18:06
You really should bulkify your queries
â Halfwarr
Aug 23 at 18:06
 |Â
show 1 more comment
1 Answer
1
active
oldest
votes
up vote
3
down vote
accepted
So looking at it I bet this is your problem:
newfundIds.get(f).Lender_ID__r.Name.contains('National Funding')
I'm guessing newfunds does not have a reference id for Lender_ID__r so when you do a .contains()
on .Name
you are really doing it on null which results in the error.
Note this is different if you were doing a simple ==
compare because you are asking for the String Object to call the method contains.
I also just wrote an anon apex to test this:
//Contact we are querying DOES NOT have a reference to an account
List<Contact> conList = [select id, name, Account.name from contact where id = '003K000001FQCCp'];
Map<Id, Contact> mapCon = new Map<Id, Contact>();
for(Contact con : conList)
mapCon.put(con.id, con);
for(Id f : mapCon.keySet())
if(mapCon.get(f).Account.name == 'test')
// does not throw error
if(mapCon.get(f).Account.name.contains('test'))
// throws error "Error Attempt to de-reference a null object"
To solve it you can use Short-circuit evaluation. Based on how you want to handle these type of records.
ah this is it. thank you! I need to change up the.contains()
to ==
â Olivia
Aug 23 at 18:49
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
accepted
So looking at it I bet this is your problem:
newfundIds.get(f).Lender_ID__r.Name.contains('National Funding')
I'm guessing newfunds does not have a reference id for Lender_ID__r so when you do a .contains()
on .Name
you are really doing it on null which results in the error.
Note this is different if you were doing a simple ==
compare because you are asking for the String Object to call the method contains.
I also just wrote an anon apex to test this:
//Contact we are querying DOES NOT have a reference to an account
List<Contact> conList = [select id, name, Account.name from contact where id = '003K000001FQCCp'];
Map<Id, Contact> mapCon = new Map<Id, Contact>();
for(Contact con : conList)
mapCon.put(con.id, con);
for(Id f : mapCon.keySet())
if(mapCon.get(f).Account.name == 'test')
// does not throw error
if(mapCon.get(f).Account.name.contains('test'))
// throws error "Error Attempt to de-reference a null object"
To solve it you can use Short-circuit evaluation. Based on how you want to handle these type of records.
ah this is it. thank you! I need to change up the.contains()
to ==
â Olivia
Aug 23 at 18:49
add a comment |Â
up vote
3
down vote
accepted
So looking at it I bet this is your problem:
newfundIds.get(f).Lender_ID__r.Name.contains('National Funding')
I'm guessing newfunds does not have a reference id for Lender_ID__r so when you do a .contains()
on .Name
you are really doing it on null which results in the error.
Note this is different if you were doing a simple ==
compare because you are asking for the String Object to call the method contains.
I also just wrote an anon apex to test this:
//Contact we are querying DOES NOT have a reference to an account
List<Contact> conList = [select id, name, Account.name from contact where id = '003K000001FQCCp'];
Map<Id, Contact> mapCon = new Map<Id, Contact>();
for(Contact con : conList)
mapCon.put(con.id, con);
for(Id f : mapCon.keySet())
if(mapCon.get(f).Account.name == 'test')
// does not throw error
if(mapCon.get(f).Account.name.contains('test'))
// throws error "Error Attempt to de-reference a null object"
To solve it you can use Short-circuit evaluation. Based on how you want to handle these type of records.
ah this is it. thank you! I need to change up the.contains()
to ==
â Olivia
Aug 23 at 18:49
add a comment |Â
up vote
3
down vote
accepted
up vote
3
down vote
accepted
So looking at it I bet this is your problem:
newfundIds.get(f).Lender_ID__r.Name.contains('National Funding')
I'm guessing newfunds does not have a reference id for Lender_ID__r so when you do a .contains()
on .Name
you are really doing it on null which results in the error.
Note this is different if you were doing a simple ==
compare because you are asking for the String Object to call the method contains.
I also just wrote an anon apex to test this:
//Contact we are querying DOES NOT have a reference to an account
List<Contact> conList = [select id, name, Account.name from contact where id = '003K000001FQCCp'];
Map<Id, Contact> mapCon = new Map<Id, Contact>();
for(Contact con : conList)
mapCon.put(con.id, con);
for(Id f : mapCon.keySet())
if(mapCon.get(f).Account.name == 'test')
// does not throw error
if(mapCon.get(f).Account.name.contains('test'))
// throws error "Error Attempt to de-reference a null object"
To solve it you can use Short-circuit evaluation. Based on how you want to handle these type of records.
So looking at it I bet this is your problem:
newfundIds.get(f).Lender_ID__r.Name.contains('National Funding')
I'm guessing newfunds does not have a reference id for Lender_ID__r so when you do a .contains()
on .Name
you are really doing it on null which results in the error.
Note this is different if you were doing a simple ==
compare because you are asking for the String Object to call the method contains.
I also just wrote an anon apex to test this:
//Contact we are querying DOES NOT have a reference to an account
List<Contact> conList = [select id, name, Account.name from contact where id = '003K000001FQCCp'];
Map<Id, Contact> mapCon = new Map<Id, Contact>();
for(Contact con : conList)
mapCon.put(con.id, con);
for(Id f : mapCon.keySet())
if(mapCon.get(f).Account.name == 'test')
// does not throw error
if(mapCon.get(f).Account.name.contains('test'))
// throws error "Error Attempt to de-reference a null object"
To solve it you can use Short-circuit evaluation. Based on how you want to handle these type of records.
edited Aug 23 at 18:44
answered Aug 23 at 18:32
Halfwarr
300112
300112
ah this is it. thank you! I need to change up the.contains()
to ==
â Olivia
Aug 23 at 18:49
add a comment |Â
ah this is it. thank you! I need to change up the.contains()
to ==
â Olivia
Aug 23 at 18:49
ah this is it. thank you! I need to change up the
.contains()
to ==â Olivia
Aug 23 at 18:49
ah this is it. thank you! I need to change up the
.contains()
to ==â Olivia
Aug 23 at 18:49
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f229952%2frecordtype-name-visibility%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
1
Is your
fList
initialized?â Jayant Das
Aug 23 at 17:23
Yeah you've clearly demonstrated that you can dereference everything but
flist
.â Adrian Larsonâ¦
Aug 23 at 17:24
Also it looks like your code snippet and debug logs are a bit out of sync. Because you debug statement within the if block should have been printed before the exception. Can you confirm if this is exactly how your code looks like?
â Jayant Das
Aug 23 at 17:58
yea sorry I didn't include that in the snippet. flist is initialized. I will update with the whole code
â Olivia
Aug 23 at 18:03
You really should bulkify your queries
â Halfwarr
Aug 23 at 18:06