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
salesforce User 15salesforce User 15 

Contract & Legal Attachment section for standard Object Account records

 public class ContractAttachment{

      public Contract_Document__c vWDoc{get;set;}
     public Attachment attachContract {get;set;} 
      
     public Account acct;

      public ContractAttachment(ApexPages.StandardController stdController) {
               
                 acct = [SELECT Id, Name,RecordTypeId FROM Account WHERE Id = '001f000000gwjoO'];
                 RecordType rt =[Select Id,Name From RecordType Where SobjectType='Account' and Id ='012E00000001vtF'];
                 acct.RecordTypeId = rt.Id;              
               
                 attachContract = new Attachment();
                 vWDoc = new Contract_Document__c();
                 this.vWDoc = (Contract_Document__c)stdController.getRecord();
                 acct.Id = vWDoc.Id;       
                      }
             
    
      public PageReference saveAttachment(){  
                          
                vWDoc.Size__c = String.valueOf(attachContract.bodyLength/1024)+'KB';
                insert vWDoc;
               
                attachContract.ParentId =vWDoc.Id;
                insert attachContract;
                    
       PageReference nextPage = new PageReference('/' + vWDoc.Id);
         return nextPage;     
                   }
      
     }

The custom object Contract_Document__c is not seen in the Account Object. any suggestion?

Best Answer chosen by salesforce User 15
salesforce User 15salesforce User 15
Solved

All Answers

Avidev9Avidev9
Looks like you are not populating the Account__c lookup in the Contract object anywhere .
salesforce User 15salesforce User 15
Hi Can you please tell me how to attach my  Contract_Document__c custom object to an Account With ID='001f000000gwjoO'. Actually my custom object contains fields to attach a document and this custom object shoul should go under the above Account.
salesforce User 15salesforce User 15
Solved
This was selected as the best answer