+ Start a Discussion
devsalesforce27devsalesforce27 

Please Help: Display error on Visualforce page depending on checkbox value

Hey All  ,

 

I have a visualforce page which allows the user to enter a part number in the UI and click a submit button.   The system then goes to the compliance part object and uses data from that record to generate some compliance certificates (.pdf) that the user can then print.

 

I’d like  to update this to interrupt this process:   Instead of simply generating and displaying the certificate back to the user, I’d like the application to first check for the  “Reviewed_By_Compliance_Team__c”(its a checkbox on part_compliance__c object)  on the part compliance record associated with the part number entered by the user.   If FALSE,  display a message saying.   “Under Review:Please check back in 7 days”.And , It should not display copliance Certificate page.

 

Below is the Apex class corresponding to the visulaforce page:-

public with sharing class ProductComplianceRequestController {

  public String partNumber {get;set;}

  public ProductComplianceRequestController() {

  }
  
  public PageReference requestCompliance() {
    
    list<Product2> part = [Select Id From Product2 Where Part_Number__c =: partNumber];
    
    if(part.size() == 0) {
      ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.WARNING, 'Part not found.'));
      return null;
    }
    return new Apexpages.Pagereference('/apex/ProductComplianceCertificate?id=' + part[0].Id);
  }
  
  static testMethod void testRequest() {
    
    Product2 testPart = new Product2();
    testPart.Part_Number__c = 'E000000';
    testPart.Name = 'E000000';
    insert testPart;
    
    ProductComplianceRequestController controller = new ProductComplianceRequestController();
    
    controller.partNumber = testPart.Part_Number__c;
    
    test.startTest();
      String resultURL = controller.requestCompliance().getUrl();
    test.stopTest();
    
    System.assertEquals('/apex/ProductComplianceCertificate?id=' + testPart.Id, resultURL);
  }
  
  static testMethod void testRequestNotExist() {
    
    Product2 testPart = new Product2();
    testPart.Part_Number__c = 'E000000';
    testPart.Name = 'E000000';
    insert testPart;
    
    Pagereference pageRef = Page.ProductComplianceRequest;
    Test.setCurrentPage(pageRef);
      
    ProductComplianceRequestController controller = new ProductComplianceRequestController();
    
    controller.partNumber = 'E000001';
    
    test.startTest();
      controller.requestCompliance();
    test.stopTest();
        
    System.assertEquals(ApexPages.getMessages().size(), 1);
  }
}

Best Answer chosen by Admin (Salesforce Developers) 
Naidu PothiniNaidu Pothini
public class ProductComplianceRequestController
{
  public String partNumber {get;set;}

  public ProductComplianceRequestController() {}

  public PageReference requestCompliance()
  {
    Part_Compliance__c pc = new Part_Compliance__c();

    list<Product2> part = [Select Id From Product2 Where Part_Number__c =: partNumber];

    if(part.size() == 0)
    {
      ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.WARNING, 'Part not found.'));
      return null;
    }
    else
    {      
      pc = [SELECT Id, Reviewed_By_Compliance_Team__c FROM Part_Compliance__c WHERE Part_Number__r.Name = :partNumber LIMIT 1];

      System.debug('---------------- PC --------------'+pc);


      List<Part_Compliance__c> pcList = [SELECT Id, Reviewed_By_Compliance_Team__c FROM Part_Compliance__c WHERE Part_Number__r.Name = :partNumber];

     System.debug('---------- total pc --------------'+pcList);
      if(pc <> null)
      {
        if(pc.Reviewed_By_Compliance_Team__c)
        {
          return new Apexpages.Pagereference('/apex/ProductComplianceCertificate?id=' + part[0].Id);
        }
        else
        {
          ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.WARNING, 'Under Review:Please check back in 7 days.'));
          return null;
        }
      }
      else
      {
        ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Error, 'Compliance record not found for the given part number.'));
        return null;
      }
    }
  }
}

 It seems like you have two part compliance records with the same part name, can you please check the debug log and confirm the one which you are looking is the one we are using in this code.

 

Can you copy the debug log?

All Answers

Naidu PothiniNaidu Pothini
public with sharing class ProductComplianceRequestController
{
  public String partNumber {get;set;}

  public ProductComplianceRequestController() {}

  public PageReference requestCompliance()
  {
    list<Product2> part = [Select Id From Product2 Where Part_Number__c =: partNumber];

    if(part.size() == 0)
    {
      ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.WARNING, 'Part not found.'));
      return null;
    }
    else
    {
      Part_Compliance__c pc = [SELECT Id, Reviewed_By_Compliance_Team__c FROM Part_Compliance__c WHERE Part_Number__c  = :partNumber];

      if(pc.Reviewed_By_Compliance_Team__c)
      {
        return new Apexpages.Pagereference('/apex/ProductComplianceCertificate?id=' + part[0].Id);
      }
      else
      {
        ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.WARNING, 'Under Review:Please check back in 7 days.'));
        return null;
      }
    }
}

 Try this. 

devsalesforce27devsalesforce27

Hey , 

 

Thanks for the reply . It is showing no error in class . But when I open a VF page and enter a valid product code. It is showing this error:-

 

List has no rows for assignment to SObject

Error is in expression '{!requestCompliance}' in component <apex:page> in page productcompliancerequest
 
Below is the corresponding VF page with regard to this class:-
 


<apex:PageblockSectionItem >
<apex:inputText value="{!partNumber}" />
<apex:commandButton action="{!requestCompliance}" value="Get Statement"/>
</apex:PageblockSectionItem>

Naidu PothiniNaidu Pothini
public with sharing class ProductComplianceRequestController
{
  public String partNumber {get;set;}

  public ProductComplianceRequestController() {}

  public PageReference requestCompliance()
  {
    list<Product2> part = [Select Id From Product2 Where Part_Number__c =: partNumber];

    if(part.size() == 0)
    {
      ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.WARNING, 'Part not found.'));
      return null;
    }
    else
    {
      Part_Compliance__c pc = [SELECT Id, Reviewed_By_Compliance_Team__c FROM Part_Compliance__c WHERE Part_Number__c  = :partNumber];
System.debug('----------------------- Part Compliance ------------------'+pc); if(pc.Reviewed_By_Compliance_Team__c) { return new Apexpages.Pagereference('/apex/ProductComplianceCertificate?id=' + part[0].Id); } else { ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.WARNING, 'Under Review:Please check back in 7 days.')); return null; } } }

If possible can you post the debug log for this code?

