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
Swap50Swap50 

Strange issue with Apex Describe for RecordType

Hi All

 

I'm facing a strange issue.. Need your suggestions.

 

I have a trigger on Case which changes the recordtype when the case owner changes to a queue.

 

So i'm using below statement to get the recordtype id based on the name.

 

Schema.SObjectType.Case.getRecordTypeInfosByName().get('case record type').getRecordTypeId();

 

We have many profiles in our org , this statement is working for everyone except one profile.

 

As apex runs in system mode, i dont think recordtype access is an issue.

I tried using a query instead of above statement and it works even for this profile.

 

Recordtype temprectypeid=[Select Id from RecordType where name='case record type'];

 

I checked running the same statement in system log and getting null pointer exception where as for other profiles it works.

 

I tried comparing all the profile settings, every thing seems to be same.

 

Can any one help me debug the issue. I may be missing something.

 

Any pointers will be of great help

 

Thanks

Swapna

 

TrueCloudTrueCloud

Can you try Id instead of the name to see if you are able to fetch the record. For example,

 

Recordtype temprectypeid=[Select Id from RecordType where Id='RecordTypeId'];

 

Of course, you will have to replace the "RecordTypeId" with the actual Id. Also it would be helpful to paste your code here to help you trouble shoot the issue. 

Swap50Swap50

Thanks for the reply.

 

Query is working for me even with the name value.

 

Below statement has issues

Schema.SObjectType.Case.getRecordTypeInfosByName().get('case record type').getRecordTypeId();

 

This statement doesnt even work in sytem log for that particular profile.

TrueCloudTrueCloud

I know you have probably answered this but I want to make sure that the permissions are correct.

 

a) You went to Setup | Administration Setup | Manage Users | Profule

 - Clicked on the profile and did not click edit.

 

b) Next > You scrolled to the Record Type section (Again the Profile is not in edit mode). And made sure the Record Type is selected for the object that is being accessed:

 

Image URL: https://4536718509136684787-a-vandamme-com-s-sites.googlegroups.com/a/vandamme.com/npsp---public-site/home/quick-start-guide/recordtype1.png?attachauth=ANoY7crIcgDsiHQJANAor2c_bZM0hBl4La52WLk6js63TSpy83si4-tHWyzjJ3TiZWVaxZwzMdaS--rm1YsdcS46DS2MaEfjPCNRx62vxSEwnv23XS_qyUkKRu9oYQmLGjohJzJgAsTSFnSQWtVseiE3H4u4JPs40kyKW8nacGAJKoDZ2OS-WFAJMmlCy-TUNDWZF5ZCOn0gg7-_BGkG6fTtI5GzKTMbb7T-PVHe-h6g6jURwwwXS0E%3D&attredirects=0



c) If you don't see the record type for the object here then click edit and add the record type for this profile. 

 

Lastly, if all of this is true then can you post your entire code to help you resolve this issue.