• Chinnodu
  • NEWBIE
  • 40 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 63
    Questions
  • 14
    Replies
Hi,

I am getting bellow error.

Hi, 
i am trying to send an email- Sending a Document as an Attachment, i am getting below error.
Anybody can help me on this , exactely where iam getting the error.

Thanks,
Chinnu
public class SendingDocasattachmentExample {
    public pagereference sendDocAttach() {
        Document doc = [SELECT Id,Name FROM Document WHERE Name = 'attachment'];
        Messaging.SingleEmailMessage semail = new Messaging.SingleEmailMessage();
        semail.setDocumentAttachments(new ID[]{doc.id});
        semail.setSubject('Sending Document as attachemnt example');
        String[] sendTo = new String[]{'test.dm2@gmail.com'};
        semail.setToAddresses(sendTo);
        semail.setPlainTextBody('Please find the attached document details');
        Messaging.sendEmail(new Messaging.SingleEmailMessage[]{semail});
        return null;
    }
}

 
Hi All,

How to erase value from text field while updating record?

Reauirement :
i have one text field, while creating a record it is required field and while updating same record, i would be erase value from text field.?

please let me know how can i achive this .Give me example code also.

Thanks in advance.
China
Hi All ,


Here my requirement is while creting a record i need required field and updaing the same record i don't want required field.

Example:
I) I Have one custom object Employee__c and field is DOB.Now  while creating a record i need required field , if value is not there , then it showing required value is missing
 2) I want update on same record then i have remove value from DOB field at that time i don't want required value.

Please suggest me, how can achive with example code.


Thanks in Advance.
Chinna
Hi All,
I am stuck at Step 2. Getting following error :-

Please help me on this .

User-added image
Please see the below code :
 
BoarsearchFormController.js


({
	doInit : function(component, event, helper){
        var action = component.get("c.getBoatTypes");
        action.setCallback(this, function(response) {
            var state = response.getState();
            if (state === "SUCCESS") {
                component.set("v.boatTypes", response.getReturnValue());
            }
            else {
                console.log("Failed with state: " + state);
            }
        });
        // Send action off to be executed
        $A.enqueueAction(action);
    },
    
   
    
    
    createRecord : function (component, event, helper) {
        var BoatTypeid = component.find("boatType").get("v.value");
        var createRecordEvent = $A.get("e.force:createRecord");
        if(!$A.util.isEmpty(BoatTypeid)){
            createRecordEvent.setParams({
                'entityApiName': 'Boat__c',
                'defaultFieldValues':{
                    'BoatType__c' : BoatTypeid
                }
            });
            createRecordEvent.fire();
        }else{
            createRecordEvent.setParams({
                'entityApiName': 'Boat__c'
            });
            createRecordEvent.fire();
        }
    } ,
    eventhandler : function (component, event, helper) {
        
    } */
})



BoatSearchForm.cmp:


<aura:component controller="BoatTypes" implements="force:appHostable,flexipage:availableForAllPageTypes"  access="global" >
    <lightning:card title="Find a Boat"  class="slds-align_absolute-Left" >
    </lightning:card>
   
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>    
    <aura:handler name="init" value="{!this}" action="{!c.newBoat}"/>
    <aura:attribute name="boatTypes" type="BoatType__c[]"/>
     <aura:attribute name="selectedType" type="String" default="foo"/>
    <aura:attribute name="showNewButton" type="boolean" default="true"/>
    
    <!--<aura:registerEvent name="launchNewBoatForm" type="c:launchNewBoatForm"/>
    <aura:handler name="launchNewBoatForm" event="c:launchNewBoatForm" action="{!c.eventhandler}"/>-->


    <lightning:layout horizontalAlign="center" verticalAlign="end">

       <lightning:layoutItem class="slds-grid_vertical-align-center" padding="around-small" > 

           <lightning:select aura:id="boatSelect"  label=""  name="selectItem">
             <aura:iteration items="{!v.boatTypes}" var="boatType">
                 <option value="" text="All Types"/>
                 <option value="{!boatType.id}" text="{!boatType.Name}"></option>
             </aura:iteration>
         </lightning:select>
       </lightning:layoutItem>

       <lightning:layoutItem class="slds-grid_vertical-align-center" padding="around-small"> 
         <lightning:button label="Search" variant="brand"  />
         <aura:if isTrue="{!v.showNewButton}">
            <lightning:button variant="neutral" label="New" onclick="{!c.newBoat}"/>
        </aura:if>
       </lightning:layoutItem>

    </lightning:layout>

</aura:component>

 
Hi All,

How to display the records in visulaforce page without command button and commmand link? kindly suggest me.