devsalesforce27devsalesforce27
26.0 APEX_CODE,DEBUG;APEX_PROFILING,INFO;CALLOUT,INFO;DB,INFO;SYSTEM,DEBUG;VALIDATION,INFO;VISUALFORCE,INFO;WORKFLOW,INFO
12:11:27.019 (19809000)|EXECUTION_STARTED
12:11:27.019 (19859000)|CODE_UNIT_STARTED|[EXTERNAL]|066Q00000005TPg|VF: /apex/ProductComplianceRequest
12:11:27.020 (20077000)|VF_DESERIALIZE_VIEWSTATE_BEGIN|066Q00000005TPg
12:11:27.024 (24112000)|VF_DESERIALIZE_VIEWSTATE_END
12:11:27.028 (28583000)|CODE_UNIT_STARTED|[EXTERNAL]|01pQ00000002Pyx|ProductComplianceRequestController get(partNumber)
12:11:27.028 (28599000)|SYSTEM_MODE_ENTER|true
12:11:27.028 (28613000)|CODE_UNIT_STARTED|[EXTERNAL]|01pQ00000002Pyx|partNumber
12:11:27.028 (28637000)|METHOD_ENTRY|[1]|01pQ00000002Pyx|ProductComplianceRequestController.ProductComplianceRequestController()
12:11:27.028 (28648000)|SYSTEM_MODE_ENTER|false
12:11:27.028 (28656000)|SYSTEM_MODE_EXIT|false
12:11:27.028 (28664000)|METHOD_EXIT|[1]|ProductComplianceRequestController
12:11:27.028 (28670000)|CODE_UNIT_FINISHED|partNumber
12:11:27.028 (28676000)|CODE_UNIT_FINISHED|ProductComplianceRequestController get(partNumber)
12:11:27.029 (29152000)|CODE_UNIT_STARTED|[EXTERNAL]|ProductComplianceRequestController set(partNumber,E071597)
12:11:27.029 (29165000)|SYSTEM_MODE_ENTER|true
12:11:27.029 (29175000)|CODE_UNIT_STARTED|[EXTERNAL]|ProductComplianceRequestController set(partNumber,E071597)
12:11:27.029 (29204000)|CODE_UNIT_FINISHED|ProductComplianceRequestController set(partNumber,E071597)
12:11:27.029 (29211000)|CODE_UNIT_FINISHED|ProductComplianceRequestController set(partNumber,E071597)
12:11:27.029 (29805000)|CODE_UNIT_STARTED|[EXTERNAL]|01pQ00000002Pyx|ProductComplianceRequestController invoke(requestCompliance)
12:11:27.029 (29870000)|SYSTEM_MODE_ENTER|false
12:11:27.029 (29916000)|METHOD_ENTRY|[9]|01pQ00000002Pyx|ProductComplianceRequestController.__sfdc_partNumber()
12:11:27.029 (29960000)|METHOD_EXIT|[9]|01pQ00000002Pyx|ProductComplianceRequestController.__sfdc_partNumber()
12:11:27.033 (33793000)|SOQL_EXECUTE_BEGIN|[9]|Aggregations:0|select Id from Product2 where Part_Number__c = :tmpVar1
12:11:27.048 (48161000)|SOQL_EXECUTE_END|[9]|Rows:1
12:11:27.048 (48409000)|SYSTEM_METHOD_ENTRY|[11]|LIST<Product2>.size()
12:11:27.048 (48450000)|SYSTEM_METHOD_EXIT|[11]|LIST<Product2>.size()
12:11:27.048 (48495000)|METHOD_ENTRY|[18]|01pQ00000002Pyx|ProductComplianceRequestController.__sfdc_partNumber()
12:11:27.048 (48520000)|METHOD_EXIT|[18]|01pQ00000002Pyx|ProductComplianceRequestController.__sfdc_partNumber()
12:11:27.050 (50884000)|SOQL_EXECUTE_BEGIN|[18]|Aggregations:0|select Id, Reviewed_By_Compliance_Team__c from Part_Compliance__c where Part_Number__c = :tmpVar1
12:11:27.053 (53829000)|SOQL_EXECUTE_END|[18]|Rows:0
12:11:27.054 (54083000)|SYSTEM_MODE_EXIT|false
12:11:27.054 (54172000)|FATAL_ERROR|System.QueryException: List has no rows for assignment to SObject

Class.ProductComplianceRequestController.requestCompliance: line 18, column 1
12:11:27.054 (54198000)|CODE_UNIT_FINISHED|ProductComplianceRequestController invoke(requestCompliance)
Naidu PothiniNaidu Pothini
Part_Compliance__c pc = [SELECT Id, Reviewed_By_Compliance_Team__c FROM Part_Compliance__c WHERE Part_Number__c  = :partNumber];

 This is the line causing error... Can you check whether there is a part compliance record, for this particular part number.??

 

devsalesforce27devsalesforce27

hey , 

 

When I don't insert the below code. Its working fine and able to fetch the data . 

 

else
{
Part_Compliance__c pc = [SELECT Id, Reviewed_By_Compliance_Team__c FROM Part_Compliance__c WHERE Part_Number__c = :partNumber];

if(pc.Reviewed_By_Compliance_Team__c == True)
{
return new Apexpages.Pagereference('/apex/ProductComplianceCertificate?id=' + part[0].Id);
}
else
{
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.WARNING, 'Under Review:Please check back in 7 days.'));
return null;
}

 

I don't know what to do. Kindly help out .

Naidu PothiniNaidu Pothini

Reviewed_By_Compliance_Team__c”(its a checkbox on part_compliance__c object)  on the part compliance record associated with the part number entered by the user

 

The above code is to check for the Reviewed_By_Compliance_Team__c checkbox value on the part Compliance record. But it seems that there is no record exist for the part number and what should the user be displayed if there is no Part Compliance record for the part number entered by the user.

devsalesforce27devsalesforce27

Hey , 

 

The record for the part number do exsists . And if the record doesn't exsist it should display " record not found".

 

 

Naidu PothiniNaidu Pothini
public with sharing class ProductComplianceRequestController
{
  public String partNumber {get;set;}

  public ProductComplianceRequestController() {}

  public PageReference requestCompliance()
  {
    list<Product2> part = [Select Id From Product2 Where Part_Number__c =: partNumber];

    if(part.size() == 0)
    {
      ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.WARNING, 'Part not found.'));
      return null;
    }
    else
    {
      Part_Compliance__c pc = [SELECT Id, Reviewed_By_Compliance_Team__c FROM Part_Compliance__c WHERE Part_Number__c  = :partNumber];

      if(pc <> null)
      {
        if(pc.Reviewed_By_Compliance_Team__c)
        {
          return new Apexpages.Pagereference('/apex/ProductComplianceCertificate?id=' + part[0].Id);
        }
        else
        {
          ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.WARNING, 'Under Review:Please check back in 7 days.'));
          return null;
        }
      }
      else
      {
        ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Error, 'Compliance record not found for the given part number.'));
          return null;
      }
    }
  }
}

 Can you try this and copy the debug log.

devsalesforce27devsalesforce27
26.0 APEX_CODE,DEBUG;APEX_PROFILING,INFO;CALLOUT,INFO;DB,INFO;SYSTEM,DEBUG;VALIDATION,INFO;VISUALFORCE,INFO;WORKFLOW,INFO
14:18:42.024 (24118000)|EXECUTION_STARTED
14:18:42.024 (24164000)|CODE_UNIT_STARTED|[EXTERNAL]|066Q00000005TPg|VF: /apex/ProductComplianceRequest
14:18:42.024 (24905000)|VF_DESERIALIZE_VIEWSTATE_BEGIN|066Q00000005TPg
14:18:42.034 (34713000)|VF_DESERIALIZE_VIEWSTATE_END
14:18:42.039 (39786000)|CODE_UNIT_STARTED|[EXTERNAL]|01pQ00000002Pyx|ProductComplianceRequestController get(partNumber)
14:18:42.039 (39804000)|SYSTEM_MODE_ENTER|true
14:18:42.039 (39822000)|CODE_UNIT_STARTED|[EXTERNAL]|01pQ00000002Pyx|partNumber
14:18:42.039 (39851000)|METHOD_ENTRY|[1]|01pQ00000002Pyx|ProductComplianceRequestController.ProductComplianceRequestController()
14:18:42.039 (39862000)|SYSTEM_MODE_ENTER|false
14:18:42.039 (39871000)|SYSTEM_MODE_EXIT|false
14:18:42.039 (39879000)|METHOD_EXIT|[1]|ProductComplianceRequestController
14:18:42.039 (39889000)|CODE_UNIT_FINISHED|partNumber
14:18:42.039 (39897000)|CODE_UNIT_FINISHED|ProductComplianceRequestController get(partNumber)
14:18:42.040 (40384000)|CODE_UNIT_STARTED|[EXTERNAL]|ProductComplianceRequestController set(partNumber,E071597)
14:18:42.040 (40398000)|SYSTEM_MODE_ENTER|true
14:18:42.040 (40414000)|CODE_UNIT_STARTED|[EXTERNAL]|ProductComplianceRequestController set(partNumber,E071597)
14:18:42.040 (40462000)|CODE_UNIT_FINISHED|ProductComplianceRequestController set(partNumber,E071597)
14:18:42.040 (40472000)|CODE_UNIT_FINISHED|ProductComplianceRequestController set(partNumber,E071597)
14:18:42.042 (42239000)|CODE_UNIT_STARTED|[EXTERNAL]|01pQ00000002Pyx|ProductComplianceRequestController invoke(requestCompliance)
14:18:42.042 (42284000)|SYSTEM_MODE_ENTER|false
14:18:42.042 (42322000)|METHOD_ENTRY|[9]|01pQ00000002Pyx|ProductComplianceRequestController.__sfdc_partNumber()
14:18:42.042 (42354000)|METHOD_EXIT|[9]|01pQ00000002Pyx|ProductComplianceRequestController.__sfdc_partNumber()
14:18:42.045 (45150000)|SOQL_EXECUTE_BEGIN|[9]|Aggregations:0|select Id from Product2 where Part_Number__c = :tmpVar1
14:18:42.067 (67049000)|SOQL_EXECUTE_END|[9]|Rows:1
14:18:42.067 (67260000)|SYSTEM_METHOD_ENTRY|[11]|LIST<Product2>.size()
14:18:42.067 (67300000)|SYSTEM_METHOD_EXIT|[11]|LIST<Product2>.size()
14:18:42.067 (67340000)|METHOD_ENTRY|[18]|01pQ00000002Pyx|ProductComplianceRequestController.__sfdc_partNumber()
14:18:42.067 (67360000)|METHOD_EXIT|[18]|01pQ00000002Pyx|ProductComplianceRequestController.__sfdc_partNumber()
14:18:42.069 (69670000)|SOQL_EXECUTE_BEGIN|[18]|Aggregations:0|select Id, Reviewed_By_Compliance_Team__c from Part_Compliance__c where Part_Number__c = :tmpVar1
14:18:42.071 (71675000)|SOQL_EXECUTE_END|[18]|Rows:0
14:18:42.071 (71879000)|SYSTEM_MODE_EXIT|false
14:18:42.071 (71962000)|FATAL_ERROR|System.QueryException: List has no rows for assignment to SObject

