• Naidu Pothini
  • SMARTIE
  • 1950 Points
  • Member since 2011

  • Chatter
    Feed
  • 70
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 371
    Replies

this code below works fine and throws error when case team is not there when status is changed per code.

however it still throws error when someone updates case and case team is there, what is wrong here?

 

thanks

 

//start ***** checks if case team is there, if not, wont allow change of status
  public  void caseteam(){
 
          setCaseId = new Set<Id>();
     
          for (Case c : mescal){  
           if(c.Status != moldmap.get(c.Id).Status && c.Record_Type_Name__c=='Escalation'
            && (c.status == 'Active Engaged' || c.status == 'Active Wait' || c.status == 'Analysis'||
             c.status == 'Closed'))     
             {
                  setCaseId.add(c.Id);
              }   
              }
             mapCaseWithteamMember = new  Map<Id,CaseTeamMember>();
              if(!(setCaseId.ISEMPTY())){
                  for(CaseTeamMember ct: [SELECT Parentid FROM CaseTeamMember  WHERE parentid IN :setCaseId])
                  {mapCaseWithteamMember.put(ct.ParentId,ct);}
                       }
       if(mapCaseWithTeamMember.ISEMPTY()){  
          for(Case c: mescal)
                  { 
          if(mapCaseWithTeamMember.get(c.Id) ==null &&  c.Record_Type_Name__c=='Escalation' &&
           (c.status == 'Active Engaged' || c.status == 'Active Wait' || c.status == 'Analysis'||
             c.status == 'Closed'))
                          {  
              c.addError('No case team is assigned, please assign a team member before changing status');
                           }
        
                 }
                        }
                       
                         }


  //end ------------------------------------------

I just need to do a trigger version of a Roll up summary. Made it easily for single use but mass Apex updates overload. Here's my un-bulked code below. Any help would be apprecieated.

Assigned_Team__c is a related object to Account that I want to count. 

 

trigger CountCov on Account (before insert, before update) {
    Account [] a = Trigger.new;
    String aid = null;    
    Aid = a[0].id;

        Integer i = [select count() from Assigned_Team__c where Account__c = :aid and Name != 'None'];

    a[0].Coverage_count__c = i;
    }

 

hi

 

 First i create a button on Account. and if i click that button that related contacts owner name is changed as Account owner Name. 

 

Please give me a solution for this... 

  • April 05, 2013
  • Like
  • 0

I have a trigger that i need a test class for but I am limited in my apex test writting. Can someone help me with a test method for the fllowing code below? I would really appreciate it.

 

trigger Trigger_ContactBouncedEmailBeforeUpdate on Contact (before update)
{
    
 //Assign the context before and after the change into a Map
    Map<Id,Contact> newContactMap = Trigger.newMap;
    Map<Id,Contact> oldContactMap = Trigger.oldMap;
    
    //Loop through the map
    for(Id contactId:newContactMap.keySet()){
        Contact myNewContact = newContactMap.get(contactId);
        Contact myOldContact = oldContactMap.get(contactId);
        if (myNewContact.EmailBouncedReason <> myOldContact.EmailBouncedReason){
            //if Salesforce is modifying these fields we want to reset are
            myNewContact.IsEmailBounced__c = false;
            myNewContact.EmailBouncedReason__c = null;
            myNewContact.EmailBouncedDate__c = null;
        }
        if (myNewContact.IsEmailBounced__c <> myOldContact.IsEmailBounced__c){
            if(myNewContact.IsEmailBounced__c == true)
            {
                myNewContact.EmailBouncedDate = myNewContact.EmailBouncedDate__c;
                myNewContact.EmailBouncedReason = myNewContact.EmailBouncedReason__c ;
            }
            if(myNewContact.IsEmailBounced__c == false)
            {
                myNewContact.EmailBouncedDate = null;
                myNewContact.EmailBouncedReason = null;
                myNewContact.EmailBouncedReason__c = null;
                myNewContact.EmailBouncedDate__c = null;
            }
        }
    }

}

  • April 04, 2013
  • Like
  • 0

I have created a new app for my org, with new record types, page layouts, etc and deployed it between sandboxes (dev to full) to test the additions. This worked fine but now I'm trying to deploy it in my production org and the change set has failed the validation test.

Basically my problem is I'm not a developer and all the code in our org was written by a consultant before I joinedthe company so I don't want to change things in production when I'm not sure about them. Therefore I would appreciate any help that could be offered!

The new record type won't be using the funnel camp tracker so I'm not sure if that is part of the issue. Would it be possible to add something into the trigger to exclude the new record type I'm trying to deploy? 

 

 

Change set deployment error:

TestClass.testOpportunityTrigger() Class 49 1

Failure Message: "System.AssertException: Assertion Failed: Expected: 3, Actual: 0", Failure Stack Trace: "Class.TestClass.testOpportunityTrigger: line 49, column 1"

 

@isTest
private class TestClass {

    //Test Opportunity Trigger
    static testMethod void testOpportunityTrigger() {
        
        //* Create Test Account, make sure all required fields for Account are populated here:
        Account testAccount = new Account(name = 'TestAccount01');
        insert (testAccount);
        
        test.startTest();
        
        //*Create Opportunities
        Id OptyRecId = Schema.SObjectType.Opportunity.getRecordTypeInfosByName().get('Opportunity Europe').getRecordTypeId();
        list<Opportunity> testListOpty = new list<Opportunity>();
        
        date d = system.Today();
        d.addMonths(1);
        
        //* Insert a list of opportunities, make sure all required fields for Opportunity are populated here:
        testListOpty.add(new Opportunity(AccountId = testAccount.Id, Name = 'TestOpty01', CurrencyIsoCode = 'EUR', StageName = '02. Positioned in Category', CloseDate = d));
        testListOpty.add(new Opportunity(AccountId = testAccount.Id, Name = 'TestOpty02', CurrencyIsoCode = 'EUR', StageName = '02. Positioned in Category', CloseDate = d));
        testListOpty.add(new Opportunity(AccountId = testAccount.Id, Name = 'TestOpty03', CurrencyIsoCode = 'EUR', StageName = '02. Positioned in Category', CloseDate = d));
        
        insert(testListOpty);
                
        //* Check Data, 3 opty therefore we should have 3 funnel trackers.
        system.assertEquals(3, [select Id from Funnel_Camp_Tracker__c where Opportunity__r.Account.Id = :testAccount.Id].size());
        
        test.stopTest();
    }
    