Please provide the example withcode .
Thank you,
Chinnodu
Hi All,

I have an account object, I have a status field which has open and completed checkboxes, when ever I click on completed, I want an opportunity to be created automatically.

it will get trigger, how i will get from trigger , any one can help me on this with example functionalty

Thanks,
Chinna
 
Hi All,
Actally i have one custom field<Account_name__c > on custom object (Jibber__c).This field Account_name__c is master detail relationship having on Account.object.

Now i want dispaly readonly with value on visualforcepage. 

Kindly help me..Please see the below my screen shot 
User-added image

Thanks,
Chinni
Hi Experts,

I have two fileds both are custom fields(Picklist) on custom object. but there is now
dependencies between fields. Now my reuirment is how to display the region based on country in visualforce page

1)Country__c 2 ) Region

For an example : Values of Country : India, USA, Japan   2) Values of Region : X, Y, Z.

Whenever i will select India from Country, i need display "Y"  in region picklist.
                                         USA from Country i need display X    in region picklist.

Kindly help me .

Thank you,
Chinnodu


 
Hi Experts,

I need help on reports,

I have run a report on task when status is Completed, but i did not see old any records on Status= completd and i gor only new records. please let me know the reason

Ex: I have tired for below with sriteria.

Status= completed and prioriaty =high and assigned alias=ram and subject= test and createdate= 08/14/16
But  i did  not receive any records on reports.

Please find aatached screen shot for your refrence

User-added imageUser-added image

Please help me 
Thanks,
Hi Experts,

I would like to remove the standard button(Find Articles) to community users ?

Actually i have written below code but it is working for internalusers . now i want remove the standardbutton(Find Articles) from customer portal (community users ) in visualforce page 

<style type="text/css">
      input.btn[value="Find Articles"] {
            display: none !important;
     }   
    </style>
    

Kindly help me on this.

Chinnodu
HI, 

while page is loading how to do display the pop-up alert based on days in visualforce page. very urgent, kindly do the needful

Thanks,
Chinnodu

 
Hi Experts, 

Actually i want popupp messge alert when" a Case is opened for more than 48 hours for the Product Set Archer" now it is working. but what happen here while creating a new case at that time also i am getting popup message alert. please let me know how to avoid in visualforce page.


please see the my code
 
function displayAACNotification() 
        {   //alert('test'); 
            //alert('AAC function'+ {!Case.Number_of_hours_back_case_created__c}); 
            var caseHours = '{!Case.Number_of_hours_back_case_created__c}'; 
            var AAC = '{!Case.PL_Affected_Area_Category__c}'; 
            var AASC1 = '{!Case.PL_Affected_Area_Subcategory__c}'; 
            var AASC2 = '{!Case.PL_Affected_Area_Subcategory2__c}'; 
            Var AASD='{!Case.Affecte_Date__c}'; 
            var Type="{!Case.Type__c}"; 
            var cowner = '{!Case.OwnerId}'; 
            var recordtypeName='{!objRecordType.Name}'; 
            var PRODSET = '{!Case.PL_RSA_Product_Set__c}'; 
            var CDate = '{!Case.CreatedDate}'; 
            
            sforce.connection.sessionId = "{!$Api.Session_ID}";         
            console.log(sforce.connection.getUserInfo().userId); 
           var usrid = sforce.connection.getUserInfo().userId; 
              //alert(sforce.connection.getUserInfo().userId); 
             
             
                   
              if((recordtypeName=="Customer Support"  && usrid == cowner) && ((AAC == null || AAC =='') || (AASC1 == null || AASC1 == '')) && (Type == 'Technical Support' && PRODSET == 'Archer' && (AASD-CreatedDate)>2)))

            { 
                
                alert('Affected Area Category and Subcategory1 are required by the Case Owner when a Case is opened for more than 48 hours for the Product Set Archer. Please update the values before proceeding.');

            } 
        }



Thanks,
Chinnodu
Hi Experts ,

This is my requirement, i have 5 users, these users have same profile and same role, but i want only one user can't able to see the related list case comments on detal page , how i can achive this ,kindly do the needful.

thanks.
chinnodu
Hi All,

I am not able to see the Case comments option on case.  Except this option remaing values are came like : Articles, emails, case history, and open activities. already i have added from customize page. still i am facing the issue. kindly help me on this

Please see attached screen shot 
User-added image



Thanks,
Chinnodu

 
HI Experts,

i have written a test class but i got code coverage 65%, i need more than 75%. kindly help me on this.
 