Class.ProductComplianceRequestController.requestCompliance: line 18, column 1
14:18:42.071 (71988000)|CODE_UNIT_FINISHED|ProductComplianceRequestController invoke(requestCompliance)
Naidu PothiniNaidu Pothini
public with sharing class ProductComplianceRequestController
{
  public String partNumber {get;set;}

  public ProductComplianceRequestController() {}

  public PageReference requestCompliance()
  {
Part_Compliance__c pc = new Part_Compliance__c();
list<Product2> part = [Select Id From Product2 Where Part_Number__c =: partNumber]; if(part.size() == 0) { ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.WARNING, 'Part not found.')); return null; } else { pc = [SELECT Id, Reviewed_By_Compliance_Team__c FROM Part_Compliance__c WHERE Part_Number__c = :partNumber]; if(pc <> null) { if(pc.Reviewed_By_Compliance_Team__c) { return new Apexpages.Pagereference('/apex/ProductComplianceCertificate?id=' + part[0].Id); } else { ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.WARNING, 'Under Review:Please check back in 7 days.')); return null; } } else { ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Error, 'Compliance record not found for the given part number.')); return null; } } } }

 If you have not solved this issue please try this.

devsalesforce27devsalesforce27

Heyt Naidu , 

 

Thanks for the reply . But its not working with this code also . Its giving the same error which it is giving in previous codes.

 

Regards

Naidu PothiniNaidu Pothini
public class ProductComplianceRequestController
{
  public String partNumber {get;set;}

  public ProductComplianceRequestController() {}

  public PageReference requestCompliance()
  {
    Part_Compliance__c pc = new Part_Compliance__c();

    list<Product2> part = [Select Id From Product2 Where Part_Number__c =: partNumber];

    if(part.size() == 0)
    {
      ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.WARNING, 'Part not found.'));
      return null;
    }
    else
    {
system.debug('----------- Part Number -------'+partNumber_; pc = [SELECT Id, Reviewed_By_Compliance_Team__c FROM Part_Compliance__c WHERE Part_Number__c = :partNumber]; if(pc <> null) { if(pc.Reviewed_By_Compliance_Team__c) { return new Apexpages.Pagereference('/apex/ProductComplianceCertificate?id=' + part[0].Id); } else { ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.WARNING, 'Under Review:Please check back in 7 days.')); return null; } } else { ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Error, 'Compliance record not found for the given part number.')); return null; } } } }

 can you copy the debug log for this.

devsalesforce27devsalesforce27
26.0 APEX_CODE,DEBUG;APEX_PROFILING,INFO;CALLOUT,INFO;DB,INFO;SYSTEM,DEBUG;VALIDATION,INFO;VISUALFORCE,INFO;WORKFLOW,INFO
13:42:51.017 (17157000)|EXECUTION_STARTED
13:42:51.017 (17201000)|CODE_UNIT_STARTED|[EXTERNAL]|066Q00000005TPg|VF: /apex/ProductComplianceRequest
13:42:51.017 (17388000)|VF_DESERIALIZE_VIEWSTATE_BEGIN|066Q00000005TPg
13:42:51.021 (21188000)|VF_DESERIALIZE_VIEWSTATE_END
13:42:51.025 (25758000)|CODE_UNIT_STARTED|[EXTERNAL]|01pQ00000002Pyx|ProductComplianceRequestController get(partNumber)
13:42:51.025 (25773000)|SYSTEM_MODE_ENTER|true
13:42:51.025 (25786000)|CODE_UNIT_STARTED|[EXTERNAL]|01pQ00000002Pyx|partNumber
13:42:51.025 (25812000)|METHOD_ENTRY|[1]|01pQ00000002Pyx|ProductComplianceRequestController.ProductComplianceRequestController()
13:42:51.025 (25822000)|METHOD_EXIT|[1]|ProductComplianceRequestController
13:42:51.025 (25829000)|CODE_UNIT_FINISHED|partNumber
13:42:51.025 (25836000)|CODE_UNIT_FINISHED|ProductComplianceRequestController get(partNumber)
13:42:51.026 (26312000)|CODE_UNIT_STARTED|[EXTERNAL]|ProductComplianceRequestController set(partNumber,E071597)
13:42:51.026 (26325000)|SYSTEM_MODE_ENTER|true
13:42:51.026 (26336000)|CODE_UNIT_STARTED|[EXTERNAL]|ProductComplianceRequestController set(partNumber,E071597)
13:42:51.026 (26367000)|CODE_UNIT_FINISHED|ProductComplianceRequestController set(partNumber,E071597)
13:42:51.026 (26374000)|CODE_UNIT_FINISHED|ProductComplianceRequestController set(partNumber,E071597)
13:42:51.026 (26979000)|CODE_UNIT_STARTED|[EXTERNAL]|01pQ00000002Pyx|ProductComplianceRequestController invoke(requestCompliance)
13:42:51.027 (27461000)|METHOD_ENTRY|[11]|01pQ00000002Pyx|ProductComplianceRequestController.__sfdc_partNumber()
13:42:51.027 (27499000)|METHOD_EXIT|[11]|01pQ00000002Pyx|ProductComplianceRequestController.__sfdc_partNumber()
13:42:51.030 (30921000)|SOQL_EXECUTE_BEGIN|[11]|Aggregations:0|select Id from Product2 where Part_Number__c = :tmpVar1
13:42:51.037 (37783000)|SOQL_EXECUTE_END|[11]|Rows:1
13:42:51.037 (37959000)|SYSTEM_METHOD_ENTRY|[13]|LIST<Product2>.size()
13:42:51.037 (37993000)|SYSTEM_METHOD_EXIT|[13]|LIST<Product2>.size()
13:42:51.038 (38018000)|METHOD_ENTRY|[20]|01pQ00000002Pyx|ProductComplianceRequestController.__sfdc_partNumber()
13:42:51.038 (38040000)|METHOD_EXIT|[20]|01pQ00000002Pyx|ProductComplianceRequestController.__sfdc_partNumber()
13:42:51.038 (38076000)|SYSTEM_METHOD_ENTRY|[20]|System.debug(ANY)
13:42:51.038 (38086000)|USER_DEBUG|[20]|DEBUG|----------- Part Number -------E071597
13:42:51.038 (38092000)|SYSTEM_METHOD_EXIT|[20]|System.debug(ANY)
13:42:51.038 (38111000)|METHOD_ENTRY|[21]|01pQ00000002Pyx|ProductComplianceRequestController.__sfdc_partNumber()
13:42:51.038 (38127000)|METHOD_EXIT|[21]|01pQ00000002Pyx|ProductComplianceRequestController.__sfdc_partNumber()
13:42:51.040 (40376000)|SOQL_EXECUTE_BEGIN|[21]|Aggregations:0|select Id, Reviewed_By_Compliance_Team__c from Part_Compliance__c where Part_Number__c = :tmpVar1
13:42:51.043 (43440000)|SOQL_EXECUTE_END|[21]|Rows:0
13:42:51.043 (43680000)|FATAL_ERROR|System.QueryException: List has no rows for assignment to SObject

