• Wayne_Clark
  • NEWBIE
  • 85 Points
  • Member since 2010

  • Chatter
    Feed
  • 3
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 34
    Questions
  • 37
    Replies

Is is possible for visualforce to automatically page break based on field values within a record.  Below is my Visualforce page code and controller extension.   I'm going to eventually render this as a PDF, but I wanted it to be separated based off the different the clients.  So, this page below will print out the Contacts Name and the different dates they submitted hours, along with the Client that they submitted hours against.  The problem is that it lumps all clients into the same column and into the same page.  I'm trying to get the first page to list everything submitted for Client A, then the second page to submit against Client B and so on.   Thanks in advance for any advise, even if it's to let me know it's not possible. 

 

Visualforce Page:

<apex:page standardController="Contact" extensions="TimeCardExtension" sidebar="false" showheader="false" >
<apex:pageBlock >
<apex:outputField value="{!Contact.Name}"/>
</apex:pageBlock>
<apex:dataTable value="{!timeCard}" var="tim" id="theTimeTable" rowClasses="odd,even" align="left">

            <apex:column >
                &nbsp;
                &nbsp;
                <apex:facet name="header">&nbsp;&nbsp;&nbsp;Date</apex:facet>               
               <b> <apex:outputText value="{!tim.Date__c}  "/></b>
                &nbsp;
            </apex:column>
           
            <apex:column >
                &nbsp;
                &nbsp;
                <apex:facet name="header">&nbsp;&nbsp;&nbsp;Hours</apex:facet>               
               <b> <apex:outputText value="{!tim.Hours__c}  "/></b>
                &nbsp;
            </apex:column>
           
           
            <apex:column >
                &nbsp;
                &nbsp;
                <apex:facet name="header">&nbsp;&nbsp;&nbsp;Client</apex:facet>               
               <b> <apex:outputText value="{!tim.Client__r.Name}  "/></b>
                &nbsp;
            </apex:column>          
</apex:dataTable>
<apex:pageBlock >
<apex:outputField value="{!Contact.Signature__c}"/>
</apex:pageBlock>
</apex:page>

 

Controller:

public with sharing class TimeCardExtension{
   
    private final List<Time_Card__c> timeCard;
   
    public TimeCardExtension(ApexPages.StandardController controller) 
   
        {
        timeCard = [select id, Name, Therapist__c, Date__c, Hours__c, Client__c, Client__r.Name, Therapist__r.Start_Date__c, Start_Date__c, Therapist__r.End_Date__c, Therapist__r.Client__c, Client_Match__c,
        from Time_Card__c where Therapist__c=:ApexPages.currentPage().getParameters().get('id')
        Order By Client__r.Name];
        }
       
         public List<Time_Card__c> gettimeCard() {
            return timeCard;
      } 
   
    }

Hello,, I wanted to get a little feedback to see if this requirement would even possible.

 

Requirement: User navigates to Account, enters start and end dates, then hits a button that will display individual time card information for employees of that Account that have submitted time within that date range specified by the user.

 

There may be multiple employees that have submitted time within the specified date range, I'm just wondering if it's possible for the user to be able to press a button that would open the multiple PDF's of the different data from the employees. So, if there were 2 employees that submitted time within the specified time frame, then there would be 2 PDF pages.

 

I created a custom Time Card object, which is a Master/Detail to the Contact and contains a look up to the Account.  I found the print out of time cards to be easily done on the individual Contact object, but that would require our users to navigate to the individual Contact records to print out there time card for the date range specified.  But, this solution is not ideal as the users may not know who has submitted time cards as employees could change.

 

I'm trying to find out if it's possible for the user to navigate to the Account record, enter a time frame and be able to press a button that would list the employee and there time card data on individual print outs, and not have all the diifferent employees and there data on one big print out. 

 

Is this even possible?  Thanks!

 

 

I have 2 objects (NRMA__c)  (ts2__Application__c).  I'm trying to update a look up field (Candidate__c) on the NRMA object with the Candidate field (ts2__Candidate_Contact__c) from the Application object. 

 

I was able to accomplish other field updates like this through workflows, but for some reason, I was unable to update the Contract lookup field on the NRMA.  I need this field to populate the Contact that is listed on the Application object. 

 

