• Naidu Sagvi
  • NEWBIE
  • 0 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 4
    Replies
rajesh Admin 
Hi Every one...Actually i getting System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Body]: [Body]
My task is,we have a button while clicking that popup should be open and having one input file component and two buttons.If select file then click save button,it will be store a coresponding case.
But that time i am getting missing required field of body error.i am attaching my Vf Page and Apex code.will any one able to slove that ,it's very helps to me...

Thanks U in Advance....

Vf Page:
=======
<apex:page controller="AccountController12" >
      <apex:sectionHeader title="Account" subtitle="Home" help="Help for this Page"/>
      <apex:form >
            <apex:pageBlock title="Recent Accounts">
                  <apex:selectList value="{!selectedAccId}" size="1">
                        <apex:selectOptions value="{!AccountNames}" />
                        <apex:actionSupport event="onchange" action="{!displaycaselist}"/>
                  </apex:selectList>
                  <apex:pageMessages />
                   
                   <apex:pageBlockTable value="{!caselst}" var="cse">          
                             
                              <apex:column HeaderValue="Case Number" >
                                    <apex:outputLink value="/apex/caseinformation?id={!cse.id}">
                                         {!cse.caseNumber}
                                    </apex:outputLink>
                              </apex:column>
                        
                             <apex:column value="{!cse.Subject}" HeaderValue="Subject"/>
                             <apex:column value="{!cse.Status}" HeaderValue="Status"/>
                             <apex:column value="{!cse.createdDate}" HeaderValue="Created Date"/>
                             <apex:column value="{!cse.createdBy.name}" HeaderValue="CReated By"/>
                             <apex:column value="{!cse.account.name}" HeaderValue="Account Name"/> 
                        
                             <apex:column HeaderValue="Attachment">                       
                                   <apex:commandButton image="/img/func_icons/util/link20.gif" action="{!showPopup1}" rerender="tstpopup1" >
                                         <apex:param name="caseid"  value="{!cse.id}" />
                                   </apex:commandButton>
                                  
                                  
                                                 <apex:outputPanel id="tstpopup1">       
                                                 <apex:outputPanel styleClass="custPopup" layout="block" rendered="{!displayPopUp}">           
                                       <center>   
                                              <apex:inputFile value="{!attachment.body}" filename="{!attachment.name}"  /><br/>
                                              <apex:commandButton action="{!upload}" value="Select Attachment"/>
                                              <apex:commandButton value="Cancle" action="{!closePopup}" />
                                       </center>              
                                </apex:outputPanel>
                             </apex:outputPanel>
                                  
                                  
                             </apex:column>
                       
                             <apex:column HeaderValue="Comment" >
                                   <apex:commandButton image="/img/icon/documents32.png" action="{!showPopup}" rerender="tstpopup" >
                                         <apex:param name="caseid"  value="{!cse.id}" />
                                   </apex:commandButton>
                             </apex:column> 
                                                     
                    </apex:pageBlockTable>
            </apex:pageBlock>
                
                
                
                
                
              <apex:outputPanel id="tstpopup">       
              <apex:outputPanel styleClass="custPopup" layout="block" rendered="{!displayPopUp}">           
                   <center>   
                        <apex:inputTextarea value="{!textvalue}" /><br/>
                        <apex:commandButton value="Save" action="{!SaveComment}" />
                        <apex:commandButton value="Cancle" action="{!closePopup}" />
                   </center>              
            </apex:outputPanel>
         </apex:outputPanel>
             
       
     </apex:form>
    
      <style type="text/css">
        .custPopup{
            background-color: yellow;
            z-index: 9999;
            left: 50%;
            padding:10px;
            position: absolute;
            width: 700px;
            margin-left: -250px;
            top:100px;
            border-style: none;
        }
       
       
    </style>
    
    
</apex:page>