Class.ProductComplianceRequestController.requestCompliance: line 21, column 1
13:42:51.043 (43705000)|CODE_UNIT_FINISHED|ProductComplianceRequestController invoke(requestCompliance)
Naidu PothiniNaidu Pothini
public class ProductComplianceRequestController
{
  public String partNumber {get;set;}

  public ProductComplianceRequestController() {}

  public PageReference requestCompliance()
  {
    Part_Compliance__c pc = new Part_Compliance__c();

    list<Product2> part = [Select Id From Product2 Where Part_Number__c =: partNumber];

    if(part.size() == 0)
    {
      ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.WARNING, 'Part not found.'));
      return null;
    }
    else
    {
     system.debug('----------- Part Number -------'+partNumber);

List<Part_Compliance__c> pcList = [SELECT Id, Part_Number__c FROM Part_Compliance__c LIMIT 5];

System.debug('-------------------------- PC List ------------------'+pcList); pc = [SELECT Id, Reviewed_By_Compliance_Team__c FROM Part_Compliance__c WHERE Part_Number__c = :partNumber]; if(pc <> null) { if(pc.Reviewed_By_Compliance_Team__c) { return new Apexpages.Pagereference('/apex/ProductComplianceCertificate?id=' + part[0].Id); } else { ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.WARNING, 'Under Review:Please check back in 7 days.')); return null; } } else { ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Error, 'Compliance record not found for the given part number.')); return null; } } } }

I think the problem might be... we are looking for part compliance with part Number ( String ) instead of Id.

 

 Can you provide me the debug log once agian to confirm that our search criteria is what we needed.

 

 

devsalesforce27devsalesforce27
26.0 APEX_CODE,DEBUG;APEX_PROFILING,INFO;CALLOUT,INFO;DB,INFO;SYSTEM,DEBUG;VALIDATION,INFO;VISUALFORCE,INFO;WORKFLOW,INFO
13:55:38.029 (29697000)|EXECUTION_STARTED
13:55:38.029 (29744000)|CODE_UNIT_STARTED|[EXTERNAL]|066Q00000005TPg|VF: /apex/ProductComplianceRequest
13:55:38.029 (29981000)|VF_DESERIALIZE_VIEWSTATE_BEGIN|066Q00000005TPg
13:55:38.033 (33790000)|VF_DESERIALIZE_VIEWSTATE_END
13:55:38.038 (38077000)|CODE_UNIT_STARTED|[EXTERNAL]|01pQ00000002Pyx|ProductComplianceRequestController get(partNumber)
13:55:38.038 (38093000)|SYSTEM_MODE_ENTER|true
13:55:38.038 (38110000)|CODE_UNIT_STARTED|[EXTERNAL]|01pQ00000002Pyx|partNumber
13:55:38.038 (38143000)|METHOD_ENTRY|[1]|01pQ00000002Pyx|ProductComplianceRequestController.ProductComplianceRequestController()
13:55:38.038 (38153000)|METHOD_EXIT|[1]|ProductComplianceRequestController
13:55:38.038 (38161000)|CODE_UNIT_FINISHED|partNumber
13:55:38.038 (38168000)|CODE_UNIT_FINISHED|ProductComplianceRequestController get(partNumber)
13:55:38.038 (38711000)|CODE_UNIT_STARTED|[EXTERNAL]|ProductComplianceRequestController set(partNumber,E071597)
13:55:38.038 (38732000)|SYSTEM_MODE_ENTER|true
13:55:38.038 (38745000)|CODE_UNIT_STARTED|[EXTERNAL]|ProductComplianceRequestController set(partNumber,E071597)
13:55:38.038 (38781000)|CODE_UNIT_FINISHED|ProductComplianceRequestController set(partNumber,E071597)
13:55:38.038 (38789000)|CODE_UNIT_FINISHED|ProductComplianceRequestController set(partNumber,E071597)
13:55:38.039 (39191000)|CODE_UNIT_STARTED|[EXTERNAL]|01pQ00000002Pyx|ProductComplianceRequestController invoke(requestCompliance)
13:55:38.039 (39622000)|METHOD_ENTRY|[11]|01pQ00000002Pyx|ProductComplianceRequestController.__sfdc_partNumber()
13:55:38.039 (39662000)|METHOD_EXIT|[11]|01pQ00000002Pyx|ProductComplianceRequestController.__sfdc_partNumber()
13:55:38.042 (42862000)|SOQL_EXECUTE_BEGIN|[11]|Aggregations:0|select Id from Product2 where Part_Number__c = :tmpVar1
13:55:38.054 (54292000)|SOQL_EXECUTE_END|[11]|Rows:1
13:55:38.054 (54458000)|SYSTEM_METHOD_ENTRY|[13]|LIST<Product2>.size()
13:55:38.054 (54492000)|SYSTEM_METHOD_EXIT|[13]|LIST<Product2>.size()
13:55:38.054 (54518000)|METHOD_ENTRY|[20]|01pQ00000002Pyx|ProductComplianceRequestController.__sfdc_partNumber()
13:55:38.054 (54537000)|METHOD_EXIT|[20]|01pQ00000002Pyx|ProductComplianceRequestController.__sfdc_partNumber()
13:55:38.054 (54569000)|SYSTEM_METHOD_ENTRY|[20]|System.debug(ANY)
13:55:38.054 (54579000)|USER_DEBUG|[20]|DEBUG|----------- Part Number -------E071597
13:55:38.054 (54586000)|SYSTEM_METHOD_EXIT|[20]|System.debug(ANY)
13:55:38.054 (54605000)|METHOD_ENTRY|[21]|01pQ00000002Pyx|ProductComplianceRequestController.__sfdc_partNumber()
13:55:38.054 (54622000)|METHOD_EXIT|[21]|01pQ00000002Pyx|ProductComplianceRequestController.__sfdc_partNumber()
13:55:38.056 (56756000)|SOQL_EXECUTE_BEGIN|[21]|Aggregations:0|select Id, Reviewed_By_Compliance_Team__c from Part_Compliance__c where Part_Number__c = :tmpVar1
13:55:38.058 (58651000)|SOQL_EXECUTE_END|[21]|Rows:0
13:55:38.058 (58900000)|FATAL_ERROR|System.QueryException: List has no rows for assignment to SObject

Class.ProductComplianceRequestController.requestCompliance: line 21, column 1
13:55:38.058 (58910000)|CODE_UNIT_FINISHED|ProductComplianceRequestController invoke(requestCompliance)
Naidu PothiniNaidu Pothini

Did you update the code in your org with the one i gave above, i dont see the log for the  line below.

 

System.debug('-------------------------- PC List ------------------'+pcList);

can you update the code and post the debug log.