Here is another run down of the fields and objects:

NRMA__c - object that includes a lookup to contacts (Candidate__c) - trying to update this field automatically

ts2__Application - object that includes a looup field to Contacts (ts2__Candidate_Contact__c). 

 

When creating a new record on NRMA from Application, I want this to happen before update, before insert:

NRMA.Candiate c = Application.ts2__Candidate_Contact__c

 

Here is the trigger, but it's not working:

 

trigger CandidateTrigger on NRMA__C (before insert, before update) {

  List<String> canList = new List<String>();
  for (NRMA__c n:Trigger.new){
    canList.add(n.Application__c);
  }
 
  List<ts2__Application__c> contactList = [SELECT Id, Name, ts2__Candidate_Contact__r.Id FROM ts2__Application__c WHERE Id in :canList];
 
  Map<String, Id> nameToId = new Map<String, Id>();
  for(ts2__Application__c c : contactList) {
    nameToId.put(c.Name, c.Id);
  }
 
  for (NRMA__c n:Trigger.new){
  n.Candidate__c = nameToId.get(n.Application__r.ts2__Candidate_Contact__r.Id);
  }
 
  }

 

 

Any ideas?  Thanks!

the salesforce advance search is down, what's the issue? 

 

I was just made aware from 2 companies I work with and I checked myself, anyone else having this issue?

Does it take a while for formula fields to update?  I have a formulat that displays the amount of business days there are between a start and end date.  A month later, I altered the formula, so now, when I create new records, it's correct, but I can't update the old records to be correct.  Do these records just take time to update? Thanks

I'm not sure why I can't get all the records to show up on this report.  The Report Generation status says

"Note: 2,000 of 2,199 records are displayed below. Select Export Details for a complete view of your data."

 

I've ran reports before though that have given me over 20k records. Does the criteria and filters I add to the report take away from the amount of records that would initially show.  Is there any way I could see all the records without having to export it every time? 

 

Thanks in advance!

 



Is it possible to bring over custom Contact fields over to a Tasks object?

 

The Task record includes a Contact name in the Who field. 

 

I've tried a text formula field of Who__r.Custom_Field__c, but it doesnt work.  However WhoID does work, so it makes me think it's possible. 

 

Thanks,

Is there a formula out there that will display the last day of the current year? (12/31/2011)

 

I'm trying to calculate the number of weekd days there are between a date and the end of the year.

 

I've found the formula that will automatically calculate the amount of business days there are between a start and end date, so if I could reference the end date as the formala field that displays the last day of the year, I would meet my requirement.

 

Thanks!

Is it possible to create and deploy a manged package that has dependencies on other manged packages within an org? 

 

For example, I create a master/detail object to the Account,  In order for the logic to work on this custom object, there has to be a lookup field to an object within the manged package.  So, in my developer org, I created an object so that my triggers and everything would function correctly, but I noticed I can not give it the same API name as the object in the managed package, because the object in the managed package has a Namespace Prefix of js2__Job_Order__c. So if I deploy it to production, it wouldn't work because the triggers would not be referencing the js2__Job_Order__c, only Job_Order__c.

 

Any advice? Thanks

This post stems from another post about our orgs issue with overall test coverage issue, the link to the previous post is here:

http://boards.developerforce.com/t5/Apex-Code-Development/Code-Coverage/td-p/257383

 

We found out that there were some classes installed in our production that do not have any code coverage and is bringing our overall coverage to around 35%.  There is also a managed package installed that is causing test failures.  These issues are not allowing us to develop and deploy any custom code.

 

If I developed custom code in a developer org and deployed the custom code we need as a managed package, would it deploy OK?  I've installed other managed packages into our production so I'm thinking this may be the way to go. 

 

Any suggestions or advice?  Thanks!

I'm tyring to insert a master record and detail record from one visualforce page, but I can't get the test class to work, any idea?

 

I'm only getting 64% coverage and it's throwing this message.  Thanks in advance!

 

System.DmlException: Insert failed. First exception on row 0 with id a1OS0000000B8yiMAC; first error: INVALID_FIELD_FOR_INSERT_UPDATE, cannot specify Id in an insert call: [Id]


Class.newVendorPriceController.save: line 43, column 7 Class.TestNewVendorPriceController.TestNewVendorPriceController: line 41, column 1 External entry point

 

