• snovvblind
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 10
    Replies

I'm currently only getting a 50% code coverage. How do I increase it to closer to 100%?

 

Thanks.

 

Trigger:

 

trigger PPM_CreateEquipmentDetailsRecord on PPM_Project__c (after update) {
    List <PPM_Equipment_Details_History__c> RecToInsert = new List <PPM_Equipment_Details_History__c> ();
    for (PPM_Project__c PPMP : Trigger.new) {
        PPM_Project__c beforeUpdate = System.Trigger.oldMap.get(PPMP.Id);
        if (beforeUpdate.of_Changes_to_Equipment_Details__c != PPMP.of_Changes_to_Equipment_Details__c) {
            PPM_Equipment_Details_History__c PPMBDH = new PPM_Equipment_Details_History__c ();
            PPMBDH.Equipment_Details_Old_Value__c = beforeUpdate.Equipment_Details__c;
            PPMBDH.Equipment_Details_New_Value__c = PPMP.Equipment_Details__c;
            PPMBDH.Project__c = PPMP.Id;
            RecToInsert.add(PPMBDH);
        }
    }
    try {
        insert RecToInsert; 
    } catch (system.Dmlexception e) {
        system.debug (e);
    }
}

 

Test Class:

 

@isTest
public class TestClass {
 
    Static testmethod void methodname() {
         List<PPM_Equipment_Details_History__c> recToInsert = new List<PPM_Equipment_Details_History__c>();
         List<PPM_project__c>  ppc = new List<PPM_Project__c>();
         List<PPM_project__c>  ppcnew = new List<PPM_Project__c>();
         for(Integer i=0; i<=10;i++) {
              PPM_project__c  ppc1 = new PPM_Project__c(name = 'i+s', requiredfields for inserting ppm project object);
              ppc.add(ppc1);
       }
       insert ppc;
       for(PPM_project__c pp:ppc) {
            pp.of_Changes_to_Equipmet_Details__c = "give the new value)
            ppcnew.add(pp);
       }
        update ppcnew;
        
              
}
}

 