devsalesforce27devsalesforce27
26.0 APEX_CODE,DEBUG;APEX_PROFILING,INFO;CALLOUT,INFO;DB,INFO;SYSTEM,DEBUG;VALIDATION,INFO;VISUALFORCE,INFO;WORKFLOW,INFO
14:03:18.031 (31103000)|EXECUTION_STARTED
14:03:18.031 (31151000)|CODE_UNIT_STARTED|[EXTERNAL]|066Q00000005TPg|VF: /apex/ProductComplianceRequest
14:03:18.031 (31941000)|VF_DESERIALIZE_VIEWSTATE_BEGIN|066Q00000005TPg
14:03:18.041 (41034000)|VF_DESERIALIZE_VIEWSTATE_END
14:03:18.045 (45801000)|CODE_UNIT_STARTED|[EXTERNAL]|01pQ00000002Pyx|ProductComplianceRequestController get(partNumber)
14:03:18.045 (45818000)|SYSTEM_MODE_ENTER|true
14:03:18.045 (45833000)|CODE_UNIT_STARTED|[EXTERNAL]|01pQ00000002Pyx|partNumber
14:03:18.045 (45860000)|METHOD_ENTRY|[1]|01pQ00000002Pyx|ProductComplianceRequestController.ProductComplianceRequestController()
14:03:18.045 (45870000)|METHOD_EXIT|[1]|ProductComplianceRequestController
14:03:18.045 (45877000)|CODE_UNIT_FINISHED|partNumber
14:03:18.045 (45885000)|CODE_UNIT_FINISHED|ProductComplianceRequestController get(partNumber)
14:03:18.046 (46362000)|CODE_UNIT_STARTED|[EXTERNAL]|ProductComplianceRequestController set(partNumber,E071597)
14:03:18.046 (46376000)|SYSTEM_MODE_ENTER|true
14:03:18.046 (46387000)|CODE_UNIT_STARTED|[EXTERNAL]|ProductComplianceRequestController set(partNumber,E071597)
14:03:18.046 (46424000)|CODE_UNIT_FINISHED|ProductComplianceRequestController set(partNumber,E071597)
14:03:18.046 (46433000)|CODE_UNIT_FINISHED|ProductComplianceRequestController set(partNumber,E071597)
14:03:18.048 (48289000)|CODE_UNIT_STARTED|[EXTERNAL]|01pQ00000002Pyx|ProductComplianceRequestController invoke(requestCompliance)
14:03:18.048 (48701000)|METHOD_ENTRY|[11]|01pQ00000002Pyx|ProductComplianceRequestController.__sfdc_partNumber()
14:03:18.048 (48732000)|METHOD_EXIT|[11]|01pQ00000002Pyx|ProductComplianceRequestController.__sfdc_partNumber()
14:03:18.052 (52307000)|SOQL_EXECUTE_BEGIN|[11]|Aggregations:0|select Id from Product2 where Part_Number__c = :tmpVar1
14:03:18.143 (143016000)|SOQL_EXECUTE_END|[11]|Rows:1
14:03:18.143 (143210000)|SYSTEM_METHOD_ENTRY|[13]|LIST<Product2>.size()
14:03:18.143 (143255000)|SYSTEM_METHOD_EXIT|[13]|LIST<Product2>.size()
14:03:18.143 (143285000)|METHOD_ENTRY|[20]|01pQ00000002Pyx|ProductComplianceRequestController.__sfdc_partNumber()
14:03:18.143 (143304000)|METHOD_EXIT|[20]|01pQ00000002Pyx|ProductComplianceRequestController.__sfdc_partNumber()
14:03:18.143 (143337000)|SYSTEM_METHOD_ENTRY|[20]|System.debug(ANY)
14:03:18.143 (143348000)|USER_DEBUG|[20]|DEBUG|----------- Part Number -------E071597
14:03:18.143 (143354000)|SYSTEM_METHOD_EXIT|[20]|System.debug(ANY)
14:03:18.145 (145968000)|SOQL_EXECUTE_BEGIN|[22]|Aggregations:0|select Id, Part_Number__c from Part_Compliance__c limit 5
14:03:18.182 (182176000)|SOQL_EXECUTE_END|[22]|Rows:5
14:03:18.182 (182346000)|SYSTEM_METHOD_ENTRY|[24]|String.valueOf(Object)
14:03:18.182 (182536000)|SYSTEM_METHOD_EXIT|[24]|String.valueOf(Object)
14:03:18.182 (182565000)|SYSTEM_METHOD_ENTRY|[24]|System.debug(ANY)
14:03:18.182 (182574000)|USER_DEBUG|[24]|DEBUG|-------------------------- PC List ------------------(Part_Compliance__c:{RecordTypeId=012Q0000000D74WIAS, CurrencyIsoCode=USD, Id=a2HQ00000001TXSMA2, Part_Number__c=01tQ0000002wvqRIAQ}, Part_Compliance__c:{RecordTypeId=012Q0000000D74WIAS, CurrencyIsoCode=USD, Id=a2HQ00000001TTBMA2, Part_Number__c=01tQ0000002wvknIAA}, Part_Compliance__c:{RecordTypeId=012Q0000000D74WIAS, CurrencyIsoCode=USD, Id=a2HQ00000001TXXMA2, Part_Number__c=01tQ0000002wvtGIAQ}, Part_Compliance__c:{RecordTypeId=012Q0000000D74WIAS, CurrencyIsoCode=USD, Id=a2HQ00000001TXNMA2, Part_Number__c=01tQ0000002wvpEIAQ}, Part_Compliance__c:{RecordTypeId=012Q0000000D74WIAS, CurrencyIsoCode=USD, Id=a2HQ00000001TXmMAM, Part_Number__c=01tQ0000002wvuOIAQ})
14:03:18.182 (182584000)|SYSTEM_METHOD_EXIT|[24]|System.debug(ANY)
14:03:18.182 (182610000)|METHOD_ENTRY|[26]|01pQ00000002Pyx|ProductComplianceRequestController.__sfdc_partNumber()
14:03:18.182 (182630000)|METHOD_EXIT|[26]|01pQ00000002Pyx|ProductComplianceRequestController.__sfdc_partNumber()
14:03:18.182 (182841000)|SOQL_EXECUTE_BEGIN|[26]|Aggregations:0|select Id, Reviewed_By_Compliance_Team__c from Part_Compliance__c where Part_Number__c = :tmpVar1
14:03:18.194 (194360000)|SOQL_EXECUTE_END|[26]|Rows:0
14:03:18.194 (194581000)|FATAL_ERROR|System.QueryException: List has no rows for assignment to SObject

Class.ProductComplianceRequestController.requestCompliance: line 26, column 1
14:03:18.194 (194594000)|CODE_UNIT_FINISHED|ProductComplianceRequestController invoke(requestCompliance)
Naidu PothiniNaidu Pothini
-------------------------- PC List ------------------(Part_Compliance__c:{RecordTypeId=012Q0000000D74WIAS, CurrencyIsoCode=USD, Id=a2HQ00000001TXSMA2, Part_Number__c=01tQ0000002wvqRIAQ}, Part_Compliance__c:{RecordTypeId=012Q0000000D74WIAS, CurrencyIsoCode=USD, Id=a2HQ00000001TTBMA2, Part_Number__c=01tQ0000002wvknIAA}, Part_Compliance__c:{RecordTypeId=012Q0000000D74WIAS, CurrencyIsoCode=USD,....

 

We are comparing the id with a string and so it is not returning any rows.

 

public class ProductComplianceRequestController
{
  public String partNumber {get;set;}

  public ProductComplianceRequestController() {}

  public PageReference requestCompliance()
  {
    Part_Compliance__c pc = new Part_Compliance__c();

    list<Product2> part = [Select Id From Product2 Where Part_Number__c =: partNumber];

    if(part.size() == 0)
    {
      ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.WARNING, 'Part not found.'));
      return null;
    }
    else
    {
     system.debug('----------- Part Number -------'+partNumber);
      
      pc = [SELECT Id, Reviewed_By_Compliance_Team__c FROM Part_Compliance__c WHERE Part_Number__r.Name = :partNumber];

    system.debug('----------- Pc -------'+pc);

      if(pc <> null)
      {
        if(pc.Reviewed_By_Compliance_Team__c)
        {
          return new Apexpages.Pagereference('/apex/ProductComplianceCertificate?id=' + part[0].Id);
        }
        else
        {
          ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.WARNING, 'Under Review:Please check back in 7 days.'));
          return null;
        }
      }
      else
      {
        ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Error, 'Compliance record not found for the given part number.'));
        return null;
      }
    }
  }
}

 I guess this code would work. 

 

can you post the debug log. sorry to ask you so many times but want to confirm the results you get.