public class newVendorPriceController {
   
   
   Vendor_Price_Line_Item__c vendorlineitem;
   Vendor_Pricing__c vendorprice;
   Order__c order;
   
    private final Map<String, String> currentpageParams;

     
     public newVendorPriceController(ApexPages.StandardController controller) {
     
     this.vendorprice = (Vendor_Pricing__c)controller.getRecord();
     this.currentpageParams = ApexPages.currentPage().getParameters();

            
    }   
    
   public Vendor_Pricing__c getvendorprice() {
      if(vendorprice == null) vendorprice = new Vendor_Pricing__c();
      return vendorprice;
   }
   
     public Vendor_Price_Line_Item__c getvendorlineitem() {
      if(vendorlineitem == null) vendorlineitem = new Vendor_Price_Line_Item__c();
      return vendorlineitem;
   }
   

    public string oId = apexpages.currentpage().getParameters().get('id');
    
    
    public PageReference cancel() {
          PageReference pr = new PageReference('/ui/desktop/DesktopPage');
          pr.setRedirect(true);
          return pr;
     }

      public PageReference save() {

      insert vendorprice;
    
      vendorlineitem.Vendor_Price__c=vendorprice.id;
      insert vendorlineitem;


      PageReference vendyPage = new ApexPages.StandardController(vendorprice).view();
      vendyPage.setRedirect(true);

      return vendyPage;
   }

   }

 

 

 

 

 

Test Method:

 

@isTest

private class TestNewVendorPriceController {


static testMethod void TestNewVendorPriceController(){

   Vendor_Pricing__c venprice;
   ApexPages.StandardController sc;
   newVendorPriceController vpc;

Account account = new Account();// specify all the required fields
account.name = 'testing';
account.shippingcity = 'baltimore';
account.shippingstate = 'MD';
account.shippingcountry = 'USA';
account.shippingpostalcode = '21228';
insert account;
Contact contact = new Contact();// specify all the required fields
contact.lastname = 'test';
insert contact;
States__c state = new States__c ();
state.State_Code__c = 'BB';
insert state;
Order__c ord = new Order__c ();
ord.Account__c = account.Id;
insert ord;
Vendor_Pricing__c ven = new Vendor_Pricing__c ();
ven.Order__c = ord.Id;
insert ven;
Vendor_Price_Line_Item__c venline = new Vendor_Price_Line_Item__c ();
venline.Vendor_Price__c = ven.Id;
insert venline;

System.assertNotEquals(null, ven.Id);//tests to see if your insert was successful
   vpc = new newVendorPriceController(new ApexPages.StandardController(ven)); //here you instantiate the controller with a standard controller.
   //start you user testing.

vpc.getvendorprice();
vpc.getvendorlineitem ();
vpc.save();
vpc.cancel();



}

}

Code Coverage: 39%

Your overall code coverage is currently 39%. To deploy code to production, you must have at least 75%.

 

We have about 10 Apex classes that are reading 0% code coverage.

 

I run the test on one of the them and the code coverage shows 100%.

 

I then run a test on another class that reads 0% and the code coverage shows 100%.

 

However, the coverage on the first class I ran now shows 0%.

 

I have about 10 classes showing 0%, but when I run individual test on them, the are above 75%.  Some of these classes include the test code inside the class.  But, there are a few of them where I'm not able to run the test on them, I'm not even sure how these made it to production without being tested.

 

How do I make all the classes read the correct code coverage?  I'm thinking I need to seperate out the test coverage and make a seperate test class for the ones that include the test code, but I wanted to get some feedback before I tackle this.

 

Any feedback is greatly appreciated.

Hello,

 

I'm trying to bring over a list of line items (Payor_Line_Item__c) to an object through lookup fields. 

 

The Pricing_PDF__c object contains a lookup field (Customer_Pricing__c) to the Customer_Price__c object, which is the Master/Detail to the Payor_Line_items__c.  The field on the Payor_Line_items__c that also contains the Customer Price Id is (Payor_Pricing_Number__c). 

 

Since these two object contain similar Id's, I should be able to list the line items on the PDF's....right?   Below is what I have so far and I marked in red what I want the code to say, but am not sure how to code it.

 