    static testMethod void testGamePlanController(){
      
      //* Create Test Data
      //* Create Test Account, make sure all required fields for Account are populated here:
        Account testAccount = new Account(name = 'TestAccount01');
        insert (testAccount);
        Contact testContact = new Contact(FirstName = 'Bruce', LastName = 'Wayne', Phone = '123', Email = 'batman@batcave.com', MobilePhone = '321');
        insert(testContact);
        
        //*Create Opportunities
        Id OptyRecId = Schema.SObjectType.Opportunity.getRecordTypeInfosByName().get('Opportunity Europe').getRecordTypeId();
        list<Opportunity> testListOpty = new list<Opportunity>();
        
        date d = system.Today();
        d.addMonths(1);
        
        //* Insert a list of opportunities, make sure all required fields for Opportunity are populated here:
        testListOpty.add(new Opportunity(AccountId = testAccount.Id, Name = 'TestOpty01', CurrencyIsoCode = 'EUR', StageName = '02. Positioned in Category', CloseDate = d));
        insert(testListOpty);
        
        list<OpportunityContactRole> TestlistOCR = new list<OpportunityContactRole>();
        for(Integer i=0;i<5;i++){
          TestlistOCR.add(new OpportunityContactRole(Role = 'testRole' + i, OpportunityId = testListOpty[0].Id, ContactId = testContact.Id));
        }
        
        insert (TestlistOCR);
        
      test.startTest();
      
      pageReference p = Page.GenerateGamePlan;
      p.getParameters().put('id', testListOpty[0].Id);
        test.setCurrentPage( p );
        GamePlanController GPC = new GamePlanController();
        GPC.oOpty = testListOpty[0];
              
      test.stopTest();
      
    
    }
}

 

Hi,

 

I want whenever the user enters the recods from web to lead process. It should automatically be submitted to worflow approvals. I have written a trigger , mentioned below. When I create a new record , it is giving this error: I am not getting why this error is coming. 

 

Error: Invalid Data. 
Review all error messages below to correct your data.
Apex trigger leadApprovalSubmit caused an unexpected exception, contact your administrator: leadApprovalSubmit: execution of BeforeInsert caused by: System.DmlException: Process failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, missing required field: []: Trigger.leadApprovalSubmit: line 15, column 1

 

trigger leadApprovalSubmit on Lead (before insert) {

 

for (Lead l : trigger.new) {

// Create an approval request for the lead
Approval.ProcessSubmitRequest req1 =
new Approval.ProcessSubmitRequest();
req1.setComments('Submitting request for approval.');
req1.setObjectId(l.id);


// Submit the approval request for the lead
Approval.ProcessResult result = Approval.process(req1);

// Verify the result
System.assert(result.isSuccess());

 

}

}

 

 

Ps- error is same with after insert also. Pls help

Hi All. Below is a really simple chatter trigger that I have written to help me with creating cases from chatter posts. It's my first chatter trigger, and I'm getting stumped on the line that is commented out. I can't get that line to compile. It seems that I can't get the FeedItem's Body from the feedcomment. Is my syntax wrong, or is not possible this way?

 

Thanks!

 

 

 

trigger createCaseFromChatter on FeedComment (after insert) {

    for(FeedComment f : trigger.new) {
        if(f.CommentBody.startsWith('!newCase')) {
            Case newCase = new Case(
            	Subject = f.CommentBody,
                //Description = f.FeedItem.Body,
                Origin = 'Chatter',
                RecordtypeId = '012G0000000yArc',
                Status = 'Open'                
            );
            insert newCase;
        }
    }
}

 

I have a very simple trigger I've written for adding two text fields to Opportunity Team Member that I then use in a flow.  It must be because it's the end of the day and I'm not thinking clearly, but I just need it to line up so that it doesn't mismatch the text values for the users with the actual records.  Right now, if I add more than 1 member to the Oppportunity Team, it enters the wrong person's name into Team Member Name and Team Member last name.  I just need to get them to match up as they're being entered.

 

trigger TRG_OpptyTeamMemberName on OpportunityTeamMember (before insert, before update) {

	List<User> teamMemberInfo = new List<User>();
	Set<ID> setTeamMemberID = new Set<ID>();
	Integer index = 0;
	
	for (OpportunityTeamMember otm: Trigger.new){
		setTeamMemberID.add(otm.UserId);
	}
	
	teamMemberInfo = [Select u.Name, u.LastName, u.Id From User u where u.Id in: setTeamMemberID];
	
	for (OpportunityTeamMember otm: Trigger.new){
		otm.Team_Member_Name__c = teamMemberInfo[index].Name;
		otm.Team_Member_LastName__c = teamMemberInfo[index].LastName;
		index +=1;
	}
	
}

Can someone please set me straight so that the values align as they go back into the record?

When I update one record, this trigger works, but when I update multiple records by using Apex Dataloader, it doesn't work.

This trigger updates parent object when its child object's status is updated.

 

1. Child object Trigger: it just updates parent object.

trigger RFTSetPDStatusFromMS on Ichthys_RFT__c(after insert, after update) {
    
  if (Trigger.isInsert||Trigger.isUpdate)
  {
    list<Ichthys_RFT__c>msl=[SELECT id,Status__c,RFT_Category__r.Id FROM Ichthys_RFT__c WHERE Id in :Trigger.new];
    Ichthys_RFT__c newMs=null;
    if(msl.size()>0)
    {
      newMs=msl[0]; 
      RFT_Category__c[] pdList = [SELECT id, Name, PD_Status__c FROM RFT_Category__c WHERE Id = :newMs.RFT_Category__r.Id];
      if(pdList.size()>0)
      {
        update pdList[0];
      }
    }
  }
}

2. Parent Object Trigger: it checks child object status and update parent status.

trigger RFTSetPDStatus on RFT_Category__c (before update) {
  if (Trigger.isUpdate)
  {
    List<Ichthys_RFT__c > msList= [SELECT RFT_Category__r.Id,Status__c FROM Ichthys_RFT__c WHERE RFT_Category__r.Id in :Trigger.new];
    Integer msExist=0;
    Integer msCnt=0;  

    if(msList.size()>0){
      msExist +=1;
    }
    for(RFT_Category__c pd:Trigger.new){
      if(msExist==0){
        pd.PD_Status__c ='Open';
      }else{
        for( Ichthys_RFT__c ms :msList){
          if( ms.RFT_Category__r.Id == pd.Id && ms.Status__c <>'Completed' &&  ms.Status__c <>'Not Applicable'){
            msCnt +=1;
          }
        }
        if(msCnt==0){
          pd.PD_Status__c ='Close';
        }
        else if(msCnt>0){
          pd.PD_Status__c ='Open';
        }
      }
    }
  }
}

 Thanks in advance for your help.

 

Anna

 

  • March 26, 2013
  • Like
  • 0
11/28/14 06:00 AM is the string i want only date from it any help is appriciable

M getting the following error...so code coverage is less than 75%...not able to deploy...Thanks in advance for help...

 

error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, Minutescase: execution of AfterInsert caused by: System.QueryException: Non-selective query against large object type (more than 100000 rows). Consider an indexed filter or contact salesforce.com

 

 

 

@isTest(SeeAllData=true)
private class testMyTaskTrigger {
 