devsalesforce27devsalesforce27
26.0 APEX_CODE,DEBUG;APEX_PROFILING,INFO;CALLOUT,INFO;DB,INFO;SYSTEM,DEBUG;VALIDATION,INFO;VISUALFORCE,INFO;WORKFLOW,INFO
14:13:45.035 (35234000)|EXECUTION_STARTED
14:13:45.035 (35283000)|CODE_UNIT_STARTED|[EXTERNAL]|066Q00000005TPg|VF: /apex/ProductComplianceRequest
14:13:45.036 (36060000)|VF_DESERIALIZE_VIEWSTATE_BEGIN|066Q00000005TPg
14:13:45.045 (45520000)|VF_DESERIALIZE_VIEWSTATE_END
14:13:45.050 (50025000)|CODE_UNIT_STARTED|[EXTERNAL]|01pQ00000002Pyx|ProductComplianceRequestController get(partNumber)
14:13:45.050 (50041000)|SYSTEM_MODE_ENTER|true
14:13:45.050 (50057000)|CODE_UNIT_STARTED|[EXTERNAL]|01pQ00000002Pyx|partNumber
14:13:45.050 (50086000)|METHOD_ENTRY|[1]|01pQ00000002Pyx|ProductComplianceRequestController.ProductComplianceRequestController()
14:13:45.050 (50096000)|METHOD_EXIT|[1]|ProductComplianceRequestController
14:13:45.050 (50103000)|CODE_UNIT_FINISHED|partNumber
14:13:45.050 (50110000)|CODE_UNIT_FINISHED|ProductComplianceRequestController get(partNumber)
14:13:45.050 (50595000)|CODE_UNIT_STARTED|[EXTERNAL]|ProductComplianceRequestController set(partNumber,E071597)
14:13:45.050 (50609000)|SYSTEM_MODE_ENTER|true
14:13:45.050 (50621000)|CODE_UNIT_STARTED|[EXTERNAL]|ProductComplianceRequestController set(partNumber,E071597)
14:13:45.050 (50657000)|CODE_UNIT_FINISHED|ProductComplianceRequestController set(partNumber,E071597)
14:13:45.050 (50666000)|CODE_UNIT_FINISHED|ProductComplianceRequestController set(partNumber,E071597)
14:13:45.052 (52615000)|CODE_UNIT_STARTED|[EXTERNAL]|01pQ00000002Pyx|ProductComplianceRequestController invoke(requestCompliance)
14:13:45.053 (53022000)|METHOD_ENTRY|[11]|01pQ00000002Pyx|ProductComplianceRequestController.__sfdc_partNumber()
14:13:45.053 (53055000)|METHOD_EXIT|[11]|01pQ00000002Pyx|ProductComplianceRequestController.__sfdc_partNumber()
14:13:45.056 (56237000)|SOQL_EXECUTE_BEGIN|[11]|Aggregations:0|select Id from Product2 where Part_Number__c = :tmpVar1
14:13:45.063 (63988000)|SOQL_EXECUTE_END|[11]|Rows:1
14:13:45.064 (64158000)|SYSTEM_METHOD_ENTRY|[13]|LIST<Product2>.size()
14:13:45.064 (64192000)|SYSTEM_METHOD_EXIT|[13]|LIST<Product2>.size()
14:13:45.064 (64217000)|METHOD_ENTRY|[20]|01pQ00000002Pyx|ProductComplianceRequestController.__sfdc_partNumber()
14:13:45.064 (64234000)|METHOD_EXIT|[20]|01pQ00000002Pyx|ProductComplianceRequestController.__sfdc_partNumber()
14:13:45.064 (64266000)|SYSTEM_METHOD_ENTRY|[20]|System.debug(ANY)
14:13:45.064 (64282000)|USER_DEBUG|[20]|DEBUG|----------- Part Number -------E071597
14:13:45.064 (64289000)|SYSTEM_METHOD_EXIT|[20]|System.debug(ANY)
14:13:45.064 (64307000)|METHOD_ENTRY|[22]|01pQ00000002Pyx|ProductComplianceRequestController.__sfdc_partNumber()
14:13:45.064 (64322000)|METHOD_EXIT|[22]|01pQ00000002Pyx|ProductComplianceRequestController.__sfdc_partNumber()
14:13:45.066 (66712000)|SOQL_EXECUTE_BEGIN|[22]|Aggregations:0|select Id, Reviewed_By_Compliance_Team__c from Part_Compliance__c where Part_Number__r.Name = :tmpVar1
14:13:45.117 (117029000)|SOQL_EXECUTE_END|[22]|Rows:2
14:13:45.117 (117358000)|FATAL_ERROR|System.QueryException: List has more than 1 row for assignment to SObject

Class.ProductComplianceRequestController.requestCompliance: line 22, column 1
14:13:45.117 (117371000)|CODE_UNIT_FINISHED|ProductComplianceRequestController invoke(requestCompliance)
Naidu PothiniNaidu Pothini
public class ProductComplianceRequestController
{
  public String partNumber {get;set;}

  public ProductComplianceRequestController() {}

  public PageReference requestCompliance()
  {
    Part_Compliance__c pc = new Part_Compliance__c();

    list<Product2> part = [Select Id From Product2 Where Part_Number__c =: partNumber];

    if(part.size() == 0)
    {
      ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.WARNING, 'Part not found.'));
      return null;
    }
    else
    {      
      pc = [SELECT Id, Reviewed_By_Compliance_Team__c FROM Part_Compliance__c WHERE Part_Number__r.Name = :partNumber LIMIT 1];

      if(pc <> null)
      {
        if(pc.Reviewed_By_Compliance_Team__c)
        {
          return new Apexpages.Pagereference('/apex/ProductComplianceCertificate?id=' + part[0].Id);
        }
        else
        {
          ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.WARNING, 'Under Review:Please check back in 7 days.'));
          return null;
        }
      }
      else
      {
        ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Error, 'Compliance record not found for the given part number.'));
        return null;
      }
    }
  }
}

 try this. this will work.

 

gud luck.

devsalesforce27devsalesforce27

Hey Naidu , 

 

All the time this code is only executing one part giving error" Under review:please check back in 7 days". Even though the Reviewed_by_compliance_team__c is checked , still gives the "Under review " error. In short , it is not directing me to the compliance certificate page.

 

Regards

Naidu PothiniNaidu Pothini
public class ProductComplianceRequestController
{
  public String partNumber {get;set;}

  public ProductComplianceRequestController() {}

  public PageReference requestCompliance()
  {
    Part_Compliance__c pc = new Part_Compliance__c();

    list<Product2> part = [Select Id From Product2 Where Part_Number__c =: partNumber];

    if(part.size() == 0)
    {
      ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.WARNING, 'Part not found.'));
      return null;
    }
    else
    {      
      pc = [SELECT Id, Reviewed_By_Compliance_Team__c FROM Part_Compliance__c WHERE Part_Number__r.Name = :partNumber LIMIT 1];

      System.debug('---------------- PC --------------'+pc);


      List<Part_Compliance__c> pcList = [SELECT Id, Reviewed_By_Compliance_Team__c FROM Part_Compliance__c WHERE Part_Number__r.Name = :partNumber];

     System.debug('---------- total pc --------------'+pcList);
      if(pc <> null)
      {
        if(pc.Reviewed_By_Compliance_Team__c)
        {
          return new Apexpages.Pagereference('/apex/ProductComplianceCertificate?id=' + part[0].Id);
        }
        else
        {
          ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.WARNING, 'Under Review:Please check back in 7 days.'));
          return null;
        }
      }
      else
      {
        ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Error, 'Compliance record not found for the given part number.'));
        return null;
      }
    }
  }
}

 It seems like you have two part compliance records with the same part name, can you please check the debug log and confirm the one which you are looking is the one we are using in this code.

 

Can you copy the debug log?