Any idea on how I can bring over the line items to the email teamplate? 

 

Thanks in advance!

 

 

Visualforce Email controller component:

 

<messaging:emailTemplate recipientType="Contact" relatedToType="Pricing_PDF__c" subject="KCC Sales Order {!relatedTo.name}" >


<messaging:htmlEmailBody >

<br>
Dear {!recipient.name},</br>

<p>Thank you for your order.</p>

<p>Attached is Sales Order #<apex:outputText value="{!relatedTo.Name}"/>, please review,
sign and fax back at your earliest convenience. </p>

 

<apex:component controller="SalesOrderEmailExtension" access="global">
    <apex:dataTable value="{!lineitem}" var="line">


        <apex:column >
            <apex:facet name="header">Customer Pricing Number</apex:facet>
            {!line.Name}
        </apex:column>


            <apex:column >
            <apex:facet name="header">Product</apex:facet>
            {!line.Product__c}
        </apex:column>


    </apex:dataTable>
</apex:component>

</messaging:htmlEmailBody>

 

Controller:

 

public with sharing class SalesOrderEmailExtension {

    public SalesOrderEmailExtension() {

    }

    private final List<Payor_Line_Item__c> lineitem;
    private final List<Customer_Price__c> price;
    private final List<Pricing_PDF__c> pdf;

    
public SalesOrderEmailExtension(ApexPages.StandardController controller)
        {        
        lineitem = [select id, Name, Payor_Pricing_Number__r.Id, Product__c, Quantity__c, Total_Price__c
        from Payor_Line_Item__c  where Customer_Pricing__r.Id = Pricing_PDF__r.Customer_Pricing__r.Id];
        }


public List<Payor_Line_Item__c> getlineitem() {
            return lineitem;
      }
      

}

Is there a way to set up a report to show all Accounts that do not contain a custom related list?

 

We have a custom object that is a child of the Account, I want to see all the Accounts where there hasn't been any data yet populated in this custom object, so when data is put in there, it will come off of the report.

 

Thanks!

Is there any way to have all child records automatically refresh when a related record's field is updated?  Can an apex trigger be designed so that it will edit and save all the child records each time a field in the master record is changed or updated?

 

Thanks

 

 

Hi,

 

I'm trying to create a Rollup SUM on a master object to total a number formula field on the child records, but it's not letting me select the field to SUM.

 

The formula field on the child record references a related object. Is this the reason it will not let me select that field to SUM? 

Hello,

 

Is it possible to count the number of records there are in a related list, only if their start dates is greater than the master objects start date? 

 

We have a School_Calendar__c which is the child of the Account.  The School Calendar has start and end dates and contains child object Calendar_Events__c, which are a list of events where the school has closings, these records also have start and end dates, example, Spring Break, the school closes between x date and x date.

 

The Order__c is another child object to the Account and includes a start date.

 

I'm trying to Count the number of Calendar_Event_Days__c there are, but only if the start date of the Calendar Event is greater than the start date of the Order.

 

Thanks in advance!

 

Aloha,

 

I'm having trouble testing out this line of code:

 

    public List<Order_Dimension__c> getdimList() {
            return dimList;
      }

 

 

Below is the full controller and test method so far, but only 60% is covered and the lines above are marked in red as not being tested.

 

 

public with sharing class OrderExtension{
    
    
    private final List<Order_Dimension__c> dimList;
    
    public OrderExtension(ApexPages.StandardController controller)     
        {
        dimList = [select e.Name, e.Commodity_Description__c, e.Length_Feet__c, Length_Inches__c, Width_Feet__c, Width_Inches__c, Height_Feet__c, Height_Inches__c, Classification__c, Dimensions__c
        from Order_Dimension__c e where Order__c=:ApexPages.currentPage().getParameters().get('id') 
        ];
    }
        
    public List<Order_Dimension__c> getdimList() {
            return dimList;
      }
  
}

 

@isTest