Hi All, I'm new to apex and I'm having trouble writing a test classes. :( How can I go about getting at least a 80% code coverage?

 

trigger PPM_CreateEquipmentDetailsRecord on PPM_Project__c (after update) {
    List <PPM_Equipment_Details_History__c> RecToInsert = new List <PPM_Equipment_Details_History__c> ();
    for (PPM_Project__c PPMP : Trigger.new) {
        PPM_Project__c beforeUpdate = System.Trigger.oldMap.get(PPMP.Id);
        if (beforeUpdate.of_Changes_to_Equipment_Details__c != PPMP.of_Changes_to_Equipment_Details__c) {
            PPM_Equipment_Details_History__c PPMBDH = new PPM_Equipment_Details_History__c ();
            PPMBDH.Equipment_Details_Old_Value__c = beforeUpdate.Equipment_Details__c;
            PPMBDH.Equipment_Details_New_Value__c = PPMP.Equipment_Details__c;
            PPMBDH.Project__c = PPMP.Id;
            RecToInsert.add(PPMBDH);
        }
    }
    try {
        insert RecToInsert; 
    } catch (system.Dmlexception e) {
        system.debug (e);
    }
}

 

Hi All,

 

I'm interested in displaying the Chatter Profile pic within a Flight_Resource record, so that it points to a lookup relationship to a user in the User Object. I'm confused as to what the SOQL would look like to implement such a functionality.

 

I know this involves a custom apex controller and visualforce page. Here's the code below. Do you know how I can modify the controller so that I can get the above functionality to work properly? Any help will be much appreciated!

 

Page:

 

<apex:page StandardController="Flight_Resource__c" extensions="profileImageUrl">
    <apex:image id="profileImage" url="{!profileImageUrl}" />
</apex:page>

 Controller:

 

public class profileImageUrl {
    public String profileImageUrl { get; set; }
    List<user> lstuser;
   
    // As this is an extension of standard controller, It must have a parameterized constructor having instance of standard controller.
    public profileImageUrl (ApexPages.StandardController controller) {
         lstuser = [select FullPhotoUrl from User where Id =: UserInfo.getUserId()];
         profileImageUrl=lstuser[0].FullPhotoUrl;  
    }
}

 

If there's a lookup to a user within a record, how do I write a Visualforce page and controller to display that user's profile picture within the record itself? I wanted to see if you had any tips and suggestions on the exact coding itself.

 

Thanks.

I'm a quick learner. I'd just like help this one time, and I'll pick up on the material pretty quickly.

 

Here's the business logic, I'd like:

 

  1. Check whether a date on a field on the Inventory Object is equal to or greater than today().
  2. If its equal to or greater than today(), create a record in an unrelated custom object (Tasks Object), and insert a whole bunch of pre-populated fields
  3. Upon creation of this new record in the Tasks Object, if I set the status field to "Done", I'd like another trigger to first increment a number field in the Inventory Object.
  4. Delete the Tasks Object that was created, after the increment to the Inventory Object is completed.

If you could help, that'd be great.

I'm trying to write a trigger than initiates itself when a checkbox is checked.

 

The trigger will basically go and clear some fields in the record. I've already coded this portion:

 

trigger ReparentToNextPlanningWeek on Innovation_Planning__c (before update) {
    for (Innovation_Planning__c IP : Trigger.new) {
        if(IP.Carryover__c == TRUE) {
            IP.Status__c = NULL;
            IP.Percent_Complete__c = NULL;
            IP.Carryover_Count__c = IP.Carryover_Count__c+1;
            IP.Carryover__c = FALSE;
        }
    }
}

 

I also want this trigger to look into the "Planning Week" object, and reparent itself to the next week's planning record. For example, if the current Innovation Planning record exists as a master-detail to the "03-03-2013" Planning Week record, I'd now like for the trigger to be reparented to the "03-10-2013" Planning Week record. Please note that the dates are always 7 days out and occur on Sundays. Perhaps this could be used in the logic?

 

Basically, I have no idea how to write a trigger that reparents itself to another record in the parent object.

 

Can someone please help?

Hi All, I'm new to apex and I'm having trouble writing a test classes. :( How can I go about getting at least a 80% code coverage?

 

trigger PPM_CreateEquipmentDetailsRecord on PPM_Project__c (after update) {
    List <PPM_Equipment_Details_History__c> RecToInsert = new List <PPM_Equipment_Details_History__c> ();
    for (PPM_Project__c PPMP : Trigger.new) {
        PPM_Project__c beforeUpdate = System.Trigger.oldMap.get(PPMP.Id);
        if (beforeUpdate.of_Changes_to_Equipment_Details__c != PPMP.of_Changes_to_Equipment_Details__c) {
            PPM_Equipment_Details_History__c PPMBDH = new PPM_Equipment_Details_History__c ();
            PPMBDH.Equipment_Details_Old_Value__c = beforeUpdate.Equipment_Details__c;
            PPMBDH.Equipment_Details_New_Value__c = PPMP.Equipment_Details__c;
            PPMBDH.Project__c = PPMP.Id;
            RecToInsert.add(PPMBDH);
        }
    }
    try {
        insert RecToInsert; 
    } catch (system.Dmlexception e) {
        system.debug (e);
    }
}

 

Hi All,

 

I'm interested in displaying the Chatter Profile pic within a Flight_Resource record, so that it points to a lookup relationship to a user in the User Object. I'm confused as to what the SOQL would look like to implement such a functionality.

 

I know this involves a custom apex controller and visualforce page. Here's the code below. Do you know how I can modify the controller so that I can get the above functionality to work properly? Any help will be much appreciated!

 

Page:

 

<apex:page StandardController="Flight_Resource__c" extensions="profileImageUrl">
    <apex:image id="profileImage" url="{!profileImageUrl}" />
</apex:page>

 Controller:

 

public class profileImageUrl {
    public String profileImageUrl { get; set; }
    List<user> lstuser;
   
    // As this is an extension of standard controller, It must have a parameterized constructor having instance of standard controller.
    public profileImageUrl (ApexPages.StandardController controller) {
         lstuser = [select FullPhotoUrl from User where Id =: UserInfo.getUserId()];
         profileImageUrl=lstuser[0].FullPhotoUrl;  
    }
}

 

If there's a lookup to a user within a record, how do I write a Visualforce page and controller to display that user's profile picture within the record itself? I wanted to see if you had any tips and suggestions on the exact coding itself.

 

Thanks.

I'm a quick learner. I'd just like help this one time, and I'll pick up on the material pretty quickly.

 

Here's the business logic, I'd like:

 

  1. Check whether a date on a field on the Inventory Object is equal to or greater than today().
  2. If its equal to or greater than today(), create a record in an unrelated custom object (Tasks Object), and insert a whole bunch of pre-populated fields
  3. Upon creation of this new record in the Tasks Object, if I set the status field to "Done", I'd like another trigger to first increment a number field in the Inventory Object.
  4. Delete the Tasks Object that was created, after the increment to the Inventory Object is completed.

If you could help, that'd be great.