This was selected as the best answer
devsalesforce27devsalesforce27
26.0 APEX_CODE,DEBUG;APEX_PROFILING,INFO;CALLOUT,INFO;DB,INFO;SYSTEM,DEBUG;VALIDATION,INFO;VISUALFORCE,INFO;WORKFLOW,INFO
14:31:26.022 (22716000)|EXECUTION_STARTED
14:31:26.022 (22761000)|CODE_UNIT_STARTED|[EXTERNAL]|066Q00000005TPg|VF: /apex/ProductComplianceRequest
14:31:26.022 (22971000)|VF_DESERIALIZE_VIEWSTATE_BEGIN|066Q00000005TPg
14:31:26.035 (35453000)|VF_DESERIALIZE_VIEWSTATE_END
14:31:26.040 (40255000)|CODE_UNIT_STARTED|[EXTERNAL]|01pQ00000002Pyx|ProductComplianceRequestController get(partNumber)
14:31:26.040 (40272000)|SYSTEM_MODE_ENTER|true
14:31:26.040 (40286000)|CODE_UNIT_STARTED|[EXTERNAL]|01pQ00000002Pyx|partNumber
14:31:26.040 (40312000)|METHOD_ENTRY|[1]|01pQ00000002Pyx|ProductComplianceRequestController.ProductComplianceRequestController()
14:31:26.040 (40322000)|METHOD_EXIT|[1]|ProductComplianceRequestController
14:31:26.040 (40329000)|CODE_UNIT_FINISHED|partNumber
14:31:26.040 (40336000)|CODE_UNIT_FINISHED|ProductComplianceRequestController get(partNumber)
14:31:26.040 (40752000)|CODE_UNIT_STARTED|[EXTERNAL]|ProductComplianceRequestController set(partNumber,E071597)
14:31:26.040 (40763000)|SYSTEM_MODE_ENTER|true
14:31:26.040 (40773000)|CODE_UNIT_STARTED|[EXTERNAL]|ProductComplianceRequestController set(partNumber,E071597)
14:31:26.040 (40810000)|CODE_UNIT_FINISHED|ProductComplianceRequestController set(partNumber,E071597)
14:31:26.040 (40818000)|CODE_UNIT_FINISHED|ProductComplianceRequestController set(partNumber,E071597)
14:31:26.042 (42479000)|CODE_UNIT_STARTED|[EXTERNAL]|01pQ00000002Pyx|ProductComplianceRequestController invoke(requestCompliance)
14:31:26.042 (42921000)|METHOD_ENTRY|[11]|01pQ00000002Pyx|ProductComplianceRequestController.__sfdc_partNumber()
14:31:26.042 (42953000)|METHOD_EXIT|[11]|01pQ00000002Pyx|ProductComplianceRequestController.__sfdc_partNumber()
14:31:26.045 (45709000)|SOQL_EXECUTE_BEGIN|[11]|Aggregations:0|select Id from Product2 where Part_Number__c = :tmpVar1
14:31:26.052 (52890000)|SOQL_EXECUTE_END|[11]|Rows:1
14:31:26.053 (53097000)|SYSTEM_METHOD_ENTRY|[13]|LIST<Product2>.size()
14:31:26.053 (53138000)|SYSTEM_METHOD_EXIT|[13]|LIST<Product2>.size()
14:31:26.053 (53180000)|METHOD_ENTRY|[20]|01pQ00000002Pyx|ProductComplianceRequestController.__sfdc_partNumber()
14:31:26.053 (53202000)|METHOD_EXIT|[20]|01pQ00000002Pyx|ProductComplianceRequestController.__sfdc_partNumber()
14:31:26.055 (55971000)|SOQL_EXECUTE_BEGIN|[20]|Aggregations:0|select Id, Reviewed_By_Compliance_Team__c from Part_Compliance__c where Part_Number__r.Name = :tmpVar1 limit 1
14:31:26.077 (77197000)|SOQL_EXECUTE_END|[20]|Rows:1
14:31:26.077 (77571000)|SYSTEM_METHOD_ENTRY|[30]|ApexPages.addMessage(ApexPages.Message)
14:31:26.077 (77619000)|VF_PAGE_MESSAGE|Under Review:Please check back in 7 days.
14:31:26.077 (77631000)|SYSTEM_METHOD_EXIT|[30]|ApexPages.addMessage(ApexPages.Message)
14:31:26.077 (77678000)|CODE_UNIT_FINISHED|ProductComplianceRequestController invoke(requestCompliance)
14:31:26.079 (79118000)|VF_APEX_CALL|j_id36|{!requestCompliance}|PageReference: none
14:31:26.093 (93491000)|CODE_UNIT_STARTED|[EXTERNAL]|01pQ00000002Pyx|ProductComplianceRequestController get(partNumber)
14:31:26.093 (93507000)|SYSTEM_MODE_ENTER|true
14:31:26.093 (93517000)|CODE_UNIT_STARTED|[EXTERNAL]|01pQ00000002Pyx|partNumber
14:31:26.093 (93527000)|CODE_UNIT_FINISHED|partNumber
14:31:26.093 (93534000)|CODE_UNIT_FINISHED|ProductComplianceRequestController get(partNumber)
14:31:26.094 (94824000)|VF_SERIALIZE_VIEWSTATE_BEGIN|066Q00000005TPg
14:31:26.097 (97224000)|VF_SERIALIZE_VIEWSTATE_END
14:31:26.970 (101006000)|CUMULATIVE_LIMIT_USAGE
14:31:26.970|LIMIT_USAGE_FOR_NS|(default)|
  Number of SOQL queries: 2 out of 100
  Number of query rows: 2 out of 50000
  Number of SOSL queries: 0 out of 20
  Number of DML statements: 0 out of 150
  Number of DML rows: 0 out of 10000
  Number of code statements: 5 out of 200000
  Maximum heap size: 0 out of 6000000
  Number of callouts: 0 out of 10
  Number of Email Invocations: 0 out of 10
  Number of fields describes: 0 out of 100
  Number of record type describes: 0 out of 100
  Number of child relationships describes: 0 out of 100
  Number of picklist describes: 0 out of 100
  Number of future calls: 0 out of 10

14:31:26.970|CUMULATIVE_LIMIT_USAGE_END

14:31:26.101 (101041000)|CODE_UNIT_FINISHED|VF: /apex/ProductComplianceRequest
14:31:26.101 (101050000)|EXECUTION_FINISHED
Naidu PothiniNaidu Pothini

I guess these logs were not for the updated code... 

 

can you please check it... i have added couple of debug statements to check for number of compliance records for the part number...

 

 