private class TestOrderExtension {

static testMethod void testOrderExtension(){
   Order__c order;
   ApexPages.StandardController sc;
   OrderExtension ore;

Account account = new Account();// specify all the required fields
account.name = 'testing';
account.shippingcity = 'baltimore';
account.shippingstate = 'MD';
account.shippingcountry = 'USA';
account.shippingpostalcode = '21228';
insert account;
Contact contact = new Contact();// specify all the required fields
contact.lastname = 'test';
insert contact;
States__c state = new States__c ();
state.State_Code__c = 'BB';
insert state;
Order__c ord = new Order__c ();
ord.Account__c = account.Id;
insert ord;
Order_Dimension__c dim = new Order_Dimension__c ();
dim.order__c = order.Id;
dim.Commodity_Description__c = 'steel';
dim.Classification__c = 'new';
dim.Height_Feet__c = Decimal.valueOf('1');
dim.Height_Feet__c = Decimal.valueOf('1');
dim.Length_Feet__c = Decimal.valueOf('1');
dim.Length_Inches__c = Decimal.valueOf('1');
dim.Width_Feet__c = Decimal.valueOf('1');
dim.Width_Inches__c = Decimal.valueOf('1');


System.assertNotEquals(null, ord.Id);//tests to see if your insert was successful
   ore = new OrderExtension(new ApexPages.StandardController(ord)); //here you instantiate the controller with a standard controller.
   //start you user testing.




}

}

 

 

Hello,

 

I have a custom object (Order__c) where I've embedded a visualforce page within the page layout.  The page has an extension to retrieve a list of the related list (Stops__c).  I'm trying to create a link on the Name of the stops so the user can click the link and go to the specific record with in the related list (Stops__c), or better yet mimic the pop-up window that shows when you hoover the mouse over a lookup field.  Any ideas on how to achieve this? 

 

Below is the main code I have so far on my Visualforce page, I've managed to link it to the page, but only when I'm in the visualforce/apex edit mode with the URL is set at apex/order?id={lorder__c.Id}

 

Visualforce markup:

 

<apex:dataTable value="{!StopList}" var="STOP">

 

      <apex:column >
        <apex:facet name="header">
         <apex:outputText value="Stop Name"/>
       </apex:facet>
       <apex:outputLink value="Stops?id={!STOP.Id}" id="theLink"> {!STOP.Name} </apex:outputLink>
       <!-- Position name field is linked to the job details page -->
       </apex:column>

 

 

The link only works when I'm the visualforce edit view (visual.force.com/apex/order?id=a0kS0000000738i), but not when I'm in the normal record view (my.salesforce.com/a0kS0000000738i)  The link goes to another Visualforce page called Stops.  Any ideas on how to get this link to work in the regular record view, or also have a popup on mouseover?

 

Thanks in advance!

 

 

Hello,

 

I am trying to build an apex controller for a visualforce email template that will pull information from multiple related list on a custom object. Sort of like the Quote PDF's work with including the Quote Line Items.

 

Order__c is the master object, Order_Line_Items__c and Order_Stops__c are the detail objects. 

 

There is also another detail object on the Order__c called Order_PDFs__c where I will generate the email from.  I'm trying to get the Order_PDF__c email template to include information from the Order_Line_Item and the Order_Stops where the id's all match the master order ID.  Below is a drawing of the schema and what I have as far as code so far.  I'm having trouble pulling the order line items and order stops that only contain the same order ID.

 

I'm not sure how to match the ID of the order in the Order PDF with the order ID in the Order Line Item in the Where clause.  Can anyone point me in the right direction?  Thanks in advance!

 

Visualforce Email Component Code:

<apex:component controller="SalesOrderEmailExtension" access="global">
    <apex:dataTable value="{!CustomerOrderList}" var="cust">
        <apex:column>
            <apex:facet name="header">Order Line Item Name</apex:facet>
            {!cust.Name}
        </apex:column>
            <apex:column>
            <apex:facet name="header">Product</apex:facet>
            {!cust.Payor__r.Name}
        </apex:column>
    </apex:dataTable>
</apex:component>

 

 

 

Apex Controller:

public with sharing class SalesOrderEmailExtension {
    public SalesOrderEmailExtension() {
    }


    private final List<Customer_Order_Line_Item__c> CustomerOrderList;
    
public SalesOrderEmailExtension(ApexPages.StandardController controller) {
        CustomerOrderList = [select id, Name, order__c, Order__r.ID, Product__c,
        from Customer_Order_Line_Item__c  where Order__r.ID = Order_PDFs__r.order__r.id];
    }

public List<Customer_Order_Line_Item__c> getCustomerOrderList() {
            return CustomerOrderList;
      }

}

 

 

 

