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
Richa_LearningRicha_Learning 

Populate a field on VF page

Hi,
I have this VF page for Custom object (invoice__c). User when they post comment it display the date, comments and who posted it. it shows like this from column (A to C). We woul like capture another field "Assigned To" (column D)  on this page. So when user write comments they assigned it to some other users.

User-added image

"Assgined To " is on the parent object (invoice__c) but i want to capture on child page too (invoice_detail__c)..here is my controller:
 
public with sharing class invoicedetails
{       
     Private final Id InvoiceId;
    
    public invoice_detail__c invoicedetail {get; set;}
   
      public invoice__c invoice {get; set;}
        
    public list<Invoice_detail__c> details
    {
        get
        {
            try
            {   
                string sRecordid=String.escapeSingleQuotes(InvoiceId);  
                
                list<Invoice_detail__c> tempdata = new list<Invoice_detail__c>();
				
                
                
                    tempdata = [select Date__c, Text__c ,createdbyid from Invoice_detail__c where Invoice__c=:InvoiceId order by Response_Date__c desc limit 50000];
                    
                    system.debug('\n----'+tempdata);    
		
                          
                return tempdata;
            }
            catch(exception ex)
            {
                return new list<Invoice_detail__c> ();
                
            }
        }
    }
       
   
    public invoicedetails(ApexPages.StandardController controller)     
    {       
        try
        {
            InvoiceId = controller.getId();
           
            invoicedetail = new Invoice_detail__c();   
            invoice = new Invoice__c(); 
         
        }
                
    }
        
        public Pagereference saveResponse()
    {
        try
        {   
            String sRecordid=String.escapeSingleQuotes(InvoiceId);  
            
                      
            if((sRecordid.length() == 15 || sRecordid.length() == 18) && Pattern.matches('^[a-zA-Z0-9]*$', sRecordid))
            {
                if(checkParticipants(sRecordid))
                {
                    invoicedetail.Invoice__c=InvoiceId;
            
                    //use for date and time(march release)
                     invoicedetail.Response_Date__c=Datetime.now();
                    system.debug('\n----invoicedetail--'+invoicedetail);
                    insert invoicedetail;
                   
                    invoice.id = InvoiceId;
                   
                   
                   
                    invoice = new Invoice__c();
                    
                    invoicedetail = new Invoice_detail__c();
                    PageReference CurrentPage = new PageReference('/'+InvoiceId);
                    CurrentPage.setRedirect(true);
                    return CurrentPage;                 
                }
                
            }
            return null;
        }
        
    }
   
 
}

Please help.
Swayam@SalesforceGuySwayam@SalesforceGuy
Hi,

First you need to create a field on Child Object for storing the value, then refer the vaule in VF page and use same code it will work.

Please let me know

--
Thanks,
Swayam
Richa_LearningRicha_Learning
I did create a text field. Adde on page layout and also added on the query. But i need to copy value from parent object (invoice__c) field = user__c to this next text field.
 
tempdata = [select assigned__c,Date__c, Text__c ,createdbyid from Invoice_detail__c where Invoice__c=:InvoiceId order by Response_Date__c desc limit 50000];


It's a process that user has to go to parent obecjt an assign to user__c. I need to copy that value from user__c to assgined__c.
Swayam@SalesforceGuySwayam@SalesforceGuy
Hi,

No need to copy the value from Parent object, simplly instead of creating  Text field, use formula field, (Refrence to the inovice__r.User__c), It wil auto populate.

Hope this helps,

--
Thanks,
Swayam
Richa_LearningRicha_Learning
if it is a formula field then i will be updated for all rows. I am looking for something like this:

I added a comment, today and assigned to David. Later
Mary posted the comments and asigne to Geroge.

User-added image

If I will use Formula, then for each row it will show the exisitng Assigned person. I want to kep track in the form so it is easy to check who assigned to comment to whom.