    public static testMethod void testTTrigger(){
      
        
        Account acc  = new Account();
        acc.name = 'Test';
        insert acc;

        Contact con = new Contact();
        con.LastName = 'Test Contact';
        insert con;
       
       
        Task t = new Task();
        t.OwnerId = UserInfo.getUserId();
        t.Subject='Donni';
        t.Status='Not Started';
        t.Priority='Normal';
        t.Minutes_on_tasks__c = 2000;
        t.status = 'Completed';
        insert t;
 
        Task tas = new Task();
        tas.OwnerId = UserInfo.getUserId();
        tas.Subject='Donni';
        tas.Status='Not Started';
        tas.Priority='Normal';
        tas.Minutes_on_tasks__c = 2000;
        tas.status = 'Completed';
        tas.whoid = con.id;

        Sales_Resources__c sr = new Sales_Resources__c ();
        sr.Name = 'Test Sales Resources';
        insert sr;
        
        Task p = [select id from task where Ownerid = '00500000006scDCAAY' limit 1];
         try{
        delete p;
        }
        Catch(Exception e)
        {

          system.debug('Error:'+e);
        }
 
       
        Test.startTest();
        insert tas;
        try{
        delete t;
        }
        Catch(Exception e)
        {

          system.debug('Error:'+e);
        }

        Test.stopTest();
       
     }

}

 

 

same error in this test class also...  Failure Message: "System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, EB_Case_Owner_Trigger: execution of AfterInsert caused by: System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, Minutescase

 

 

@isTest(SeeAllData=true)
private class EB_Case_Owner_Trigger_Test_Class {

    static testMethod void myUnitTest() {
        // TO DO: implement unit test
        EB_SB_Builder__c ebsb = new  EB_SB_Builder__c ();
        Case accs1 = new Case();
        insert ebsb;
        Datetime dt = Datetime.now();
        Case accs = new Case(RecordTypeId='0120000000098Po',Event_Survey_Builder__c = ebsb.Id, Origin= 'Email', Subject='Testing Task', Minutesoncase__c =10, Reason='508 compliance', Product_Type__c = 'Event Tool');
        //Case accs = new Case(ContactId = '003P000000Cu7pU',RecordTypeId='0120000000095Nn',Event_Survey_Builder__c = ebsb.Id, Origin= 'Email', Subject='Testing Task', Minutesoncase__c =10, Reason='508 compliance', Product_Type__c = 'Event Tool' , AccountId='001P000000GF1fq');
            insert accs;
    }
    

}

 

 

 

Hello,

 

I have the following code that is supposed to send an email to the Task Creator once the Task has been Completed.  I am getting an error .... "System.NullPointerException: Attempt to de-reference a null object:  Trigger.TaskSendEmail: line 18, column 1."  I cant figure out what I need to change on the code?    I highlighted in red; line 18.   Thanks in advance

 

 

trigger TaskSendEmail on Task (after update) {
// Don't forget this- all triggers in SF are bulk triggers and so
    // they can fire on multiple objects. So you need to process objects
    // in a FOR loop.
    Set<Id> CBIds = new Set<Id>();
   
    for(Task tsk: Trigger.New)
       if(tsk.RecordTypeId == '012Z00000004WFV' && tsk.Status == 'Completed')
        CBIds.add(tsk.CreatedById);
   
    // Build a map of all users who created the tasks.
    Map<Id, User> userMap = new Map<Id,User>([select Name, Email from User where Id in :CBIds]);
    for(Task tsk : Trigger.New)
    {
        User theUser = userMap.get(tsk.CreatedById);
        
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
        String[] toAddresses = new String[] {theUser.Email};
        mail.setToAddresses(toAddresses);    // Set the TO addresses
        mail.setSubject('The following Task has been Closed');    // Set the subject
        // Next, create a string template. Specify {0}, {1} etc. in place of actual values.
        // You can replace these values with a call to String.Format.
        String template = 'Hello {0}, \nYour task has been modified. Here are the details - \n\n';
        template+= 'Subject - {1}\n';
        template+= 'Due Date - {2}\n';
        String duedate = '';
        
        if (tsk.ActivityDate==null)
            duedate = '';
        else
            duedate = tsk.ActivityDate.format();
            
        List<String> args = new List<String>();
        args.add(theUser.Name);
        args.add(tsk.Subject);
        args.add(duedate);
        
       
        // Here's the String.format() call.
        String formattedHtml = String.format(template, args);
       
        mail.setPlainTextBody(formattedHtml);
        Messaging.SendEmail(new Messaging.SingleEmailMessage[] {mail});
    }
}

 

 

  • March 21, 2013
  • Like
  • 0

I have a couple of lists in my apex class that I'm trying to check against certain potential query results in order to trigger a conditional set of actions, however they don't seem to be executing as intended and I'm a little perplexed as they contain the trigger values in the tests I'm running, but the conditional don't trigger.

My code is below:

public with sharing class claimSubmitController {
 
  private ApexPages.StandardController controller    {get; set;}
  public List<MG_Contract_Holder__c> searchResults    {get;set;}
  public string vin6    {get;set;}
  public string Name    {get;set;}
  public string contractNum    {get;set;}
  
  public string descr    {get;set;}
  public string causeLoss    {get;set;}
  public string lDate    {get;set;}
  public string cPhone    {get;set;}
  public string cEmail    {get;set;}
  
  public static String SEARCH    {get{return 'SEARCH';}set;}
  public static String SHOW    {get{return 'SHOW';}set;}
  public static String HIDE    {get{return 'HIDE';}set;}
  public static String CLAIM_QUESTIONS    {get{return 'CLAIM_QUESTIONS';}set;} 
  public static String CLAIM_DONE    {get{return 'CLAIM_DONE';}set;}
  
  public String currentPage        {get;set;}
  public String buttonStatus       {get;set;}
  public String listChoice         {get;set;}
  
  public MG_MAG_Claim__c claim {get;set;}
  
  // Standard controller
  public claimSubmitController(ApexPages.StandardController controller) {
  currentPage = SEARCH;
  buttonStatus = HIDE;
  listChoice = HIDE;
  }
 
  // Search button clicked
  public PageReference search() {
     
    String qry = 'SELECT Vin_Number__c, Name, Product_Group__c, Insurer__c, Contract_Number__c FROM MG_Contract_Holder__c WHERE (Vin_Last_6__c =:vin6) AND (Contract_Number__c =:contractNum) AND (Name LIKE \''+String.escapeSingleQuotes(Name)+'%\')'; 
    searchResults = Database.query(qry);
    List<MG_Contract_Holder__c> c = [SELECT Insurer__c FROM MG_Contract_Holder__c WHERE Vin_Last_6__c =:vin6 AND Contract_Number__c =:contractNum LIMIT 1];    
    if (c.isEmpty()){
    ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'No records found'));
    hideButton();
    return null;    
    }
    String cD = String.valueOf(c[0]);
    if(cD == 'NSD' || cD == 'Markel' || cD == 'CarCo' || cD == 'Test Insurer'){
    ApexPages.Message err = new ApexPages.Message(ApexPages.Severity.ERROR,'Your policy requires direct interaction with one of our associates, please call the phone number on your policy specified under claims.');
    ApexPages.addMessage(err);
    hideButton();
    return null;
    }
    else{
    showButton();
    } 
    return null;
    }
    
    String[] coverage = new String[]{};
                    
    public List<SelectOption> getItems() {
        List<SelectOption> options = new List<SelectOption>();
        options.add(new SelectOption('T&W','T&W'));
        options.add(new SelectOption('WINDSHIELD','Windshield'));
        options.add(new SelectOption('KEY','Key'));
        options.add(new SelectOption('PDR','Dent'));
        return options;
    }
            
    public String[] getCoverage() {
        return coverage;
    }
            
    public void setCoverage(String[] coverage) {
        this.coverage = coverage;
    }
    
  public PageReference showButton(){
    PageReference pageReference = null;
    buttonStatus = SHOW;           
    return(pageReference);
  }
  
  public PageReference hideButton(){
    PageReference pageReference = null;
    buttonStatus = HIDE;           
    return(pageReference);
  }
  
  public PageReference hideList(){
    PageReference pageReference = null;
    listChoice = HIDE;           
    return(pageReference);
  }
  
  public PageReference showList(){
    PageReference pageReference = null;
    listChoice = SHOW;           
    return(pageReference);
  }
 
  public PageReference startClaim(){
     PageReference pageReference = null;
     currentPage = CLAIM_QUESTIONS;           
     List<MG_Contract_Holder__c> cvg = [SELECT Product_Group__c FROM MG_Contract_Holder__c WHERE (Vin_Last_6__c =:vin6) AND (Contract_Number__c =:contractNum)];    
     if (cvg.isEmpty())
     {
     listChoice = HIDE;
     hideList();
     return null;
     }
     String cV = String.valueOf(cvg[0]);
     if(cV == 'MPP' || cV == 'Key Plus' || cV == 'UPP Plus' || cV == 'UPP' || cV == 'MPP TX' || cV == 'MPP Plus' || cV == 'PG01'){
     listChoice = SHOW;
     showList();
     }
     return(pageReference); 
     }
 
  public PageReference submitClaim(){
  
     PageReference pageReference = null;
     currentPage = CLAIM_DONE;           
     return(pageReference);
  }
}

 The specific parts I'm having trouble with are:

