+ Start a Discussion
subodh chaturvedi 17subodh chaturvedi 17 

i am not getting the parent id through getRecord() in standard controller

I have a visual force page where whenever I am trying to create a new record it is giving me an error.
System.QueryException: Apply_Cash_Fees_to_Promo_Transactions__c, AQ_table_ID__c, Charge_Cash_Item_Fees__c ^ ERROR at Row:1:Column:90 invalid ID field: null 
Class.NewTLPController.<init>: line 22, column 1

The above query has parent object fields. For the Existing record, my code works properly But during the creation of new Record, the above error occurs. Below is my class 

public with sharing class NewTLPController
        //Instance Variables 
       public List<TLP_System_Prin__c> TLPList {get;set;}
       public List<TLP_System_Prin__c> TLPAddList {get;set;}
       public TLP__c tlpRecord;
       public List<TLP_System_Prin__c> tlpSysPrinList;
       ApexPages.StandardController controller;
        //standard controller constructor
        public NewTLPController(ApexPages.StandardController con) {
            controller =con;  
            tlpRecord = (TLP__c)con.getRecord();
            String queryData = 'SELECT Agent__c,System_Prin__c,MarkedforDeletion__c,TLP__c FROM TLP_System_Prin__c WHERE TLP__c=\''+tlpRecord.Id+'\'';
            TLPList = Database.Query(queryData);
                TLPAddList = new List<TLP_System_Prin__c>();    
                TLPAddList = new List<TLP_System_Prin__c>();    
        //Method is used to add the Multiple rows.
        public void AddRow()
            TLPAddList.add(new TLP_System_Prin__c());
        //Method is used to remove the rows.
        public void removerow(){
            Integer i = TLPAddList.size();
       //Method is used to save the TLP record & also save the Multiple row data. 
       public pageReference saveAll()
           TLP__c tlpRec = (TLP__c)controller.getRecord();
           upsert tlpRec;
           for(TLP_System_Prin__c tsp:TLPAddList)
                    tsp.TLP__c = tlpRec.Id;    
            upsert TLPAddList;    
           return new PageReference('/'+tlpRec.Id);
Hello Subodh,

How you are calling your visualforce page using custom java script code or directly overiding a button with visualforce page.