Apex:
=====
public with sharing class AccountController12 {


    public blob bodyfile{get; set;}
    public boolean displayPopup {get; set;}
    public string textvalue{get; set;}
    public string showPopup1{get; set;}
    public string showPopup{get; set;}
    public attachment attachment { get {if (attachment == null) attachment = new Attachment(); return attachment; }  set;}
    public list<case> caselst { get; set; }
    public String selectedAccId{get;set;}
    //public string caseid {get; set { caseid = value; if (!displayPopup) { upload(); displayPopup = true; } } }
    public string caseid {get; set ;}
    public string keepvalue {get; set;}
    public List<SelectOption> getAccountNames() {
        List<SelectOption> accOptions = new List<SelectOption>();
            accOptions.add( new SelectOption('','--Select--'));
            for( Account acc : [select Id,name from Account ] ) {
                      accOptions.add( new SelectOption(acc.Id,acc.name));
                 }
                    return accOptions;
          }

 
    public void displaycaselist() {
   
        caselst = new list<case>();
        caselst=[SELECT id,CaseNumber,Subject,Account.name,createdBy.name,createdDate,Status,accountid FROM Case where accountid=:selectedAccId];
             if(caselst == null || caselst.size() == 0){
                ApexPages.addMessage(new ApexPages.message(ApexPages.Severity.ERROR, 'No Corresponding Case Record'));
             }
    }
 
    public void showPopup1() {
        displayPopup = true;       
        String caseid= System.currentPageReference().getParameters().get('caseid');       
        system.debug('========>'+caseid);
        system.debug('=========>'+bodyfile);
        keepvalue = caseid ;
        bodyfile=attachment.body;               
    }           
          
    public PageReference upload() {
    system.debug('=====>'+bodyfile);
    attachment attachment1 = new Attachment();        
        attachment1.OwnerId = UserInfo.getUserId();
        attachment1.parentid = keepvalue;
        attachment1.name ='true';          
        attachment1.body = bodyfile;
 
      insert attachment1 ;
 
    PageReference pageRef = new PageReference('/apex/casesmmary3');  
       pageRef.setRedirect(true);  
       return pageRef ;

     }
    
public AccountController12 (){
String caseid = System.currentPageReference().getParameters().get('caseid');
//String caseid = apexpages.currentpage().getparameters().get('caseid');
        system.debug('========>'+caseid);
}
  

    public void showPopup() {
        displayPopup = true;
        String caseid = System.currentPageReference().getParameters().get('caseid');
        system.debug('========>'+caseid);
        system.debug('========>'+textvalue);
        keepvalue = caseid ;
    }  
  
    public PageReference SaveComment(){      
        caseComment cc = new caseComment();
        cc.CommentBody = textvalue;
        cc.parentid = keepvalue;
        insert cc;            
        PageReference pageRef = new PageReference('/apex/casesmmary3');  
        pageRef.setRedirect(true);               
        return pageRef ; 
  }
    public void closePopup() {   
        displayPopup = false;   
    }   
   
    

}
My task is,we have a button while clicking that popup should be open and having one input file component and two buttons.If select file then click save button,it will be store a coresponding case.
But that time i am getting missing required field of body error.i am attaching my Vf Page and Apex code.will any one able to slove that ,it's very helps to me...

Thanks U in Advance....

Vf Page:
=======
<apex:page controller="AccountController12" >
      <apex:sectionHeader title="Account" subtitle="Home" help="Help for this Page"/>
      <apex:form >
            <apex:pageBlock title="Recent Accounts">
                  <apex:selectList value="{!selectedAccId}" size="1">
                        <apex:selectOptions value="{!AccountNames}" />
                        <apex:actionSupport event="onchange" action="{!displaycaselist}"/>
                  </apex:selectList>
                  <apex:pageMessages />
                   
                   <apex:pageBlockTable value="{!caselst}" var="cse">          
                             
                              <apex:column HeaderValue="Case Number" >
                                    <apex:outputLink value="/apex/caseinformation?id={!cse.id}">
                                         {!cse.caseNumber}
                                    </apex:outputLink>
                              </apex:column>
                        
                             <apex:column value="{!cse.Subject}" HeaderValue="Subject"/>
                             <apex:column value="{!cse.Status}" HeaderValue="Status"/>
                             <apex:column value="{!cse.createdDate}" HeaderValue="Created Date"/>
                             <apex:column value="{!cse.createdBy.name}" HeaderValue="CReated By"/>
                             <apex:column value="{!cse.account.name}" HeaderValue="Account Name"/> 
                        
                             <apex:column HeaderValue="Attachment">                       
                                   <apex:commandButton image="/img/func_icons/util/link20.gif" action="{!showPopup1}" rerender="tstpopup1" >
                                         <apex:param name="caseid"  value="{!cse.id}" />
                                   </apex:commandButton>
                                  
                                  
                                                 <apex:outputPanel id="tstpopup1">       
                                                 <apex:outputPanel styleClass="custPopup" layout="block" rendered="{!displayPopUp}">           
                                       <center>   
                                              <apex:inputFile value="{!attachment.body}" filename="{!attachment.name}"  /><br/>
                                              <apex:commandButton action="{!upload}" value="Select Attachment"/>
                                              <apex:commandButton value="Cancle" action="{!closePopup}" />
                                       </center>              
                                </apex:outputPanel>
                             </apex:outputPanel>
                                  
                                  
                             </apex:column>
                       
                             <apex:column HeaderValue="Comment" >
                                   <apex:commandButton image="/img/icon/documents32.png" action="{!showPopup}" rerender="tstpopup" >
                                         <apex:param name="caseid"  value="{!cse.id}" />
                                   </apex:commandButton>
                             </apex:column> 
                                                     
                    </apex:pageBlockTable>
            </apex:pageBlock>
                
                
                
                
                
              <apex:outputPanel id="tstpopup">       
              <apex:outputPanel styleClass="custPopup" layout="block" rendered="{!displayPopUp}">           
                   <center>   
                        <apex:inputTextarea value="{!textvalue}" /><br/>
                        <apex:commandButton value="Save" action="{!SaveComment}" />
                        <apex:commandButton value="Cancle" action="{!closePopup}" />
                   </center>              
            </apex:outputPanel>
         </apex:outputPanel>
             
       
     </apex:form>
    
      <style type="text/css">
        .custPopup{
            background-color: yellow;
            z-index: 9999;
            left: 50%;
            padding:10px;
            position: absolute;
            width: 700px;
            margin-left: -250px;
            top:100px;
            border-style: none;
        }
       
       
    </style>
    
    