List<MG_Contract_Holder__c> c = [SELECT Insurer__c FROM MG_Contract_Holder__c WHERE Vin_Last_6__c =:vin6 AND Contract_Number__c =:contractNum LIMIT 1];    
    if (c.isEmpty()){
    ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'No records found'));
    hideButton();
    return null;    
    }
    String cD = String.valueOf(c[0]);
    if(cD == 'NSD' || cD == 'Markel' || cD == 'CarCo' || cD == 'Test Insurer'){
    ApexPages.Message err = new ApexPages.Message(ApexPages.Severity.ERROR,'Your policy requires direct interaction with one of our associates, please call the phone number on your policy specified under claims.');
    ApexPages.addMessage(err);
    hideButton();
    return null;
    }

 And :

 List<MG_Contract_Holder__c> cvg = [SELECT Product_Group__c FROM MG_Contract_Holder__c WHERE (Vin_Last_6__c =:vin6) AND (Contract_Number__c =:contractNum)];    
     if (cvg.isEmpty())
     {
     listChoice = HIDE;
     hideList();
     return null;
     }
     String cV = String.valueOf(cvg[0]);
     if(cV == 'MPP' || cV == 'Key Plus' || cV == 'UPP Plus' || cV == 'UPP' || cV == 'MPP TX' || cV == 'MPP Plus' || cV == 'PG01'){
     listChoice = SHOW;
     showList();
     }

 I figure that I'm failing to parse the list array properly, but what I have is the only syntax the system would let me use to pull out the item I'm trying to check against without throwing a compile error so any suggestions on improvement would be appreciated.

Hi I'd like to create a pop up window which will have to value either Yes or No and when the user click on "Yes" it creates the Record and when the user click on NO nothing will happen...

 

please help me on this...this I want to achieve in javascript

Hi Everyone,

 

I am having a problem with some code I am trying to write. I want to create a calculator inside salesforce. When I try to add a output text tag with a variable in it I keep getting the unknown property error.

The variable is defined in my custom apex controller. IT has a getter and setter methods and is set to public. I don't understand what the problem is?

Can someone help me out. 

 

Below is my code that I have created so far:

 

Visualforce page:

<apex:page controller="DirectHireCalcController">
<apex:form >
<apex:page >
    <apex:pageBlock title="Direct Hire Fee Calculator">
        <apex:pageBlockSection columns="1">
            <apex:pageBlockSectionItem helpText="This value is automatically calculated. Do not enter a value.">
                <apex:outputLabel value="Direct Hire Fee"/>
                <apex:outputPanel id="DirectHireFee">
                    <input type="text" value="" readonly="readonly" style="color:black; font-weight:bold; border:1px solid #AEAEAE; background-color:white;"/>
                    <!--<apex:inputText label="Gross Margin Pct" value="{!GrossPctString}" disabled="true" style="color:black; font-weight:bold; border:1px solid #AEAEAE; background-color:white;"/>-->
                </apex:outputPanel>
            </apex:pageBlockSectionItem>
            <apex:outputText >
                {!DHPercent}
            </apex:outputText>
        </apex:pageBlockSection>
    </apex:pageBlock>
</apex:page>
</apex:form>
</apex:page>

Controller:

public class DirectHireCalcController {
    public String DHFee {get; set;}
    public String DHPercent {get; set;}
    public DirectHireCalcController(){}
}

 

 

Thanks,

I've put together the following test for a trigger. 

@isTest
public with sharing class AutoCreateSubsTriggerTest {

    static testMethod void testAutoCreateSubs() {
        // First, set up your test User.
        User testUser = generateTestUser();

        // Generate your position but don't perform DML yet
        Contract_Overview__c contover = new Contract(Subsidiaries_On_Contract__c = testUser.Id);

        // Start your test and insert your contract overview
        Test.startTest();
        insert contover;
        Test.stopTest();

        // Get the subs from the DB to ensure they were created
        List<Subs_Serviced_On_Contract__c> subs = [SELECT
                                                 Id
                                             FROM
                                                 Subs_Serviced_On_Contract__c
                                             WHERE
                                                 Contract_Overview__c = :contover.Id
        ];

        // There should be 1 interviewer because only one user ID was provided
        System.assert(1, subs.size(), 'One sub object is expected');
    }

    private User generateTestUser(){
        // We use the System Admin profile because it will always be there
        Profile sysAdmin = [SELECT 
                               Id 
                            FROM 
                               Profile 
                            WHERE 
                               Name = 'System Administrator'
                            LIMIT 1
        ];

        // Generate the user
        User newUser = new User(
            UserName = 'unit.tester@example.com',
            LastName = 'Test',
            FirstName = 'Jane',
            Email = 'unit.tester@example.com',
            phone = '555-555-5555',
            MobilePhone = '555-555-5554',
            Street = '123 Fake Street',
            City = 'Los Angeles',
            State = 'CA',
            PostalCode = '12345',
            CommunityNickName = 'unit.test',
            Alias = 'abcd',
            ProfileId = sysAdmin.Id,
            emailencodingkey = 'UTF-8',
            languagelocalekey = 'en_US',
            localesidkey = 'en_US',
            timezonesidkey = 'America/Los_Angeles'
        );

        // Insert that user
        insert user;

        return user;
    }
}

 I am getting the error "Variable does not exist : user". I don't understand how that's happening. Anybody got an idea ? 

Thank you.

  • March 19, 2013
  • Like
  • 0

I'm trying to add an specific OwnerID to an specific task.

But I couldn't query my others tasks.

 

I'm trying to select the OwnerID from task "1X".

And put in the task "3X" when I complete the task "2X".

 