@istest
public class AccConUpd_test
{
 static testMethod void testMethod1() 
 {
 
 Account testAccount = new Account();
    testAccount.Name='Test Account' ;
    
    insert testAccount;
 
 Contact cont = new Contact();
        cont.FirstName='a1123';
        cont.LastName='rest';
        cont.Accountid= '0019000001xfaMI';
        cont.Employee_Id__c='1091637612';
        cont.PAN_Number__c='apgffg';
        cont.Working_Days_Per_Week__c=7;
        cont.Phone='12344';
        
        insert cont;
 }
}

User-added image


Thanks!

Sai
Hi Experts,

I have written a test class , test method does not passed and i got cobut i am getting  below error. how to i will fix , kindly suggest me.

System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Body]: [Body].


public class caseattachment
{
public case objcase{get;set;}
public Attachment myAttachment{get;set;}
public string fileName{get;set;} 
public Blob fileBody{get;set;}

    public caseattachment(Apexpages.standardcontroller controller)
    {
        objcase = new case();
        myAttachment =new Attachment();
    }
    public pagereference save()
    {
        insert objcase;
        System.debug('@@@@@fileBody'+fileBody);     
        myAttachment  = new Attachment();
              Integer i=0;
              myAttachment .clear();
              myAttachment.Body = fileBody; 
              myAttachment.Name = 'Logo_'+objcase.id+'.jpeg' ; 
              myAttachment.ParentId = objcase.id;             
              insert myAttachment;                 
        pagereference pr = new pagereference('/'+objcase.id);                           
        return pr;
    }
}

Please see attached the my screen shot User-added image
@isTest
private class caseattachment1{

    static testMethod void testCaseExt() {
        // Create the Case Record.
        Case cas = new Case( Priority = 'Medium',Status= 'Working',Origin= 'Phone'); 
        insert cas;
        Attachment attach=new Attachment();     
        attach.Name='Unit Test Attachment';
        Blob fileBody=Blob.valueOf('Unit Test Attachment Body');
        attach.body=fileBody;
        attach.parentId=cas.id;
        insert attach;
        
        
         ApexPages.StandardController sc = new ApexPages.StandardController(cas);
        caseattachment cec= new caseattachment(sc);
        
         
        cec.save();
       
    }
}

 
HI All,

while creating a case by partner user ,at that time only partner user can't able to see the other records in detailpage. please let me know how we can achive this

Kindly help me .

Thanks,
Sai
HI Dudes,
I want required on text box ased on picklist value. i having text field is :"Office_Phone__c" and picklist value "Department__c".When evar i can set as Department__c==Department__c"" for that time i want rerquird "Office_Phone__c" filed.
Pls help mr for below code.
<apex:page controller="employmenthistiry" sidebar="true">
    <apex:form >
        <apex:pageBlock id="pgBlckId">
            <apex:pageBlockSection title="Employe" collapsible="false">
                    
                    <apex:inputField value="{! emp.Report__c}"/>
                    <apex:inputField value="{! emp.Name }"/>
                    <apex:inputField value="{! emp.Date_of_joining__c}"/>
                    <apex:inputField value="{! emp.Department__c}"/>
                    
                    <apex:inputField value="{! emp.Desigination__c}"/>
                    <apex:inputField value="{! emp.Email__c}" required="true"/>
                    <apex:inputField value="{! emp.Employeeid__c}"/>
                    <apex:inputField value="{! emp.Mobile__c }"/>
                    <apex:inputField value="{! emp.Office_Phone__c}" required="!IF(emp.Department__c=='IT',true,false)}" id="Office_phonerequired"/>
                    <apex:inputField value="{! emp.payslip_lase_sent_date__c}"/>
                    <apex:inputField value="{! emp.Technology__c}"/>
                  </apex:pageBlockSection>
</apex:pageblock>
</apex:form>
</apex:page>
Regards,
sai
 
HI ,
How to reduce the permissions for two users at a time ? Below is my requirement:
I have five users , now i want reduce the access to TWO users..if it's possible.pls explain this.

Thanks,
Viswa
Hi Experts,

when we go to Contact and Enable as Partner User, that time, one email is sent to user. In that email there is a link to visualforce page
When that user clicks on the link, VF page opens where he has to click Accept button (to Accept terms and conditions). After that only the User is enabled. Also when we enable as Partner User, there is a field i User object (Activation Link Sent Date) which is populated when the email is sent
 
Hi All,

How to erase value from text field while updating record?

Reauirement :
i have one text field, while creating a record it is required field and while updating same record, i would be erase value from text field.?

please let me know how can i achive this .Give me example code also.

Thanks in advance.
China
Hi All ,


Here my requirement is while creting a record i need required field and updaing the same record i don't want required field.