devsalesforce27devsalesforce27
26.0 APEX_CODE,DEBUG;APEX_PROFILING,INFO;CALLOUT,INFO;DB,INFO;SYSTEM,DEBUG;VALIDATION,INFO;VISUALFORCE,INFO;WORKFLOW,INFO
15:16:22.023 (23313000)|EXECUTION_STARTED
15:16:22.023 (23354000)|CODE_UNIT_STARTED|[EXTERNAL]|066Q00000005TPg|VF: /apex/ProductComplianceRequest
15:16:22.024 (24092000)|VF_DESERIALIZE_VIEWSTATE_BEGIN|066Q00000005TPg
15:16:22.033 (33830000)|VF_DESERIALIZE_VIEWSTATE_END
15:16:22.038 (38462000)|CODE_UNIT_STARTED|[EXTERNAL]|01pQ00000002Pyx|ProductComplianceRequestController get(partNumber)
15:16:22.038 (38478000)|SYSTEM_MODE_ENTER|true
15:16:22.038 (38493000)|CODE_UNIT_STARTED|[EXTERNAL]|01pQ00000002Pyx|partNumber
15:16:22.038 (38519000)|METHOD_ENTRY|[1]|01pQ00000002Pyx|ProductComplianceRequestController.ProductComplianceRequestController()
15:16:22.038 (38529000)|METHOD_EXIT|[1]|ProductComplianceRequestController
15:16:22.038 (38537000)|CODE_UNIT_FINISHED|partNumber
15:16:22.038 (38545000)|CODE_UNIT_FINISHED|ProductComplianceRequestController get(partNumber)
15:16:22.039 (39021000)|CODE_UNIT_STARTED|[EXTERNAL]|ProductComplianceRequestController set(partNumber,E071597)
15:16:22.039 (39035000)|SYSTEM_MODE_ENTER|true
15:16:22.039 (39046000)|CODE_UNIT_STARTED|[EXTERNAL]|ProductComplianceRequestController set(partNumber,E071597)
15:16:22.039 (39085000)|CODE_UNIT_FINISHED|ProductComplianceRequestController set(partNumber,E071597)
15:16:22.039 (39093000)|CODE_UNIT_FINISHED|ProductComplianceRequestController set(partNumber,E071597)
15:16:22.040 (40656000)|CODE_UNIT_STARTED|[EXTERNAL]|01pQ00000002Pyx|ProductComplianceRequestController invoke(requestCompliance)
15:16:22.041 (41075000)|METHOD_ENTRY|[11]|01pQ00000002Pyx|ProductComplianceRequestController.__sfdc_partNumber()
15:16:22.041 (41108000)|METHOD_EXIT|[11]|01pQ00000002Pyx|ProductComplianceRequestController.__sfdc_partNumber()
15:16:22.043 (43746000)|SOQL_EXECUTE_BEGIN|[11]|Aggregations:0|select Id from Product2 where Part_Number__c = :tmpVar1
15:16:22.053 (53212000)|SOQL_EXECUTE_END|[11]|Rows:1
15:16:22.053 (53425000)|SYSTEM_METHOD_ENTRY|[13]|LIST<Product2>.size()
15:16:22.053 (53462000)|SYSTEM_METHOD_EXIT|[13]|LIST<Product2>.size()
15:16:22.053 (53502000)|METHOD_ENTRY|[20]|01pQ00000002Pyx|ProductComplianceRequestController.__sfdc_partNumber()
15:16:22.053 (53524000)|METHOD_EXIT|[20]|01pQ00000002Pyx|ProductComplianceRequestController.__sfdc_partNumber()
15:16:22.056 (56197000)|SOQL_EXECUTE_BEGIN|[20]|Aggregations:0|select Id, Reviewed_By_Compliance_Team__c from Part_Compliance__c where Part_Number__r.Name = :tmpVar1 limit 1
15:16:22.063 (63957000)|SOQL_EXECUTE_END|[20]|Rows:1
15:16:22.064 (64188000)|SYSTEM_METHOD_ENTRY|[22]|String.valueOf(Object)
15:16:22.064 (64268000)|SYSTEM_METHOD_EXIT|[22]|String.valueOf(Object)
15:16:22.064 (64300000)|SYSTEM_METHOD_ENTRY|[22]|System.debug(ANY)
15:16:22.064 (64308000)|USER_DEBUG|[22]|DEBUG|---------------- PC --------------Part_Compliance__c:{RecordTypeId=012Q0000000D74VIAS, CurrencyIsoCode=USD, Reviewed_By_Compliance_Team__c=false, Id=a2HQ00000001S5aMAE, Part_Number__c=01t80000001TeRWAA0}
15:16:22.064 (64316000)|SYSTEM_METHOD_EXIT|[22]|System.debug(ANY)
15:16:22.064 (64339000)|METHOD_ENTRY|[25]|01pQ00000002Pyx|ProductComplianceRequestController.__sfdc_partNumber()
15:16:22.064 (64359000)|METHOD_EXIT|[25]|01pQ00000002Pyx|ProductComplianceRequestController.__sfdc_partNumber()
15:16:22.064 (64580000)|SOQL_EXECUTE_BEGIN|[25]|Aggregations:0|select Id, Reviewed_By_Compliance_Team__c from Part_Compliance__c where Part_Number__r.Name = :tmpVar1
15:16:22.074 (74164000)|SOQL_EXECUTE_END|[25]|Rows:2
15:16:22.074 (74231000)|SYSTEM_METHOD_ENTRY|[27]|String.valueOf(Object)
15:16:22.074 (74338000)|SYSTEM_METHOD_EXIT|[27]|String.valueOf(Object)
15:16:22.074 (74357000)|SYSTEM_METHOD_ENTRY|[27]|System.debug(ANY)
15:16:22.074 (74363000)|USER_DEBUG|[27]|DEBUG|---------- total pc --------------(Part_Compliance__c:{RecordTypeId=012Q0000000D74VIAS, CurrencyIsoCode=USD, Reviewed_By_Compliance_Team__c=false, Id=a2HQ00000001S5aMAE, Part_Number__c=01t80000001TeRWAA0}, Part_Compliance__c:{RecordTypeId=012Q0000000D74WIAS, CurrencyIsoCode=USD, Reviewed_By_Compliance_Team__c=true, Id=a2HQ00000001UF5MAM, Part_Number__c=01t80000001TeRWAA0})
15:16:22.074 (74372000)|SYSTEM_METHOD_EXIT|[27]|System.debug(ANY)
15:16:22.074 (74496000)|SYSTEM_METHOD_ENTRY|[36]|ApexPages.addMessage(ApexPages.Message)
15:16:22.074 (74534000)|VF_PAGE_MESSAGE|Under Review:Please check back in 7 days.
15:16:22.074 (74542000)|SYSTEM_METHOD_EXIT|[36]|ApexPages.addMessage(ApexPages.Message)
15:16:22.074 (74581000)|CODE_UNIT_FINISHED|ProductComplianceRequestController invoke(requestCompliance)
15:16:22.075 (75672000)|VF_APEX_CALL|j_id36|{!requestCompliance}|PageReference: none
15:16:22.090 (90076000)|CODE_UNIT_STARTED|[EXTERNAL]|01pQ00000002Pyx|ProductComplianceRequestController get(partNumber)
15:16:22.090 (90094000)|SYSTEM_MODE_ENTER|true
15:16:22.090 (90103000)|CODE_UNIT_STARTED|[EXTERNAL]|01pQ00000002Pyx|partNumber
15:16:22.090 (90113000)|CODE_UNIT_FINISHED|partNumber
15:16:22.090 (90120000)|CODE_UNIT_FINISHED|ProductComplianceRequestController get(partNumber)
15:16:22.091 (91360000)|VF_SERIALIZE_VIEWSTATE_BEGIN|066Q00000005TPg
15:16:22.093 (93676000)|VF_SERIALIZE_VIEWSTATE_END
15:16:22.751 (97720000)|CUMULATIVE_LIMIT_USAGE
15:16:22.751|LIMIT_USAGE_FOR_NS|(default)|
  Number of SOQL queries: 3 out of 100
  Number of query rows: 4 out of 50000
  Number of SOSL queries: 0 out of 20
  Number of DML statements: 0 out of 150
  Number of DML rows: 0 out of 10000
  Number of code statements: 8 out of 200000
  Maximum heap size: 0 out of 6000000
  Number of callouts: 0 out of 10
  Number of Email Invocations: 0 out of 10
  Number of fields describes: 0 out of 100
  Number of record type describes: 0 out of 100
  Number of child relationships describes: 0 out of 100
  Number of picklist describes: 0 out of 100
  Number of future calls: 0 out of 10

15:16:22.751|CUMULATIVE_LIMIT_USAGE_END

15:16:22.097 (97752000)|CODE_UNIT_FINISHED|VF: /apex/ProductComplianceRequest
15:16:22.097 (97766000)|EXECUTION_FINISHED
Naidu PothiniNaidu Pothini
Part_Compliance__c:{RecordTypeId=012Q0000000D74VIAS, CurrencyIsoCode=USD, Reviewed_By_Compliance_Team__c=false, Id=a2HQ00000001S5aMAE, Part_Number__c=01t80000001TeRWAA0}, 

Part_Compliance__c:{RecordTypeId=012Q0000000D74WIAS, CurrencyIsoCode=USD, Reviewed_By_Compliance_Team__c=true, Id=a2HQ00000001UF5MAM, Part_Number__c=01t80000001TeRWAA0})

 

I see there are two records and my guess would be it is checking for the first record which has the value as false,

 

Is this a valid data of having two part compliance records for same part number? if not delete one record, or else we need to update the code based on which compliance record we need to choose from the part number.

 

devsalesforce27devsalesforce27

Hey Naidu , 

 

You are right . There were 2 records corresponding to that ID . Your code is working fine. I really appreciate your time and deeply express my gratitude for helping me fix the bug. I owe you. You are a salesforce Rockstar....I salute....

 

Thanks a lot....