trigger CriarTarefa_Nova_separacao on Task (after update) {
    
    List<Id> creatorIds = new List<Id>();
  	for (Task task : Trigger.new) {
    if (task.Status == '1X') {
      creatorIds.add(task.CreatedById);
    }
  } 
    
    List<Task> creators = [Select Id, CreatedById from Task Where Id in :creatorIds];
  	Map<Id,String> creatorIdsTo = new Map<Id,String>();
  	for (Task creator : creators) {
    creatorIdsTo.put(creator.Id,creator.CreatedByID);
  }
    
    List<Task> taskNova = new List<Task>();
    for (Task tt : Trigger.new)
    if (tt.subject == '2X' && tt.status == 'Completed'){
                taskNova.add (new Task(
                         Subject = '3X',
                         Status = 'Nenhum',
                         WhatID = tt.WhatID,
                         Description = tt.description,
                    	 OwnerId = creatorIdsTo.get(tt.CreatedById),
                         ActivityDate = Date.today()));
    }
insert taskNova;
}

 My error is:

"Assigned to: Assigned to ID: owner can not be blank"

 

Thanks !

Hi - I am new to Apex programming and triggers and have a simple question.  We are tracking proposals which are a child to an opportunity.  We may have multiple revisions of a proposal - the most recent is the one we should be using. We have approval process set up on the proposal.
 
I have a custom field - "Proposal Status" on the Proposal (New, Pending, Approved, or Rejected  - updated through Approval Process field updates). I would like to copy the value from this field from the latest proposal to a correlating field on the Opportunity when the Proposal Status changes. Note: we can have multiple revisions of the same proposal and I want to use the latest one.
 
I've tried this with roll-up summaries and workflow rules but it doesn't work. Called SFDC support and told that I need a trigger to do this. Can you please help me? I already spent hours on this and I'm about to give up. Nothing seems to work. Please help! Thank you! :)
  • March 18, 2013
  • Like
  • 0

I want to pull a list of Leads from a SOQL query, where the Leads meet some requirements, and are also found in another list from a previous query.

 

A dumbed down version of what I've got:

 

List<AggregateResult> numTasks = [SELECT WhoId
    FROM Task
    WHERE
        status='Completed' AND
        isClosed = true AND
        ActivityDate = LAST_N_DAYS:35
    GROUP BY WhoId
    HAVING count(id) >= :TASKS_MAX];

List<Lead> openLeads = [Select id, ownerId
    FROM Lead
    WHERE
        OwnerId = 'Enter a queue ID here' AND
        Days_Since_Modified__c <= :NUM_OF_DAYS_TO_WATCH AND
        Id IN :numTasks];

 I get:"Error: Compile Error: Invalid bind expression type of SOBJECT:AggregateResult for Id field of SObject Lead at line 63 column 25"

 

I understand it's a type issue, but I find it funny I can go from a Lead List to an Aggregate Result, but not vice versa.

 

How do I do this correctly?  I can't seem to find anything about AggregateResult Lists in the developer's guide that addresses this.

 

Hi Everone,

I wrote this code for scheduler class ,but when i look in below path
 Setup->Monitoring->Scheduled Jobs i am not able be to see my class .


global class Schecudlertestaccount22  implements Schedulable  {
    Schecudlertestaccount22  c = new Schecudlertestaccount22();
    global void execute(SchedulableContext ctx) {
        
        String sch = '0 6 * * * ? ';
        
        system.schedule('Schecudlertestaccount', sch, c);
        
        Account acct= new Account();
        //acct.Type
        acct=[SELECT id, Type from Account where Type='Other'];
        acct.Site='www.abc.com';
        update acct;
    }

}

Can any one pl suggets on this


Regards
madhu

HI All,

I have the below trigger and test class and with this test class i can get only 69% code coverage, can you pls help me increase code coverage for below trigger so i will be able to deploy this to production.
trigger Contactcallout on Contact (after insert, after update, before delete) {
Map<Id, String> m = new Map<Id, String>();
list<Contact> validContacts = new list<Contact>();
set<ID> accIds = new set<ID>();
if(Trigger.isDelete)
    {
        for (contact c : Trigger.old) 
        {
            if(c.RecordTypeId == '012D0000000BaFA' && c.Reg__c == TRUE)
            c.status__c='inactive';
            {
                validContacts.add(c);
                accIds.add(c.accountid);
            }   
        }
    }
    else
    {
for (contact c : Trigger.new) {
    if(c.RecordTypeId == '012D0000000BaFA' && c.Reg__c == TRUE){
    if(Trigger.isUpdate){
        contact old = Trigger.oldMap.get(c.Id);
        if (c.Email != old.Email||c.FirstName!=old.FirstName||c.LastName!=old.LastName||c.phone!=old.phone||c.Title__c!=old.Title__c||c.status__c!=old.status__c||c.AccountID!=old.AccountID||c.Reg__c == TRUE)
         {
             validContacts.add(c);
                accIds.add(c.accountid);
         }
         }else{
         validContacts.add(c);
                accIds.add(c.accountid);
                }
                }
         }   
}
map<ID, Account> accMap;
if(!accIds.IsEmpty()) // guard condition for SOQL
    accMap = new map<ID, Account>([select name from account where id in :accIds]);

for (contact c : validContacts) {
    Account acc = accMap.get(c.AccountID);
    string accName = acc == null ? null : acc.Name;
    WebServiceCallout.sendNotification(c.Id,c.Email,c.FirstName,c.LastName,c.phone,c.Title__c,accName,c.status__c);
              }
}
Test Classs:-
@istest
public class ContactcalloutTestClass{
@istest
static void contactcreate(){
Account acc = new Account();
acc.Name = 'Test';
acc.ShippingStreet = 'test';
acc.ShippingCity = 'test';        
acc.ShippingPostalCode = 'tw31aq';
insert acc;

contact c =new contact();
c.Email = 'abc@gmail.com';
c.Salutation = 'Mr';
c.FirstName = 'Abraham';
c.LastName = 'Daniel';
c.type__c = 'Agency';
c.status__c= 'Active';
insert c;

Contact c1=[Select id from contact Where Id =:c.id];
c1.firstname= 'Daniel';
c1.lastname= 'Abraham';
c1.Email = 'def@gmail.com';
c1.Status__c = 'inactive';
update c1;
           try
           { 
               Delete c1;
              // c1.Status__c = 'Inactive';
            }
           catch(DmlException e) 
           {
               System.debug('The following exception has occurred: ' + e.getMessage());
            }
               }
@istest
static void contactcreate2(){
Account acc2 = new Account();
acc2.Name = 'Test';
acc2.ShippingStreet = 'test';
acc2.ShippingCity = 'test';        
acc2.ShippingPostalCode = 'tw31aq';
insert acc2;

contact c3 =new contact();
c3.Email = 'abc@gmail.com';
c3.Salutation = 'Mr';
c3.FirstName = 'Abraham';
c3.LastName = 'Daniel';
c3.type__c = 'Agency';
c3.status__c= 'Active';
insert c3;

Contact c4=[Select id from contact Where Id =:c3.id];
c4.firstname= 'Daniel';
c4.lastname= 'Abraham';
c4.Email = 'def@gmail.com';
c4.Status__c = 'inactive';
update c4;
if(c4.email !=c3.email||c4.firstname != c3.firstname||c4.lastname != c3.lastname){
Test.setMock(WebServiceMock.class, new WebServiceMockImpl());
            }
            }
            }