Example:
I) I Have one custom object Employee__c and field is DOB.Now  while creating a record i need required field , if value is not there , then it showing required value is missing
 2) I want update on same record then i have remove value from DOB field at that time i don't want required value.

Please suggest me, how can achive with example code.


Thanks in Advance.
Chinna
Hi All,

I have an account object, I have a status field which has open and completed checkboxes, when ever I click on completed, I want an opportunity to be created automatically.

it will get trigger, how i will get from trigger , any one can help me on this with example functionalty

Thanks,
Chinna
 
HI Experts,

i have written a test class but i got code coverage 65%, i need more than 75%. kindly help me on this.
 
@istest
public class AccConUpd_test
{
 static testMethod void testMethod1() 
 {
 
 Account testAccount = new Account();
    testAccount.Name='Test Account' ;
    
    insert testAccount;
 
 Contact cont = new Contact();
        cont.FirstName='a1123';
        cont.LastName='rest';
        cont.Accountid= '0019000001xfaMI';
        cont.Employee_Id__c='1091637612';
        cont.PAN_Number__c='apgffg';
        cont.Working_Days_Per_Week__c=7;
        cont.Phone='12344';
        
        insert cont;
 }
}

User-added image


Thanks!

Sai
HI Apex EXPERTSxperts,

I got Below error on Apex class as well as i have attached with my class , Could you please help me

System.NullPointerException: Attempt to de-reference a null object
Error is in expression '{!doAttach}' in component <apex:commandButton> in page gbocase: Class.gboCaseController.doAttach: line 316, column 1
Class.gboCaseController.doAttach: line 316, column 1.
public class gboCaseController {
Public Transient BLOB attachmentBody{get; set;}        
Public String attachmentName{get; set;}
Public Attachment objCaseAtt {get; set;}
public String caseId{get; set;} 
 
Public List<Attachment> lst_attch{get; set;} 
        
    
    public gboCaseController(ApexPages.StandardController controller) {
       objCaseAtt = new Attachment(); 
    
    caseId = ApexPages.CurrentPage().getParameters().get('id');
    }
    
    public Case c { get; set; }
    
    /*Public string str {get; set;}
public List<SelectOption> getTypeOptions() 
{
List<SelectOption> options = new List<SelectOption>();
String Opt = '';
List<String> strList = new List<String>();
List<Channel_Type__c> listVals = Channel_Type__c.getAll().values();
For(Channel_Type__c ChnlType: listVals )
{
if(ChnlType.Case_Type__c=='Channel')
{
Opt =  ChnlType.Record_Type__c;
strList.Add(Opt);      
}
}
strList.sort();
options.add(new SelectOption('','--None--'));
for(String str : strList)
{
options.add(new SelectOption(str,str));
}
return options;
}*/
    
    //CaseVO caseVO = new CaseVO();
    
    //  public CaseRecordType caseRecordType ;
    //   
    /*  public void setCaseVO (CaseVO caseVO ) 
{
caseVO = caseVO;
}
public CaseVO getCaseVO () 
{
return caseVO ;
}   */
    
