• Rafal Galazkiewicz 4
  • NEWBIE
  • 20 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 4
    Replies
I'm running int0 this error - attempt to de-reference a null object.
My scenario - VFP published as force.com site with a class to save a record first from entered fields and add attachmnet there as well if user attached that:

public class savemcd {
    public savemcd(ApexPages.StandardController controller)
    {
    }
    Public Attachment myfile;
    Public Attachment getmyfile()
    {
        myfile = new Attachment();
        return myfile;
    }

    Public Misconduct__c mymscd;
    Public Misconduct__c getmymscd()
    {
        mymscd = new Misconduct__c();
        return mymscd;
    }
  
 
    Public Pagereference Savedoc()
    {
    if (mymscd.name != null){
       Misconduct__c mcd = new Misconduct__c(Submitter__c=mymscd.Submitter__c, Phone_number__c=mymscd.Phone_number__c, Email__c=mymscd.Email__c, Description__c=mymscd.Description__c );
       insert mcd;
       string result = mcd.id;
          
           if (myfile.name != null)
           {
           Attachment a = new Attachment(parentId = result, name=myfile.name, body = myfile.body);
           /* insert the attachment */
           insert a;
           }
        }
        return NULL;
    } 
}


What do I do wrong?
I'm following work.com workbook but having it prinstalled from Salesforce 1 for admin guide so some parts need some modifications still. I have encountered this tricky issue.
Schema is such:
Warehouse (Master) - (detail) Merchandies (Master) - (detail) Line Item (detail) - (Master) Invoice

No roles in place yet

OWD:
Invoice  Private  
Line Item Controlled by Parent
Merchandise Controlled by Parent
Warehouse Public Read Only

Profile:
Merchandise Read
Warehouse Read

Permission set:
Invoices Read, Create, Edit, Delete
Line Items Read, Create, Edit, Delete
Merchandise Read
Warehouses Read

I can create Invoice record. Then on Line Item related list I click on New. Input webform opens. Invoice field is prefilled as open from related list and then I browse any Merchandise (owned by other user) and click save and I got this error:

"Insufficient Privileges
You do not have the level of access necessary to perform the operation you requested. Please contact the owner of the record or your administrator if access is necessary."

Why is that? When I change OWD for Merchandise to Public Read/Write it lets me save Line Item record but why? Based on my definition order of relationship is such that primary is between Invoice and Line Item.

I'm lost a bit here ir it's so simple that I just don't see it.

Please help.
I'm running int0 this error - attempt to de-reference a null object.
My scenario - VFP published as force.com site with a class to save a record first from entered fields and add attachmnet there as well if user attached that:

public class savemcd {
    public savemcd(ApexPages.StandardController controller)
    {
    }
    Public Attachment myfile;
    Public Attachment getmyfile()
    {
        myfile = new Attachment();
        return myfile;
    }

    Public Misconduct__c mymscd;
    Public Misconduct__c getmymscd()
    {
        mymscd = new Misconduct__c();
        return mymscd;
    }
  
 
    Public Pagereference Savedoc()
    {
    if (mymscd.name != null){
       Misconduct__c mcd = new Misconduct__c(Submitter__c=mymscd.Submitter__c, Phone_number__c=mymscd.Phone_number__c, Email__c=mymscd.Email__c, Description__c=mymscd.Description__c );
       insert mcd;
       string result = mcd.id;
          
           if (myfile.name != null)
           {
           Attachment a = new Attachment(parentId = result, name=myfile.name, body = myfile.body);
           /* insert the attachment */
           insert a;
           }
        }
        return NULL;
    } 
}


What do I do wrong?
I'm following work.com workbook but having it prinstalled from Salesforce 1 for admin guide so some parts need some modifications still. I have encountered this tricky issue.
Schema is such:
Warehouse (Master) - (detail) Merchandies (Master) - (detail) Line Item (detail) - (Master) Invoice

No roles in place yet

OWD:
Invoice  Private  
Line Item Controlled by Parent
Merchandise Controlled by Parent
Warehouse Public Read Only

Profile:
Merchandise Read
Warehouse Read

Permission set:
Invoices Read, Create, Edit, Delete
Line Items Read, Create, Edit, Delete
Merchandise Read
Warehouses Read

I can create Invoice record. Then on Line Item related list I click on New. Input webform opens. Invoice field is prefilled as open from related list and then I browse any Merchandise (owned by other user) and click save and I got this error:

"Insufficient Privileges
You do not have the level of access necessary to perform the operation you requested. Please contact the owner of the record or your administrator if access is necessary."

Why is that? When I change OWD for Merchandise to Public Read/Write it lets me save Line Item record but why? Based on my definition order of relationship is such that primary is between Invoice and Line Item.

I'm lost a bit here ir it's so simple that I just don't see it.

Please help.
I am creating a visualforce page for leads.

I have the following in my controller:

Code:
Lead lead;

public Lead getLead(){
    if(lead == null) lead = [select id, name, Persona__c from Lead where id= :ApexPages.currentPage().getParameters().get('id')];
    return lead;
}

public List<Question__c> getQuestions(){
    return [select id, Question_Value__c from Question__c where Persona__c = :lead.Persona__c];
}

 Now on the Page it shows the Question ids if I just put {!Questions}.

But as soon as I try to put the questions into a pageblock I get the error: System.NullPointerException: Attempt to de-reference a null object. The error points to the return statement in the last method above.

Here is the section of the page:

Code:
<apex:pageBlockTable value="{!Questions}" var="q">
             <apex:column value="{!q.Question_Value__c}"/>
         </apex:pageBlockTable>

 
Any idea how to put the data into a table appropriately?