I have checked in the developer console and see the lines 21 to lines 32 of the trigger are not being covered. PLease help me increase code coverage to deploy this code. 

Many Thanks 
Abraham
 
Here's the situation - I have a custom object (Referral__c) with a lookup(account) field to (Client__c). That Account has a lookup(contact) field that I want placed into the record on the custom object, field is called Internal_Referral_By__c. I believe I may need to check that the lookup(contact) is not null, but I haven't got there yet. Here's where I am and am getting "Attempt to de-reference a null object" errorsL


trigger autoPopulateReferredBy on Referral__c (before insert, before update){

      set<Id> clientIDSet = new set<Id>();
    for(Referral__c referral: trigger.new){
        if(referral.Client__c != null){
            clientIdSet.add(referral.Client__c);
        }
    }

     map<id, Account> acctMap = new map<ID, Account>([SELECT Id, Name FROM Account where Id IN: clientIdSet]);


    for(Referral__c referral: trigger.new){
        if(acctMap.containsKey(referral.Client__c)){
            referral.Internal_Referral_By__c = acctMap.get(referral.Id).Internal_Referral_By__c;
        }      
    }

}

this code below works fine and throws error when case team is not there when status is changed per code.

however it still throws error when someone updates case and case team is there, what is wrong here?

 

thanks

 

//start ***** checks if case team is there, if not, wont allow change of status
  public  void caseteam(){
 
          setCaseId = new Set<Id>();
     
          for (Case c : mescal){  
           if(c.Status != moldmap.get(c.Id).Status && c.Record_Type_Name__c=='Escalation'
            && (c.status == 'Active Engaged' || c.status == 'Active Wait' || c.status == 'Analysis'||
             c.status == 'Closed'))     
             {
                  setCaseId.add(c.Id);
              }   
              }
             mapCaseWithteamMember = new  Map<Id,CaseTeamMember>();
              if(!(setCaseId.ISEMPTY())){
                  for(CaseTeamMember ct: [SELECT Parentid FROM CaseTeamMember  WHERE parentid IN :setCaseId])
                  {mapCaseWithteamMember.put(ct.ParentId,ct);}
                       }
       if(mapCaseWithTeamMember.ISEMPTY()){  
          for(Case c: mescal)
                  { 
          if(mapCaseWithTeamMember.get(c.Id) ==null &&  c.Record_Type_Name__c=='Escalation' &&
           (c.status == 'Active Engaged' || c.status == 'Active Wait' || c.status == 'Analysis'||
             c.status == 'Closed'))
                          {  
              c.addError('No case team is assigned, please assign a team member before changing status');
                           }
        
                 }
                        }
                       
                         }


  //end ------------------------------------------

I just need to do a trigger version of a Roll up summary. Made it easily for single use but mass Apex updates overload. Here's my un-bulked code below. Any help would be apprecieated.

Assigned_Team__c is a related object to Account that I want to count. 

 

trigger CountCov on Account (before insert, before update) {
    Account [] a = Trigger.new;
    String aid = null;    
    Aid = a[0].id;

        Integer i = [select count() from Assigned_Team__c where Account__c = :aid and Name != 'None'];

    a[0].Coverage_count__c = i;
    }

 

hi

 

 First i create a button on Account. and if i click that button that related contacts owner name is changed as Account owner Name. 

 

Please give me a solution for this... 

  • April 05, 2013
  • Like
  • 0

If I want to have a trigger on a record in one object, that updates a record in another object, how can I accomplish this without having  a SOQL query inside a for loop? We are going to want to map a couple fields back to the other record, so I'm not sure the most efficient way to do this. I was thinking something like this:

 

trigger ContactUpdater on Custom_Object_Name__c (after update) {

 List<Contact> Contactlist = new List<Contact>();
 List<Contact> updatedContacts = new List<Contact>();

 for(Custom_Object_Name__c p : trigger.new){

        If(p.Associated_Contact__c != Null){ 
          Contactlist.add(p.Associated_Contact__c);

          }

	for(Contact c : [SELECT Id FROM Contact WHERE Id IN :Contactlist]){
             c.FieldToUpdate = p.FieldValue;

             updatedContacts.add(c);
          }

         update updatedContacts; 

    }

 

Is there anything inherently wrong with how this is coded?

 

Hi,

 

In essence the below trigger creates records in two junction objects, TrialContactAssociation__c & TrialAccountAssociation__c , when a Trial__c record is created that matches an email address in an existing Contact.  This creates a way for us to track Accounts and Contacts that are already in our system for incoming trials.

 

After a zillion hours of Googling I can't seem to figure out how to reference Email__c outside the for loop?

 

Any help on the bulkification syntax will be greatly appreciated!  All bulkification examples I've come across reference the ID as opposed to a 'column' of incoming records.

 

trigger TrialInsert on Trial__c (after insert) {
    
    List<TrialContactAssociation__c> ContactListItem = new List<TrialContactAssociation__c>();
    List<TrialAccountAssociation__c> AccountListItem = new List<TrialAccountAssociation__c>();
    
    for (Trial__c c : Trigger.new) {
        
        List<Contact> contactID = new List<Contact>([SELECT Id FROM Contact WHERE Email LIKE :c.Email__c]);
        List<Contact> ContactAccountRel = new List<Contact>([SELECT AccountId FROM Contact WHERE Email LIKE :c.Email__c]);

        for (Contact contactItem : contactID){
            TrialContactAssociation__c clt = new TrialContactAssociation__c(Trial__c = c.ID, Contact__c = contactItem.Id);
            ContactListItem.add(clt);        
        }
        for (Contact AccountItem : ContactAccountRel){
            TrialAccountAssociation__c clt2 = new TrialAccountAssociation__c(Trial_Account_Asso__c = c.ID, Account_Trial_Link__c = AccountItem.AccountId);
            AccountListItem.add(clt2);
        }    
    }
    insert ContactListItem;
    insert AccountListItem;
}

 Thanks

 

John

I have a trigger that i need a test class for but I am limited in my apex test writting. Can someone help me with a test method for the fllowing code below? I would really appreciate it.

 

trigger Trigger_ContactBouncedEmailBeforeUpdate on Contact (before update)
{
    
 //Assign the context before and after the change into a Map
    Map<Id,Contact> newContactMap = Trigger.newMap;
    Map<Id,Contact> oldContactMap = Trigger.oldMap;
    
    //Loop through the map
    for(Id contactId:newContactMap.keySet()){
        Contact myNewContact = newContactMap.get(contactId);
        Contact myOldContact = oldContactMap.get(contactId);
        if (myNewContact.EmailBouncedReason <> myOldContact.EmailBouncedReason){
            //if Salesforce is modifying these fields we want to reset are
            myNewContact.IsEmailBounced__c = false;
            myNewContact.EmailBouncedReason__c = null;
            myNewContact.EmailBouncedDate__c = null;
        }
        if (myNewContact.IsEmailBounced__c <> myOldContact.IsEmailBounced__c){
            if(myNewContact.IsEmailBounced__c == true)
            {
                myNewContact.EmailBouncedDate = myNewContact.EmailBouncedDate__c;
                myNewContact.EmailBouncedReason = myNewContact.EmailBouncedReason__c ;
            }
            if(myNewContact.IsEmailBounced__c == false)
            {
                myNewContact.EmailBouncedDate = null;
                myNewContact.EmailBouncedReason = null;
                myNewContact.EmailBouncedReason__c = null;
                myNewContact.EmailBouncedDate__c = null;
            }
        }
    }

}

  • April 04, 2013
  • Like
  • 0

Hi Everyone,

We have a requirement where we need to compare current Client support record with all the old client support record and that needs to be done before saving the record.

We need to compare near about 12 fields for every record which we are selecting during mass operation (can select 100 record for mass operation),but we are not having any field which can used as a key without saving the record.

We tried using map and list but we are getting exceptions ' Too many code statements: 200001' and as well as its making the process too time taking.

Please help to achieve this requirement .

 

Below is the method where we are getting issue:

 

public static Map<Client_support__c,List<String>> checkDuplicatePriceSupportforMassChangeone(List<Client_support__c> PSList){
                   
    List<String> duplicatesPS= new List<String>();    
    List<Client_support__c> OldPS=new List<Client_support__c>();
    oldPS =[select id,status__c,distributor_PRofile__c,Material_Selling__c,Material_Buying__c where status__c='Approved' or status__c='Awaiting distributor Approval' or status__c='Awaiting Nexeo Approval'];
    List <Client_support__c>l1 = new List<Client_support__c>();
    Map<Client_support__c,List<duplicate>> mapPS = new Map<Client_support__c,List<duplicate>>();
    List <String> l2=new List<String>();   
  for(Client_support__c ps:PSList){

    for(Client_support__c ps1:oldPS){

    if(ps.distributor_PRofile__c!=null){
        if(ps.distributor_PRofile__c == ps1.distributor_PRofile__c){
        l1.add(ps1);
    }
    }

    if(ps.Material_Selling__c!=null){
        for(Client_support__c li : L1){
       
            if(ps.Material_Selling__c == ps1.Material_Selling__c){
            //l1.add(li);
            l2.add(li.aggrement_number__c);
            }

        }
    }

   
    }
   
    mapPS.put(ps1 ,l2);

 }   

 

Thanks in advance:))))
                   
   

  • April 04, 2013
  • Like
  • 0