    public gboCaseController() {
        //c = new Case(RecordTypeId = '012560000000DrN');
        Id recTypeId = [Select Id, Name from RecordType where Name = 'GBOCase'][0].Id;
        c = new Case(RecordTypeId = recTypeId);
        c.Priority = 'Medium';
        //c.Record_Type__C = 'GBOcase';
      
        
    }
    public PageReference submitCase() {
        boolean isMandatoryFailed = false;
        if(c.SuppliedName== null || c.SuppliedName==''){
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Error,'Please Enter Contact Name'));
            isMandatoryFailed = true;   
            
        }
        if(c.SuppliedCompany== null || c.SuppliedCompany==''){
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Error,'Please Enter Company'));   
            isMandatoryFailed = true;   
            
        }
        if(c.SuppliedEmail== null || c.SuppliedEmail=='' ){
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Error,'Please Enter Email'));   
            isMandatoryFailed = true;   
            
        }
        if(c.suppliedEmail.contains('@gmail.com')|| c.suppliedEmail.contains('@yahoo.com')|| c.suppliedEmail.contains('@hotmail.com')){
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Error,'Please enter valid business email'));   
            isMandatoryFailed = true;   
            
        }
        if(c.SuppliedPhone== null || c.SuppliedPhone==''){
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Error,'Please Enter Phone'));   
            isMandatoryFailed = true;   
            
        }
        if(c.To__c== null || c.To__c==''){
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Error,'Please pick up a value from To'));   
            isMandatoryFailed = true;   
        }
        
        if(c.GBO_Type__c== null || c.GBO_Type__c==''){
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Error,'Please pick up a value from GBOType'));   
            isMandatoryFailed = true;   
        }
        if(c.Subject== null || c.Subject==''){
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Error,'Please Enter Subject'));   
            isMandatoryFailed = true;
        }
        if(c.Description== null || c.Description==''){
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Error,'Please Enter Description'));   
            isMandatoryFailed = true;
        }
        if(c.Country__c== null || c.Country__c==''){
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Error,'Please Enter Country'));   
            isMandatoryFailed = true;
        }
        
        if(isMandatoryFailed){
            return null;
        }
        List<String> contList = new List<String>(); 
        try {
            Integer i=0;        
            // now look for an associated contact with the same email
            for(Contact cnt : [SELECT Id,Email FROM Contact WHERE Email = :c.SuppliedEmail]){
                if (cnt != null) {
                    contList.add(cnt.Id);
                    i++;
                }
            }
            If(contList!=null){
                if(i<1){
                    
                }else if(i>1){
                    
                }else if (i==1){
                    for(String contStr :contList)
                    {
                        c.ContactId=contStr;
                    }
                    
                }
            }
            
            
            // c.RecordTypeId=c.Record_Type__c;
            // Specify DML options to ensure the assignment rules are executed
            Database.DMLOptions dmlOpts = new Database.DMLOptions();
            dmlOpts.assignmentRuleHeader.useDefaultRule = true;
            c.setOptions(dmlOpts);
            c.Is_Submitted_From_Site__c = true;
            c.IsVisibleInSelfService = False; 
            // Insert the case
            INSERT c;
            PageReference redirectPage= new PageReference('https://www.rsa.com');
            return redirectPage;//new PageReference('/thanks');
        } catch (Exception e) {
            ApexPages.addMessages(e);
            System.debug('Exception in gboCaseController: '+e);
            return null;
        }
    }
    public PageReference submitCaseWithAttachment() {
        
        boolean isMandatoryFailed = false;
        if(c.SuppliedName== null || c.SuppliedName==''){
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Error,'Please Enter Contact Name'));
            isMandatoryFailed = true;   
            
        }
        if(c.SuppliedCompany== null || c.SuppliedCompany==''){
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Error,'Please Enter Company'));   
            isMandatoryFailed = true;   
            
        }
        if(c.SuppliedEmail== null || c.SuppliedEmail==''){
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Error,'Please Enter Email'));   
            isMandatoryFailed = true;   
            
        }
        if(c.suppliedEmail.contains('@gmail.com')|| c.suppliedEmail.contains('@yahoo.com')|| c.suppliedEmail.contains('@hotmail.com')){
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Error,'Please enter valid business email'));   
            isMandatoryFailed = true;   
            
        }
        if(c.SuppliedPhone== null || c.SuppliedPhone==''){
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Error,'Please Enter Phone'));   
            isMandatoryFailed = true;   
            
        }
        if(c.To__c== null || c.To__c==''){
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Error,'Please pick up a value from To'));   
            isMandatoryFailed = true;   
        }
        if(c.GBO_Type__c== null || c.GBO_Type__c==''){
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Error,'Please pick up a value from GBOType'));   
            isMandatoryFailed = true;   
        }
        if(c.Subject== null || c.Subject==''){
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Error,'Please Enter Subject'));   
            isMandatoryFailed = true;
        }
        if(c.Description== null || c.Description==''){
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Error,'Please Enter Description'));   
            isMandatoryFailed = true;
        }
        if(c.Country__c== null || c.Country__c==''){
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Error,'Please Enter Country'));   
            isMandatoryFailed = true;
        }
        
        if(isMandatoryFailed){
            return null;
        }
        List<String> contList = new List<String>(); 
        try {
            Integer i=0;        
            // now look for an associated contact with the same email
            for(Contact cnt : [SELECT Id,Email FROM Contact WHERE Email = :c.SuppliedEmail]){
                if (cnt != null) {
                    contList.add(cnt.Id);
                    i++;
                }
            }
            If(contList!=null){
                if(i<1){
                    
                }else if(i>1){
                    
                }else if (i==1){
                    for(String contStr :contList)
                    {
                        c.ContactId=contStr;
                    }
                    
                }
            }
            //   c.Type=CaseVO.getType();
            
            // c.RecordTypeId=c.Record_Type__c;
            // Specify DML options to ensure the assignment rules are executed
            Database.DMLOptions dmlOpts = new Database.DMLOptions();
            dmlOpts.assignmentRuleHeader.useDefaultRule = true;
            c.setOptions(dmlOpts);
            c.Is_Submitted_From_Site__c = true;
            // Insert the case
            // INSERT c;
            // Added by Kavitha - Webtocase Attachment - Start               
            Database.SaveResult res = Database.Insert(c,false);
            System.debug('gboCaseController Error: '+res.getErrors());
            PageReference redirectAttachmentPage;
            if(res.getId()!= null)
            {
                case cs = [select id,CaseNumber from case where id =:res.getId()];
                redirectAttachmentPage= new PageReference('/apex/SubmitCaseAttachmentPage?id='+res.getId());
                // redirectAttachmentPage= new PageReference('http://sit-rsa.cs1.force.com/webtocase/p/attach/NoteAttach?pid='+cs.id+'&parentname='+cs.casenumber);
                redirectAttachmentPage.setRedirect(TRUE);
                return redirectAttachmentPage;//new PageReference('/thanks');
            }else
            {
                String strError; 
                for(Database.Error err : res.getErrors()) 
                {
                    strError += err+ ';';
                }
                
                return null;
                
            }
        } catch (Exception e) {
            ApexPages.addMessages(e);
            return null;
        }
    }
    
    //added by viswa from 271 line to 297 line
    
    public List<SelectOption> getPickLstValue()

    {

    List<SelectOption> options = new List<SelectOption>();

     Schema.DescribeFieldResult fieldResult = Case.Priority.getDescribe();

    List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();

    for(Schema.PicklistEntry f : ple)

    {

     if(f.getValue() != 'Hot')

     {

   options.add(new SelectOption(f.getLabel(), f.getValue()));

   }

     }  

           return options;            

  }

    
    public void doAttach()
     {

        String caseid1 = ApexPages.CurrentPage().getParameters().get('id');

       
 
        if(attachmentName == null && attachmentBody == null)        
        {
          ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Error: Please specify a file to upload. Type in the path to the file, or use the "Browse" button to locate it in your local filesystem.'));
        }
        else        
        { 
       
         objCaseAtt.Name     = attachmentName;            
          objCaseAtt.Body     = attachmentBody;           
          objCaseAtt.ParentId = caseId;  
            try{             
          insert(objCaseAtt); 
          }
          catch(exception e){
          ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Error: Please specify a file to upload. Type in the path to the file, or use the "Browse" button to locate it in your local filesystem.'));
          }
          finally{
         objCaseAtt = new attachment();
         
          } 
          
      /*  Messaging.EmailFileAttachment efa = new Messaging.EmailFileAttachment();
        efa.setFileName(attachmentName);
        efa.setContentType('application/Pdf');
        efa.setBody(attachmentBody);  
        system.debug('Test---90>>>'+attachmentBody.size());
       // if(attachmentBody.size()<156000) {          
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
        mail.setUseSignature(false);
        mail.setToAddresses( new String[] {System.Label.webtocaseattachinsert});
     //  mail.setToAddresses('udaykumar.pathi@rsa.com');
        mail.setSubject(caseId);
        mail.setPlainTextBody('case attachment');
        mail.setFileAttachments(new Messaging.EmailFileAttachment[] { efa }); 
        Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });*/
      //  }
       /* else{
         ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Error: Size of the file cannot be greater than 150KB.'));*/     

       //}
            lst_attch = new List<attachment>();
            lst_attch = [Select id,name,Parent.name from attachment where parentid =:caseid];
          }
        }
    
}
Regards,
VIswa
 
