+ Start a Discussion
MDXHikerMDXHiker 

Issue with profiles

I have a apex code which runs fine when the user is a sysadmin.
But it errors with null pointer when the user is another profile.

How do I debug this ? Thanks
jyotijyoti

Have you checked if the profile has the right to run that particular class?  Next to each class, click Security to grant access or go to the Profile and at the bottom, you'll see Enabled Apex Class Access.  Also they may need API Enabled checkbox checked??



Message Edited by jyoti on 06-12-2008 06:11 PM
MDXHikerMDXHiker
Yes other profiles have access. I did check that
BoxBox

You may need to look into the field level security for the profile running the APEX code.  If that field is set to hidden than you will probably get a null pointer exception.



MDXHikerMDXHiker
I checked the field visibility and it is visible to all profiles

The apex code runs only for sysadmin profile. All other profiles get this null pointer exception.


BoxBox

Have you tried logging the debug trace?

Setup --> Monitoring --> Debug Logs

Would be interesting to see what is in that.

MDXHikerMDXHiker
I did try that. It gives the follwing message

   returning from end of method public void create(x) in 21 ms
System.NullPointerException: Attempt to de-reference a null object
But this same code runs fine for Sysadmin profile


Message Edited by MDXHiker on 06-12-2008 10:48 PM
BoxBox

Looks like you my need to include some debug logging with System.Debug(); 

I find it helpful to debug entire objects with issues like this and this should help you find the object that is giving you the issues.

MDXHikerMDXHiker
I know the object on which it is erroring.
I am trying to dtermine why would the apex code run fine with one profile and error out with null pointer with another profile

I checked the field security for both profiles and it is the same.
Both profiles have access to the apex class. There must be some reasoning for this.

Does it matter who deploys the codes?
BoxBox

No it wont matter who deploys the code.  My current thinking is that it maybe to do with the security settings, e.g. If you have private Accounts and the code is trying to update an Account that does not belong to you and you have no access over through any sharing rules. 

It’s difficult for me to comment as haven’t seen a debug trace of your code running though.

MDXHikerMDXHiker
This is an opp created by the user in this standard user profile and on save the apex code triggers.
So the opp is owned by that user. The user gets a null pointer wiht the above message

Same scenario for Sysadmin, works fine
BoxBox

I'm afraid i would need to see the code and a full debug log to help any further. 

Feel free to PM it to me if you like.