I have created a new app for my org, with new record types, page layouts, etc and deployed it between sandboxes (dev to full) to test the additions. This worked fine but now I'm trying to deploy it in my production org and the change set has failed the validation test.

Basically my problem is I'm not a developer and all the code in our org was written by a consultant before I joinedthe company so I don't want to change things in production when I'm not sure about them. Therefore I would appreciate any help that could be offered!

The new record type won't be using the funnel camp tracker so I'm not sure if that is part of the issue. Would it be possible to add something into the trigger to exclude the new record type I'm trying to deploy? 

 

 

Change set deployment error:

TestClass.testOpportunityTrigger() Class 49 1

Failure Message: "System.AssertException: Assertion Failed: Expected: 3, Actual: 0", Failure Stack Trace: "Class.TestClass.testOpportunityTrigger: line 49, column 1"

 

@isTest
private class TestClass {

    //Test Opportunity Trigger
    static testMethod void testOpportunityTrigger() {
        
        //* Create Test Account, make sure all required fields for Account are populated here:
        Account testAccount = new Account(name = 'TestAccount01');
        insert (testAccount);
        
        test.startTest();
        
        //*Create Opportunities
        Id OptyRecId = Schema.SObjectType.Opportunity.getRecordTypeInfosByName().get('Opportunity Europe').getRecordTypeId();
        list<Opportunity> testListOpty = new list<Opportunity>();
        
        date d = system.Today();
        d.addMonths(1);
        
        //* Insert a list of opportunities, make sure all required fields for Opportunity are populated here:
        testListOpty.add(new Opportunity(AccountId = testAccount.Id, Name = 'TestOpty01', CurrencyIsoCode = 'EUR', StageName = '02. Positioned in Category', CloseDate = d));
        testListOpty.add(new Opportunity(AccountId = testAccount.Id, Name = 'TestOpty02', CurrencyIsoCode = 'EUR', StageName = '02. Positioned in Category', CloseDate = d));
        testListOpty.add(new Opportunity(AccountId = testAccount.Id, Name = 'TestOpty03', CurrencyIsoCode = 'EUR', StageName = '02. Positioned in Category', CloseDate = d));
        
        insert(testListOpty);
                
        //* Check Data, 3 opty therefore we should have 3 funnel trackers.
        system.assertEquals(3, [select Id from Funnel_Camp_Tracker__c where Opportunity__r.Account.Id = :testAccount.Id].size());
        
        test.stopTest();
    }
    
    static testMethod void testGamePlanController(){
      
      //* Create Test Data
      //* Create Test Account, make sure all required fields for Account are populated here:
        Account testAccount = new Account(name = 'TestAccount01');
        insert (testAccount);
        Contact testContact = new Contact(FirstName = 'Bruce', LastName = 'Wayne', Phone = '123', Email = 'batman@batcave.com', MobilePhone = '321');
        insert(testContact);
        
        //*Create Opportunities
        Id OptyRecId = Schema.SObjectType.Opportunity.getRecordTypeInfosByName().get('Opportunity Europe').getRecordTypeId();
        list<Opportunity> testListOpty = new list<Opportunity>();
        
        date d = system.Today();
        d.addMonths(1);
        
        //* Insert a list of opportunities, make sure all required fields for Opportunity are populated here:
        testListOpty.add(new Opportunity(AccountId = testAccount.Id, Name = 'TestOpty01', CurrencyIsoCode = 'EUR', StageName = '02. Positioned in Category', CloseDate = d));
        insert(testListOpty);
        
        list<OpportunityContactRole> TestlistOCR = new list<OpportunityContactRole>();
        for(Integer i=0;i<5;i++){
          TestlistOCR.add(new OpportunityContactRole(Role = 'testRole' + i, OpportunityId = testListOpty[0].Id, ContactId = testContact.Id));
        }
        
        insert (TestlistOCR);
        
      test.startTest();
      
      pageReference p = Page.GenerateGamePlan;
      p.getParameters().put('id', testListOpty[0].Id);
        test.setCurrentPage( p );
        GamePlanController GPC = new GamePlanController();
        GPC.oOpty = testListOpty[0];
              
      test.stopTest();
      
    
    }
}

 

Hi,

 

My req is that ,when a checkbox is checked then 4 fields(3 text fields and 1 picklist field) needs to be enabled or else it should be disabled.

 

I have achieved this functionality with 3 text fields,but i am facing problem in Picklist field since i am unable to do enable/disable.

 

 

Below is the Code:

 

