RecordType.Name Visibility

The name of the pictureThe name of the pictureThe name of the pictureClash 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









share|improve this question



















  • 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
















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









share|improve this question



















  • 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












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









share|improve this question















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Aug 23 at 18:11

























asked Aug 23 at 17:05









Olivia

1,142318




1,142318







  • 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












  • 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







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










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.






share|improve this answer






















  • ah this is it. thank you! I need to change up the .contains() to ==
    – Olivia
    Aug 23 at 18:49










Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "459"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















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






























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.






share|improve this answer






















  • ah this is it. thank you! I need to change up the .contains() to ==
    – Olivia
    Aug 23 at 18:49














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.






share|improve this answer






















  • ah this is it. thank you! I need to change up the .contains() to ==
    – Olivia
    Aug 23 at 18:49












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.






share|improve this answer














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.







share|improve this answer














share|improve this answer



share|improve this answer








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
















  • 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

















 

draft saved


draft discarded















































 


draft saved


draft discarded














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













































































Popular posts from this blog

How to check contact read email or not when send email to Individual?

Bahrain

Postfix configuration issue with fips on centos 7; mailgun relay