</apex:page>


Apex:
=====
public with sharing class AccountController12 {


    public blob bodyfile{get; set;}
    public boolean displayPopup {get; set;}
    public string textvalue{get; set;}
    public string showPopup1{get; set;}
    public string showPopup{get; set;}
    public attachment attachment { get {if (attachment == null) attachment = new Attachment(); return attachment; }  set;}
    public list<case> caselst { get; set; }
    public String selectedAccId{get;set;}
    //public string caseid {get; set { caseid = value; if (!displayPopup) { upload(); displayPopup = true; } } }
    public string caseid {get; set ;}
    public string keepvalue {get; set;}
    public List<SelectOption> getAccountNames() {
        List<SelectOption> accOptions = new List<SelectOption>();
            accOptions.add( new SelectOption('','--Select--'));
            for( Account acc : [select Id,name from Account ] ) {
                      accOptions.add( new SelectOption(acc.Id,acc.name));
                 }
                    return accOptions;
          }

 
    public void displaycaselist() {
   
        caselst = new list<case>();
        caselst=[SELECT id,CaseNumber,Subject,Account.name,createdBy.name,createdDate,Status,accountid FROM Case where accountid=:selectedAccId];
             if(caselst == null || caselst.size() == 0){
                ApexPages.addMessage(new ApexPages.message(ApexPages.Severity.ERROR, 'No Corresponding Case Record'));
             }
    }
 
    public void showPopup1() {
        displayPopup = true;       
        String caseid= System.currentPageReference().getParameters().get('caseid');       
        system.debug('========>'+caseid);
        system.debug('=========>'+bodyfile);
        keepvalue = caseid ;
        bodyfile=attachment.body;               
    }           
          
    public PageReference upload() {
    system.debug('=====>'+bodyfile);
    attachment attachment1 = new Attachment();        
        attachment1.OwnerId = UserInfo.getUserId();
        attachment1.parentid = keepvalue;
        attachment1.name ='true';          
        attachment1.body = bodyfile;
 
      insert attachment1 ;
 
    PageReference pageRef = new PageReference('/apex/casesmmary3');  
       pageRef.setRedirect(true);  
       return pageRef ;

     }
    
public AccountController12 (){
String caseid = System.currentPageReference().getParameters().get('caseid');
//String caseid = apexpages.currentpage().getparameters().get('caseid');
        system.debug('========>'+caseid);
}
  

    public void showPopup() {
        displayPopup = true;
        String caseid = System.currentPageReference().getParameters().get('caseid');
        system.debug('========>'+caseid);
        system.debug('========>'+textvalue);
        keepvalue = caseid ;
    }  
  
    public PageReference SaveComment(){      
        caseComment cc = new caseComment();
        cc.CommentBody = textvalue;
        cc.parentid = keepvalue;
        insert cc;            
        PageReference pageRef = new PageReference('/apex/casesmmary3');  
        pageRef.setRedirect(true);               
        return pageRef ; 
  }
    public void closePopup() {   
        displayPopup = false;   
    }   
   
    

}
Hi. I'm sure alot of people have run into this type of issue.
Basically, I have a Parent record, and Child record that I want to load via Data Loader.
Since its an Insert (or Upsert), I wouldn't know the "Parent ID" initially.
So I'd have to:
insert/upsert the parent.
Grab the Parent ID and paste the Parent ID to the reference ID in the Child record.

This is a pain especially if i am loading a lot of parent-child related records. Is there even an easier work around in data loader?

Hi

 

I am little confuse about read-only and read/write access record in sharing rules?

 

what these statements(read-only and read/write) exactly tells. 

 

 

regards

Hi,

 

How can i create one-to-one relationship between two custom objects in salesforce.com. 

 

Example: I have two custom objects having following details:

 

1) Employee (Name, PanCardNo)

2)PanCard(PanCardNo Name_on_card)

 

I have gone through documents of salesforce, but i can able to find out only lookup (One-to-many raltionship) and master-detail relationship(many-to-many relationship).

 

Is there any way to create one-to-one relationship??

 

Regards

kamlesh kumar