I have 2 objects (NRMA__c)  (ts2__Application__c).  I'm trying to update a look up field (Candidate__c) on the NRMA object with the Candidate field (ts2__Candidate_Contact__c) from the Application object. 

 

I was able to accomplish other field updates like this through workflows, but for some reason, I was unable to update the Contract lookup field on the NRMA.  I need this field to populate the Contact that is listed on the Application object. 

 

Here is another run down of the fields and objects:

NRMA__c - object that includes a lookup to contacts (Candidate__c) - trying to update this field automatically

ts2__Application - object that includes a looup field to Contacts (ts2__Candidate_Contact__c). 

 

When creating a new record on NRMA from Application, I want this to happen before update, before insert:

NRMA.Candiate c = Application.ts2__Candidate_Contact__c

 

Here is the trigger, but it's not working:

 

trigger CandidateTrigger on NRMA__C (before insert, before update) {

  List<String> canList = new List<String>();
  for (NRMA__c n:Trigger.new){
    canList.add(n.Application__c);
  }
 
  List<ts2__Application__c> contactList = [SELECT Id, Name, ts2__Candidate_Contact__r.Id FROM ts2__Application__c WHERE Id in :canList];
 
  Map<String, Id> nameToId = new Map<String, Id>();
  for(ts2__Application__c c : contactList) {
    nameToId.put(c.Name, c.Id);
  }
 
  for (NRMA__c n:Trigger.new){
  n.Candidate__c = nameToId.get(n.Application__r.ts2__Candidate_Contact__r.Id);
  }
 
  }

 

 

Any ideas?  Thanks!

the salesforce advance search is down, what's the issue? 

 

I was just made aware from 2 companies I work with and I checked myself, anyone else having this issue?

This post stems from another post about our orgs issue with overall test coverage issue, the link to the previous post is here:

http://boards.developerforce.com/t5/Apex-Code-Development/Code-Coverage/td-p/257383

 

We found out that there were some classes installed in our production that do not have any code coverage and is bringing our overall coverage to around 35%.  There is also a managed package installed that is causing test failures.  These issues are not allowing us to develop and deploy any custom code.

 

If I developed custom code in a developer org and deployed the custom code we need as a managed package, would it deploy OK?  I've installed other managed packages into our production so I'm thinking this may be the way to go. 

 

Any suggestions or advice?  Thanks!

I'm tyring to insert a master record and detail record from one visualforce page, but I can't get the test class to work, any idea?

 

I'm only getting 64% coverage and it's throwing this message.  Thanks in advance!

 

System.DmlException: Insert failed. First exception on row 0 with id a1OS0000000B8yiMAC; first error: INVALID_FIELD_FOR_INSERT_UPDATE, cannot specify Id in an insert call: [Id]


Class.newVendorPriceController.save: line 43, column 7 Class.TestNewVendorPriceController.TestNewVendorPriceController: line 41, column 1 External entry point

 

public class newVendorPriceController {
   
   
   Vendor_Price_Line_Item__c vendorlineitem;
   Vendor_Pricing__c vendorprice;
   Order__c order;
   
    private final Map<String, String> currentpageParams;

     
     public newVendorPriceController(ApexPages.StandardController controller) {
     
     this.vendorprice = (Vendor_Pricing__c)controller.getRecord();
     this.currentpageParams = ApexPages.currentPage().getParameters();

            
    }   
    
   public Vendor_Pricing__c getvendorprice() {
      if(vendorprice == null) vendorprice = new Vendor_Pricing__c();
      return vendorprice;
   }
   
     public Vendor_Price_Line_Item__c getvendorlineitem() {
      if(vendorlineitem == null) vendorlineitem = new Vendor_Price_Line_Item__c();
      return vendorlineitem;
   }
   

    public string oId = apexpages.currentpage().getParameters().get('id');
    
    
    public PageReference cancel() {
          PageReference pr = new PageReference('/ui/desktop/DesktopPage');
          pr.setRedirect(true);
          return pr;
     }