Hi Experts,
Below is my test class ,
public with sharing class gboclosecaseController {
 public Case caseObj {get;set;}
    public Id tempCaseId {get;set;}    
    public String tempTo {get;set;}
    public String tempCategory {get;set;}
    public String tempRootCause {get;set;}
    public String tempGBOType {get;set;}    
    public String tempSubCategory {get;set;}       
    public String tempInternalComments {get;set;}             
    public Case caseObj1;
    public Case parentCase;
  

    
       public gboclosecaseController(ApexPages.StandardController controller){
        this.caseObj = (Case)controller.getRecord();
        caseObj.RecordTypeID = '012560000000DrN';
         tempCaseId  = ApexPages.currentPage().getParameters().get('previousId');
         tempTo  = ApexPages.currentPage().getParameters().get('To');
         tempCategory  = ApexPages.currentPage().getParameters().get('Category');
         tempRootCause  = ApexPages.currentPage().getParameters().get('RootCause');
         tempGBOType  = ApexPages.currentPage().getParameters().get('GBOType');    
         tempSubCategory  = ApexPages.currentPage().getParameters().get('SubCategory');  
         tempInternalComments= ApexPages.currentPage().getParameters().get('InternalComments'); 

          /* List<Case> childCases = [select id from Case where ParentId=:caseObj.id AND Status!='Closed'];
        if(childCases.size()>0){
             ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error,'You cannot Close Parent Case when any one of the child case is opened. Please close all the open child cases ')); 
                        
                }  */
         
        caseObj1 = [Select Status,ParentId,Id,CaseNumber,To__c,GBO_Type__c,Description,Root_Cause__c from case where id =:caseObj.Id]; 
                          
         system.debug('tempCaseId------------------1'+tempCaseId);    
             

         
          if(tempTo!=null && tempTo!='')
            caseObj.To__c = tempTo;    
              
         if(tempCategory!=null && tempCategory!='')
            caseObj.Category__c = tempCategory;    
            
          if(tempRootCause!=null && tempRootCause!='')
            caseObj.Root_Cause__c = tempRootCause;  
                        
          if(tempGBOType!=null && tempGBOType!='')
            caseObj.GBO_Type__c = tempGBOType;  
            
          if(tempSubCategory!=null && tempSubCategory!='')
            caseObj.SubCategory__c = tempSubCategory;  
            
          if(tempInternalComments!=null && tempInternalComments!='')
            caseObj.Description = tempInternalComments;                         
 
    }
    
    
 public  PageReference NewSave()
    {
      PageReference pageRef = Null;
      
        List<Case> childCases = [select id from Case where ParentId=:caseObj.id AND Status!='Closed'];
        if(childCases.size()>0){
             ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error,'You cannot Close Parent Case when any one of the child case is opened. Please close all the open child cases ')); 
                return null;        
                }  
               
         if (caseObj.To__c != tempTo) 

            { 
                        ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error,'You cannot change the "To" value')); 
                        return null; 
                }  
        
            
      try
     {
     
             if(caseObj1.ParentId !=null)
            {
               // parentCase = new Case();
               parentCase = [select id,CaseNumber,Account.Name,Owner.Email,ParentId from Case where Id=:caseObj1.ParentId];
                parentCase.Id = caseObj1.ParentId;
                parentCase.Status = 'In progress';
                
            }
            
            system.debug('parentCase------------------1'+parentCase);
            system.debug('caseObj1------------------1'+caseObj1);
   
   update caseObj;
   system.debug('caseObj------------------000000000000000000000000000000000000000'+caseObj);
   
            if(caseObj1.ParentId !=null)
            {       
                update parentCase;
            }
            
             if(caseObj1.ParentId !=null)
            {
        
        //Send an Email

        EmailTemplate et = [SELECT Id, Subject, HtmlValue, Body FROM EmailTemplate WHERE Name = 'GBOCASE02'];
        system.debug('SendEmail');

        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
       
                
        string CaseNumber=caseObj1.CaseNumber==null?'':caseObj1.CaseNumber;
        string ParentCaseNumber=parentCase.CaseNumber==null?'':parentCase.CaseNumber;
        string Accnt=caseObj.Account.Name==null?'':caseObj.Account.Name;
        //string OwnerName=parentCase.Owner.Name==null?'':parentCase.Owner.Name;
        string OwnerName=parentCase.Owner.Email;
        
        system.debug('SendEmail'+OwnerName);
        string To=caseObj.To__c==null?'':caseObj.To__c;
        string GBOType=caseObj.GBO_Type__c==null?'':caseObj.GBO_Type__c;
        string Reason=caseObj.Reason==null?'':caseObj.Reason;
        string Descrptn=caseObj.Description==null?'':caseObj.Description;
        string RootCause=caseObj.Root_Cause__c==null?'':caseObj.Root_Cause__c;


        
        String subject = et.Subject;
        subject = subject.replace('{!Case.CaseNumber}', CaseNumber);
        subject = subject.replace('{!Case.Parent}', ParentCaseNumber);

    
        String htmlBody = et.HtmlValue;
        htmlBody = htmlBody.replace('{!Case.CaseNumber}', CaseNumber);
        htmlBody = htmlBody.replace('{!Case.Parent}', ParentCaseNumber);
        htmlBody = htmlBody.replace('{!Case.To__c}', To);
        htmlBody = htmlBody.replace('{!Case.GBO_Type__c}', GBOType);
        htmlBody = htmlBody.replace('{!Case.Reason}', Reason);
        htmlBody = htmlBody.replace('{!Case.Description}', Descrptn);
        htmlBody = htmlBody.replace('{!Case.Root_Cause__c}', RootCause);
       
        mail.setSenderDisplayName('RSA Notification');
        mail.setInReplyTo('noreply@rsa.com');
        mail.setSubject(subject);
        mail.setHtmlBody(htmlBody);
        mail.setToaddresses(new String[] {OwnerName});
        
        system.debug('SingleEmail.svp'+mail);
       // Messaging.sendEmail(new Messaging.SingleEmailMessage[] {mail});
    } 
   
    
      
     } 
    
     
     catch(Exception e){
                ApexPages.addMessages(e);
                return null;
            }              
  
      
    
     pageRef = new PageReference('/apex/CaseView?id='+caseObj.Id);
     return pageRef;
    }
}


