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
Vigneshwaran LoganathanVigneshwaran Loganathan 

SObject row was retrieved via SOQL without querying the requested field: Legal_Action__c.Name_of_Client__c

public with sharing class legalactionsubmission
{   
    public legal_action__c legact{get;set;}
    public String currentid= ApexPages.currentPage().getParameters().get('id');
    public boolean savedis{get;set;}
    public string idcurr;
    
    public legalactionsubmission(ApexPages.StandardController controller)
    {
        savedis=false;
        legact=new legal_action__c();
        legact=(legal_action__c)controller.getrecord();
        system.debug('>>>legact'+legact);
        this.idcurr=ApexPages.currentpage().getparameters().get('id');
        if(currentid!=null && currentid!='')
        {
          //Legal_Action__c a = new Legal_Action__c();
          legact=[select id,submit_done__c,entry_by__c from legal_action__c where id=:currentid];
          if(legact.submit_done__c==true)
          {
           savedis=true;
           String msg = 'Thank you for Submitting.';
           ApexPages.addmessage(new ApexPages.message(ApexPages.severity.CONFIRM,msg));
          }
        }  
    }
    
    public pagereference save()
    {
     savedis=true;
     legal_action__c leg= new legal_action__c();
     //legal_action__c legact= new legal_action__c();
     system.debug('>>>legact'+legact);
     leg=[select id,Name_of_Client__c,submit_done__c,Name_of_VA__c,entry_by__c,reviewed_by__C,Summary_of_Situation__c,Attachment_summary__c from legal_action__c where id=:currentid];
     if(leg.submit_done__c==false)
     {
       leg.Name_of_Client__c=legact.Name_of_Client__c; // Error Line 
       leg.submit_done__c=true;
       leg.Name_of_VA__c=legact.Name_of_VA__c;
       leg.entry_by__c=legact.entry_by__c;
       leg.reviewed_by__C=legact.reviewed_by__C;
       leg.Summary_of_Situation__c=legact.Summary_of_Situation__c;
       leg.Attachment_summary__c=legact.Attachment_summary__c;
       update leg;
       system.debug('>>>>entryby'+leg.entry_by__c);
     }
     
        pagereference ref;
        ref = new pagereference('/apex/legal_action_final_reviewe?id='+legact.id);
        ref.setredirect(true);
        return ref;
    }
}
Hi,
Can anyone help me for this, I know where it goes wrong..  I have queried correctly but still its showing the error.. Any mistakes here?
 
Best Answer chosen by Vigneshwaran Loganathan
Thiyagarajan Selvaraj (SFDC Developer)Thiyagarajan Selvaraj (SFDC Developer)
Hi Vigneshwaran Loganathan,

Change your query on line 18 like following
legact = [SELECT id,Name_of_Client__c,submit_done__c,Name_of_VA__c,entry_by__c,reviewed_by__C,Summary_of_Situation__c,Attachment_summary__c, Attachment_summary__c from legal_action__c where id=:currentid];



 

All Answers

Prabhat Kumar12Prabhat Kumar12
Query it again in your pagereference method. - legact=[select id,submit_done__c,entry_by__c from legal_action__c where id=:currentid];

Let me know if it does not work.
Thiyagarajan Selvaraj (SFDC Developer)Thiyagarajan Selvaraj (SFDC Developer)
Hi Vigneshwaran Loganathan,

Change your query on line 18 like following
legact = [SELECT id,Name_of_Client__c,submit_done__c,Name_of_VA__c,entry_by__c,reviewed_by__C,Summary_of_Situation__c,Attachment_summary__c, Attachment_summary__c from legal_action__c where id=:currentid];



 
This was selected as the best answer
Vigneshwaran LoganathanVigneshwaran Loganathan
Thank you all frnz :) :)