      public PageReference save() {

      insert vendorprice;
    
      vendorlineitem.Vendor_Price__c=vendorprice.id;
      insert vendorlineitem;


      PageReference vendyPage = new ApexPages.StandardController(vendorprice).view();
      vendyPage.setRedirect(true);

      return vendyPage;
   }

   }

 

 

 

 

 

Test Method:

 

@isTest

private class TestNewVendorPriceController {


static testMethod void TestNewVendorPriceController(){

   Vendor_Pricing__c venprice;
   ApexPages.StandardController sc;
   newVendorPriceController vpc;

Account account = new Account();// specify all the required fields
account.name = 'testing';
account.shippingcity = 'baltimore';
account.shippingstate = 'MD';
account.shippingcountry = 'USA';
account.shippingpostalcode = '21228';
insert account;
Contact contact = new Contact();// specify all the required fields
contact.lastname = 'test';
insert contact;
States__c state = new States__c ();
state.State_Code__c = 'BB';
insert state;
Order__c ord = new Order__c ();
ord.Account__c = account.Id;
insert ord;
Vendor_Pricing__c ven = new Vendor_Pricing__c ();
ven.Order__c = ord.Id;
insert ven;
Vendor_Price_Line_Item__c venline = new Vendor_Price_Line_Item__c ();
venline.Vendor_Price__c = ven.Id;
insert venline;

System.assertNotEquals(null, ven.Id);//tests to see if your insert was successful
   vpc = new newVendorPriceController(new ApexPages.StandardController(ven)); //here you instantiate the controller with a standard controller.
   //start you user testing.

vpc.getvendorprice();
vpc.getvendorlineitem ();
vpc.save();
vpc.cancel();



}

}

Code Coverage: 39%

Your overall code coverage is currently 39%. To deploy code to production, you must have at least 75%.

 

We have about 10 Apex classes that are reading 0% code coverage.

 

I run the test on one of the them and the code coverage shows 100%.

 

I then run a test on another class that reads 0% and the code coverage shows 100%.

 

However, the coverage on the first class I ran now shows 0%.

 

I have about 10 classes showing 0%, but when I run individual test on them, the are above 75%.  Some of these classes include the test code inside the class.  But, there are a few of them where I'm not able to run the test on them, I'm not even sure how these made it to production without being tested.

 

How do I make all the classes read the correct code coverage?  I'm thinking I need to seperate out the test coverage and make a seperate test class for the ones that include the test code, but I wanted to get some feedback before I tackle this.

 

Any feedback is greatly appreciated.

Hi,

 

I'm trying to create a Rollup SUM on a master object to total a number formula field on the child records, but it's not letting me select the field to SUM.

 

The formula field on the child record references a related object. Is this the reason it will not let me select that field to SUM? 

Hello,

 

Is it possible to count the number of records there are in a related list, only if their start dates is greater than the master objects start date? 

 

We have a School_Calendar__c which is the child of the Account.  The School Calendar has start and end dates and contains child object Calendar_Events__c, which are a list of events where the school has closings, these records also have start and end dates, example, Spring Break, the school closes between x date and x date.

 

The Order__c is another child object to the Account and includes a start date.

 

I'm trying to Count the number of Calendar_Event_Days__c there are, but only if the start date of the Calendar Event is greater than the start date of the Order.

 

Thanks in advance!

 

Aloha,

 

I'm having trouble testing out this line of code:

 

    public List<Order_Dimension__c> getdimList() {
            return dimList;
      }

 

 

Below is the full controller and test method so far, but only 60% is covered and the lines above are marked in red as not being tested.

 

 

public with sharing class OrderExtension{
    
    
    private final List<Order_Dimension__c> dimList;
    
    public OrderExtension(ApexPages.StandardController controller)     
        {
        dimList = [select e.Name, e.Commodity_Description__c, e.Length_Feet__c, Length_Inches__c, Width_Feet__c, Width_Inches__c, Height_Feet__c, Height_Inches__c, Classification__c, Dimensions__c
        from Order_Dimension__c e where Order__c=:ApexPages.currentPage().getParameters().get('id') 
        ];
    }
        
    public List<Order_Dimension__c> getdimList() {
            return dimList;
      }
  
}

 

@isTest