<apex:inputField value="{!Liabilities__c.Type_of_Loan__c}" id="loanType"/>  // PICKLIST FIELD//
<apex:inputText value="{!Liabilities__c.Loan_Amount__c}" disabled="{!NOT(Liabilities__c.Loan_Taken__c)}" />
<apex:inputText value="{!Liabilities__c.Loan_Tenure_Years__c}" disabled="{!NOT(Liabilities__c.Loan_Taken__c)}" />
<apex:inputText value="{!Liabilities__c.EMI__c}" disabled="{!NOT(Liabilities__c.Loan_Taken__c)}" id="EMI"/>

 

Please help me in this context.

 

Thanks in Advance.

 

Regards,

Rabi

  • April 02, 2013
  • Like
  • 0

This table is not appearing when I render the vfpage. What do I need to change in my vf page?

 

<apex:page standardcontroller="PCN_s__c" extensions="pcntable" >
<apex:form >
 <apex:pageBlock >
 <apex:repeat value="{!pcnlist}" var="pcn" >   
   <table> 
        <tr> 
            <td> <apex:outputlabel value="Project Impact"/> </td>
            <td> <apex:outputlabel value="Current Project"/> </td>
            <td> <apex:outputlabel value="Revised Project"/> </td>
            <td> <apex:outputlabel value="Change"/> </td>
            <td> <apex:outputlabel value="Approved"/> </td>
       </tr>
       <tr> 
            <td> <apex:outputlabel value="PROD. LABOR HOURS & COST:"/> </td>
            <td> <apex:inputfield value="{!pcn.Current_PROD_LABOR_HOURS__c}"/> <apex:inputfield value="{!pcn.Current_PROD_LABOR_COST__c}"/> </td>
            <td> <apex:inputfield value="{!pcn.Revised_PROD_LABOR_HOURS__c}"/> <apex:inputfield value="{!pcn.Revised_PROD_LABOR_COST__c}"/> </td>
       </tr>
       <tr>
            <td> <apex:outputlabel value="ENG. LABOR HOURS & COST:"/> </td>
            <td> <apex:inputfield value="{!pcn.Current_ENG_LABOR_HOURS__c}"/> <apex:inputfield value="{!pcn.Current_ENG_LABOR_COST__c}"/> </td>
            <td> <apex:inputfield value="{!pcn.Revised_ENG_LABOR_HOURS__c}"/> <apex:inputfield value="{!pcn.Revised_ENG_LABOR_COST__c}"/> </td>
      </tr>
       <tr>
            <td> <apex:outputlabel value="MATERIAL COST:"/> </td>
            <td> <apex:inputfield value="{!pcn.Current_MATERIAL_COST__c}"/> </td>
            <td> <apex:inputfield value="{!pcn.Revised_MATERIAL_COST__c}"/> </td>
      </tr>
       <tr>
            <td> <apex:outputlabel value="PRINT RELEASE DATE:"/> </td>
            <td> <apex:inputfield value="{!pcn.Current_PRINT_RELEASE_DATE__c}"/> </td>
            <td> <apex:inputfield value="{!pcn.Revised_PRINT_RELEASE_DATE__c}"/> </td>
      </tr>
       <tr>
            <td> <apex:outputlabel value="SCHED. SHIP DATE:"/> </td>
            <td> <apex:inputfield value="{!pcn.Current_SCHED_SHIP_DATE__c}"/> </td>
            <td> <apex:inputfield value="{!pcn.Revised_SCHED_SHIP_DATE__c}"/> </td>
      </tr>
       <tr>
            <td> <apex:outputlabel value="ADDITIONAL COMPONENTS:"/> </td>
            <td> <apex:inputfield value="{!pcn.Current_ADDITIONAL_COMPONENTS__c}"/> </td>
            <td> <apex:inputfield value="{!pcn.Revised_ADDITIONAL_COMPONENTS__c}"/> </td>
      </tr>
       <tr>
            <td> <apex:outputlabel value="TOTAL COST:"/> </td>
            <td> <apex:inputfield value="{!pcn.Current_TOTAL_COST__c}"/> </td>
            <td> <apex:inputfield value="{!pcn.Revised_TOTAL_COST__c}"/> </td>
      </tr>
       <tr>
            <td> <apex:outputlabel value="SELLING PRICE:"/> </td>
            <td> <apex:inputfield value="{!pcn.Current_SELLING_PRICE__c}"/> </td>
            <td> <apex:inputfield value="{!pcn.RevisedSELLING_PRICE__c}"/> </td>
      </tr>
  </table>
</apex:repeat>
</apex:pageBlock>
</apex:form>
</apex:page>

M getting the following error...so code coverage is less than 75%...not able to deploy...Thanks in advance for help...

 

error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, Minutescase: execution of AfterInsert caused by: System.QueryException: Non-selective query against large object type (more than 100000 rows). Consider an indexed filter or contact salesforce.com

 

 

 

@isTest(SeeAllData=true)
private class testMyTaskTrigger {
 
    public static testMethod void testTTrigger(){
      
        
        Account acc  = new Account();
        acc.name = 'Test';
        insert acc;

        Contact con = new Contact();
        con.LastName = 'Test Contact';
        insert con;
       
       
        Task t = new Task();
        t.OwnerId = UserInfo.getUserId();
        t.Subject='Donni';
        t.Status='Not Started';
        t.Priority='Normal';
        t.Minutes_on_tasks__c = 2000;
        t.status = 'Completed';
        insert t;
 
        Task tas = new Task();
        tas.OwnerId = UserInfo.getUserId();
        tas.Subject='Donni';
        tas.Status='Not Started';
        tas.Priority='Normal';
        tas.Minutes_on_tasks__c = 2000;
        tas.status = 'Completed';
        tas.whoid = con.id;

        Sales_Resources__c sr = new Sales_Resources__c ();
        sr.Name = 'Test Sales Resources';
        insert sr;
        
        Task p = [select id from task where Ownerid = '00500000006scDCAAY' limit 1];
         try{
        delete p;
        }
        Catch(Exception e)
        {

          system.debug('Error:'+e);
        }
 
       
        Test.startTest();
        insert tas;
        try{
        delete t;
        }
        Catch(Exception e)
        {

          system.debug('Error:'+e);
        }

        Test.stopTest();
       
     }

}

 

 

same error in this test class also...  Failure Message: "System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, EB_Case_Owner_Trigger: execution of AfterInsert caused by: System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, Minutescase

 

 

@isTest(SeeAllData=true)
private class EB_Case_Owner_Trigger_Test_Class {

    static testMethod void myUnitTest() {
        // TO DO: implement unit test
        EB_SB_Builder__c ebsb = new  EB_SB_Builder__c ();
        Case accs1 = new Case();
        insert ebsb;
        Datetime dt = Datetime.now();
        Case accs = new Case(RecordTypeId='0120000000098Po',Event_Survey_Builder__c = ebsb.Id, Origin= 'Email', Subject='Testing Task', Minutesoncase__c =10, Reason='508 compliance', Product_Type__c = 'Event Tool');
        //Case accs = new Case(ContactId = '003P000000Cu7pU',RecordTypeId='0120000000095Nn',Event_Survey_Builder__c = ebsb.Id, Origin= 'Email', Subject='Testing Task', Minutesoncase__c =10, Reason='508 compliance', Product_Type__c = 'Event Tool' , AccountId='001P000000GF1fq');
            insert accs;
    }
    

}