********************************************** here my test class  *********************

@isTest(SeeAllData=true)
public class gboclosecaseController_test{

        public static testMethod void gboclosecase(){
        case objCase=new Case(status='New',Origin='Phone');
        insert objCase;
       
 
                 
        case objCase1=new Case(status='New',Origin='Phone',ParentId=objCase.Id);
        EmailTemplate et = new EmailTemplate (Subject='Test',HtmlValue='gbocase',Body ='templete');
       
        //insert et;
        /*list<case> cn =new list<case>();
     
        cn.add(new case(status='New',Origin='Phone',ParentId=objCase.Id));
        insert cn;*/
       
               
               
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
       
        ApexPages.currentPage().getParameters().put('caseId',objCase.Id);
        ApexPages.StandardController sc = new ApexPages.StandardController(objCase);
        gboclosecaseController GCC= new gboclosecaseController (sc);
       
       
         GCC.NewSave();
      
        
       
            }
}
Hi All,

I am writing a test class on Entitelement  . in this object we have lookupfileds to Entitlement object.
Thesre are lookup fileds
CAS_Entitlement__c,DSE_Entitlement__c,OSE_Entitlement__c.
i got this error
System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [AccountId]: [AccountId]

Below is my test class and also i got error , could you please can any one help.

@istest(SeeAllData=true)
public class caseSupportPortalControllerGS_test
{