private class TestOrderExtension {

static testMethod void testOrderExtension(){
   Order__c order;
   ApexPages.StandardController sc;
   OrderExtension ore;

Account account = new Account();// specify all the required fields
account.name = 'testing';
account.shippingcity = 'baltimore';
account.shippingstate = 'MD';
account.shippingcountry = 'USA';
account.shippingpostalcode = '21228';
insert account;
Contact contact = new Contact();// specify all the required fields
contact.lastname = 'test';
insert contact;
States__c state = new States__c ();
state.State_Code__c = 'BB';
insert state;
Order__c ord = new Order__c ();
ord.Account__c = account.Id;
insert ord;
Order_Dimension__c dim = new Order_Dimension__c ();
dim.order__c = order.Id;
dim.Commodity_Description__c = 'steel';
dim.Classification__c = 'new';
dim.Height_Feet__c = Decimal.valueOf('1');
dim.Height_Feet__c = Decimal.valueOf('1');
dim.Length_Feet__c = Decimal.valueOf('1');
dim.Length_Inches__c = Decimal.valueOf('1');
dim.Width_Feet__c = Decimal.valueOf('1');
dim.Width_Inches__c = Decimal.valueOf('1');


System.assertNotEquals(null, ord.Id);//tests to see if your insert was successful
   ore = new OrderExtension(new ApexPages.StandardController(ord)); //here you instantiate the controller with a standard controller.
   //start you user testing.




}

}

 

 

Hello,

 

I have a custom object (Order__c) where I've embedded a visualforce page within the page layout.  The page has an extension to retrieve a list of the related list (Stops__c).  I'm trying to create a link on the Name of the stops so the user can click the link and go to the specific record with in the related list (Stops__c), or better yet mimic the pop-up window that shows when you hoover the mouse over a lookup field.  Any ideas on how to achieve this? 

 

Below is the main code I have so far on my Visualforce page, I've managed to link it to the page, but only when I'm in the visualforce/apex edit mode with the URL is set at apex/order?id={lorder__c.Id}

 

Visualforce markup:

 

<apex:dataTable value="{!StopList}" var="STOP">

 

      <apex:column >
        <apex:facet name="header">
         <apex:outputText value="Stop Name"/>
       </apex:facet>
       <apex:outputLink value="Stops?id={!STOP.Id}" id="theLink"> {!STOP.Name} </apex:outputLink>
       <!-- Position name field is linked to the job details page -->
       </apex:column>

 

 

The link only works when I'm the visualforce edit view (visual.force.com/apex/order?id=a0kS0000000738i), but not when I'm in the normal record view (my.salesforce.com/a0kS0000000738i)  The link goes to another Visualforce page called Stops.  Any ideas on how to get this link to work in the regular record view, or also have a popup on mouseover?

 

Thanks in advance!

 

 

Hello,

 

Is there anyway to add Products to a custom object like it is with the Opportunity? 

 

Thanks!

I'm trying to populate a lookup to Account in Account called Parent_or_Self_Id__c, but it generates an error when I set a record to reference itself:

Hierarchy Constraint Violation in the UI

or

CIRCULAR_DEPENDENCY, attempt to violate hierarchy constraints in Apex

 

From a Data Model and a practical perspective it's much preferred to have one lookup field than potentially sixty-five cross object formulas (if that's even allowed) to pull the data from the parent record defaulting with the current record.

 

Anyone know if the apparent check restricting circular references in the data can be disabled by the SalesForce feature activation customer support?  I called a different area of customer support and the person seemed to be under the assumption that it couldn't be changed without any reasoning why.

 

Perhaps the validation rule was created by a salesforce developer over-protecting the system so he could guarantee no infinate loops ever?  In theory poorly coded Apex especially triggers could be following lookups in the data and get lost in an infinate loop.  But in practice, if that happened it would violate a governor rule, and generate an API error with no harm.   I can't think of any other reason to restrict data from having circular references.  Perhaps there is more reasoning to this restriction that I'm not aware of?

 

I keep running into all of these different ways that SalesForce is crippled... perhaps one per month!  So disappointing!  Another item to add to the list of technical flaws in SalesForce that maybe I can get someone to listen to at the next DreamForce?  SalesForce may be one of the least flawed Content Management Systems (CMS), but that's why experienced people often caution against CMS instead of custom programming because of those things you need done that can't be done!