      public static testMethod void caseCust()
      {
        
        case objCase=new Case(status='New',Origin='Phone',Subject='RSA',Type__c='Technical',PL_RSA_Product_Set__c='DLP',
        PL_RSA_Product__c='Archer',PL_RSA_Version_Condition__c='5.3',
        Issue_Type__c='SA missing csas rules',Platform__c='windows');
        insert objCase;
        case objCase1=new Case(status='New',Origin='Phone');
        RSA_Product_Set__c objRSA=new RSA_Product_Set__c(Name='test',Type__c='Technical Support');
        insert objRSA;                      
        Account a = new Account(Name='Test01',Country__c='India',City__c='Chennai',Street__c='karapakam');
        insert a;
        
        Entitlement objEntl=new Entitlement(Name='test',Startdate=system.today(),MSSP_Account_Name__c='Test2');
        insert objEntl;
        
        Entitlement objEnt2=new Entitlement();
      
        objEnt2.Name='test';
        objEnt2.Startdate=system.today();
        objEnt2.CAS_Entitlement__c=objEntl.id;
        objEnt2.DSE_Entitlement__c=objEntl.id;
        objEnt2.OSE_Entitlement__c=objEntl.id;
        objEnt2.TAM_Entitlement__c=objEntl.id;
        objEnt2.Name=a.id;
      
        
        insert objEnt2;
        

                
        ApexPages.currentPage().getParameters().put('caseId',objCase.Id);
       
        ApexPages.StandardController sc = new ApexPages.StandardController(objCase);
        caseCustomerSupportPortalControllerGS contr = new caseCustomerSupportPortalControllerGS(sc);
        
        PageReference pageRef = Page.caseCustomerSupport_PortalVFGS;
        Test.setCurrentPage(pageRef);
        
        contr.getSevItems();
        contr.runSearch();
        contr.ArticleView();
        contr.submitAttachment();
        contr.NewSave();
        contr.routetoProperQueue(objCase1);
        contr.updateEntitlementIcons('test');
        contr.CollectVersionConditionList();
        contr.CollectProductSetList();
        contr.CollectProductList();
        
        
            
    }

Regrads,
VIswa
H i All,

How to we can write multiple batch sizes (indidual size )in single batch apex.class

Can you pls explian me with one example.


Regards,
Viswa.
HI,
i am phasing this issue variable  doesnot exist.

trigger updatephonecontact on Account (after update)
{
 for(account acc : trigger.new)
 {
 list<contact> listcon= [select phone from contact where accountid=:acc.id];
 }
/for(Contact ct : listcon)
 {
 
 ct.phone=acc.phone ;// i got error at his line can ypo pls help me
 }
 update listcon;
}
   how to  write a code   i have one tab , that tab is Search job , u can clickied on  the tab then it will go to next page. i wanted code in vf page and apex class? by using pagerefrence, kindely give me reply