• Brad Both
  • NEWBIE
  • 10 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 2
    Replies

I am in desperate need of help and everything I find on this doesn't help what I'm attempting to do. Let's start with the basics. I'm creating a "Program Report" document, all the content on the document is being populated by several different objects within my Program object. The document begins with a general overview and description and ends with disclaimers. Outside of the disclaimers at the bottom, the rest of the information is called from the Program Object and it's children. 

Some things to note, I'm primarily using pageblockTables to display the data and my local css sheet to style it the way it is needed. Every table I have does not display the headers at all and they are completely hidden. So instead of headers I am using custom images. The reason for this is that we want to maintain a design flow and because a customer will get this report we need it to fall in line with the design of the rest of what we are creating. The biggest issue is being that rendering a pdf only allows four fonts and we have a specific one that we need to use for our headers and subheaders. Now, everything looks good but there is a small issue. 

Between that top and bottom is 3 different subsections. Each has a list of parameters which have a variable attached to them as well as a description. Two of these are displayed the same where in the first row is two columnes, one with the name the other with the variable. The next row that spans both colums has the description. The third looks a little different but same principal. Names and Variables span across 4 columns and in the next row has two Descriptions one spanning one column the other spanning two columns. 

And here inlies the issue. when I'm going from page to page the table just continues to the next page without any breaks. I will try and find links to the things I have already tried which has included the css style page-break-after:always. The issue with this is it's not page breaking within the table but after the table so the issue of the table spilling into the next page and leaving some content on one page and the related description is on another. Or the description will get cut in half. This can't happen.

The other fix that was mentioned was something I believed is refered to as pagination, again this seems like a great idea but it also requires a limi as to the number of entries per page which forces you to tweak numbers until you find the right balance. The problem with this is my initial decription can be two sentences or two paragraphs. This immediately changes where all my subheaders start. Because I'm creating dynamically it's impossible for me to know just how many items will be displayed on any given page. 

I can take some screenshots and copy code if necessary but as it stands I don't have any code in here many an attempts to fix the page breaking issue. Thanks for any and all help

I am creating a Program Report which is being populated by multiple objects. At the very top it has all the general information for the program. In this instance we'll say "Name", "System", "Status", "State". So because we are rendering as a PDF but still wanted to use our companies font I created images to act as headers for each table and am not displaying the header for each pageblockTable including this one.

When I initially created it I used columnswidth to break the 6 columns to line up perfectly with the image above it. This worked regularly for multiple system and multiple program reports. I then brought the visualforce page into production and now my columnswidth aren't being maintained at all and I would need to adjust the numbers manually for whatever reason.

Here is the apex code that is creating the table. And depending on the program these widths change, and it has nothing to do with the information in the cells as the information won't fill a whole cell, it is at most 7 letters. Like I said, when this was created, those % values worked fine, but now they aren't and what's even weirder to me is sometimes the table will only fill up half the page, so the last column ends at half the page length, sometimes 70% of the page length but never like it was in the Sandbox

<apex:pageBlockSection columns="1">
<apex:pageblockTable headerClass="hideTableHeader" value="{!myProgram}" var="ProgramID" columnsWidth="30%, 22%, 12%, 12%, 12%, 12%">
<apex:column styleclass="ProgName" value="{!ProgramID.name}"/>
<apex:column styleclass="topContent" value="{!ProgramID.Electrical_System__c}"/>
<apex:column styleclass="topContent" value="{!ProgramID.Bootloader__c}"/>
<apex:column styleclass="topContent" value="{!ProgramID.Base_Program__c}"/>
<apex:column styleclass="topContent" ><apex:outputText value="{!if((myProgram.Active__c)=true, "Active", "Inactive")}"/></apex:column>
<apex:column styleclass="topContent"  value="{!myProgram.Status_Reason__c}"/>
</apex:pageblockTable>
</apex:pageBlockSection>

Let me do my best to explain this properly. I'm in the middle of creating a controller class, using that controller I will be creating a visualforce page that will be creating PDFs using this controller.

User-added image 
Above is the way my current set up looks. I have my Parent object called Programs__c, within Programs__c is multiple fields, a lookup relationship and 3 children (Program_Toggle__c, Program_IO__c, Program_Details__c). For the sake of my document creation I will need to access all of the fields within Program__c as well as it's children. So far so easy. 

Now looking into the three children, they each have their own fields and one (or two) look up relationship to either Program_Toggle_Option__c, Program_IO_Function__c, or Program_Details_Variable__c (Which matches to which should be obvious). There are 3 fields in each of these objects and I need to display all of them. Every piece of literature I find gives me ways to access grandchildren of parents, but when I try and follow these instructions I run into the issues where the relationship between the Child and Lookup Relationship cannot be found. 

This was the primary resource I used, to help create my controller. Which in all honesty at this point is basically a copy paste with all variables changed to properly reflect my objects to see if it will work. Replacing Member with Program, Interest with Program_Toggle and Equipment with Program_Toggle_Option In my controller I'm only trying to access the fields from the Program_Toggle__c lookup relationship with Program_Toggle_Option__c and I'm receiving this error. 

Error: Compile Error:
Didn't understand relationship
 'Program_Toggle_Options__r' in FROM part of query call. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names.

If any other information is required let me know. 

Hey all, so here's my issue. When I first did some updates through deploying the changes everything went well. I tried to create a class and deploy it and it failed (See my last question). Now we are trying to update another class to have one extra field being collected, when deployed we are getting the exact same errors. I also had to refresh my sandbox before I did this, I have no idea if that makes a difference. Someone did respond with what what each error. In all honesty I'm just very confused as to why with minimal changes to the controller is it throwing errors when it was fine last week. I'm assuming the issue isn't from the controller at all but something else entirely. Here are the errors, please let me know if you need anything else to help. Thanks

 

Here are the 4 errors I'm getting:
CalculateBusinessHoursAgesTest || testBusinessHoursBucketer || System.Exception: Assertion Failed 
Stack Trace: Class.CalculateBusinessHoursAgesTest.testBusinessHoursBucketer: line 29, column 1

Catalog_Controller_Test || runTest || System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Carrier can not be North America for overseas shipments.: [Preferred_Carrier__c] 
Stack Trace: Class.Catalog_Controller_Test.runTest: line 32, column 1

Milestone1_Test_Field_Values || testFieldValues || System.AssertException: Assertion Failed: Expected: -1789.690000000000000000000000000000000001, Actual: -1789.69 
Stack Trace: Class.Milestone1_Test_Field_Values.testFieldValues: line 245, column 1

OppPusherTests || myOppUnitTest || System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, Opportunity_SetPricebook: execution of BeforeInsert caused by: System.NullPointerException: Attempt to de-reference a null object Trigger.Opportunity_SetPricebook: line 16, column 1: [] 
Stack Trace: Class.OppPusherTests.createOppty: line 73, column 1 Class.OppPusherTests.myOppUnitTest: line 30, column 1

Hey all, fairly new to Salesforce and Apex. So I'm trying to create a class that will store all the data from the parent object and the 3 child objects. I'll be using this controller in VisualForce to create PDFs with the fields collected in the class. Here is the full class (This was based on another class roughly doing the same thing, which may be where my problem is). It is failing 4 Apex tests when deployed. Thanks for the help, and apologies if this has a simple solution I'm just not seeing!

-----

public with sharing class Program_Controller {

public Program__c myProgram{get;set;}

public Program_Controller(){
    myProgram=new Program__c();
    
    if(ApexPages.currentPage().getParameters().get('id')!=null){
        myProgram=[SELECT   Name, 
                                                    Active__c, 
                                                    Alpha_Test__c, 
                                                    Base_Program__c, 
                                                    Beta_Test__c, 
                                                    Bootloader__c, 
                                                    Complexity__c, 
                                                    Description__c, 
                                                    Design_Approval__c, 
                                                    Design_Finalized__c, 
                                                    Electrical_System__c, 
                                                    Engineering_Documentation_Review__c, 
                                                    Estimated_Completion__c,
                                                    Field_test_Required__c, 
                                                    Final_Test__c, 
                                                    Program_ID__c, 
                                                    Sales_Documentation_Review__c, 
                                                    Sales_R_C_Review__c, 
                                                    Short_Descrip__c, 
                                                    Status_Reason__c, 
                                                    Sticker__c, 
                                                    (SELECT Name, 
                                                        Active__c,
                                                        Jumper_Position__c,
                                                        MSID__c,
                                                        Toggle__c,
                                                        ToggleDisp__c,
                                                        Toggle_State__c              
                                                    FROM Program_Toggles__r),
                                                    (SELECT Name, 
                                                        Active__c,
                                                        Duration__c,
                                                        Function__c,
                                                        FunctionDisp__c,
                                                        MSID__c,
                                                        Signal__c,
                                                        SignalDisplay__c,
                                                        Wire__c              
                                                    FROM Program_IOs__r),
                                                    (SELECT Name, 
                                                        Active__c,
                                                        Jumper_Position__c,
                                                        MSID__c,
                                                        TypeDisp__c,
                                                        Value__c,
                                                        Variable__c,
                                                        VariableDisp__c              
                                                    FROM Program_Details__r)
                            FROM PROGRAM__c p
                            WHERE p.Id=:ApexPages.currentPage().getParameters().get('id')];
                }
        }
}//end of class

----

Here are the 4 errors I'm getting:

CalculateBusinessHoursAgesTest || testBusinessHoursBucketer || System.Exception: Assertion Failed 
Stack Trace: Class.CalculateBusinessHoursAgesTest.testBusinessHoursBucketer: line 29, column 1

Catalog_Controller_Test || runTest || System.DmlException: Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Carrier can not be North America for overseas shipments.: [Preferred_Carrier__c] 
Stack Trace: Class.Catalog_Controller_Test.runTest: line 32, column 1

Milestone1_Test_Field_Values || testFieldValues || System.AssertException: Assertion Failed: Expected: -1789.690000000000000000000000000000000001, Actual: -1789.69 
Stack Trace: Class.Milestone1_Test_Field_Values.testFieldValues: line 245, column 1

OppPusherTests || myOppUnitTest || System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, Opportunity_SetPricebook: execution of BeforeInsert caused by: System.NullPointerException: Attempt to de-reference a null object Trigger.Opportunity_SetPricebook: line 16, column 1: [] 
Stack Trace: Class.OppPusherTests.createOppty: line 73, column 1 Class.OppPusherTests.myOppUnitTest: line 30, column 1

Hey, I'm fairly new to this and haven't been able to find an answer elsewhere, or I have missed it. What I'm trying to accomplish is checking to see if the string has at least 2 characters and if it does I use that string inside a URL to create a barcode. If it is less than 2 then it will return a blank image instead of the barcode.

It just doesn't seem to be working that way, when I try to use the variable within the URL it "cuts" the URL at that point where I put it in and returns the basic barcode from the site.

-----

<apex:pageBlock >
    <apex:pageBlockSection id="Items" columns="1" 
            showHeader="true" collapsible="false">  
      <apex:pageBlockTable value="{!myOrder.OrderItems}" headerClass="hidden"  cellPadding="4"  border="0" var="item" > 
                            
      <apex:column headerValue="Customer P/N" width="25%"><apex:image id="CusPN" value="{!IF(LEN(item.PriceBookEntry.Product2.ProductCode)>2, 'http://generator.barcodetools.com/barcode.png?gen=0&data={!item.PriceBookEntry.Product2.ProductCode}&bcolor=FFFFFF&fcolor=000000&tcolor=000000&fh=8&bred=&w2n=2.5&xdim=2&w=250&h=30&debug=1&btype=2&angle=0&quiet=0&balign=2&talign=2&guarg=1&text=1&tdown=1&stst=1&schk=0&cchk=1&ntxt=1&c128=0', '---')}"/>
                </apex:column>
                
                <apex:column headerValue="CCM P/N" width="25%"><apex:image id="CCMPN" value="http://generator.barcodetools.com/barcode.png?gen=0&data={!item.PriceBookEntry.Product2.ProductCode}&bcolor=FFFFFF&fcolor=000000&tcolor=000000&fh=8&bred=&w2n=2.5&xdim=2&w=250&h=30&debug=1&btype=2&angle=0&quiet=1&balign=2&talign=2&guarg=1&text=1&tdown=1&stst=1&schk=0&cchk=1&ntxt=1&c128=0}"/>
                </apex:column>

-----

So those are the two columns, only the one needs to be checked while the other one works fine. Again my knowledge is fairly limited within VisualForce and Apex, and as far as I can tell when I'm trying to use the variable within the IF statement using { } it is cause the URL to get shortened to "http://generator.barcodetools.com/barcode.png?gen=0&data=" which is exactly what I'm getting as an output.

Thanks for all the help!

I am creating a Program Report which is being populated by multiple objects. At the very top it has all the general information for the program. In this instance we'll say "Name", "System", "Status", "State". So because we are rendering as a PDF but still wanted to use our companies font I created images to act as headers for each table and am not displaying the header for each pageblockTable including this one.

When I initially created it I used columnswidth to break the 6 columns to line up perfectly with the image above it. This worked regularly for multiple system and multiple program reports. I then brought the visualforce page into production and now my columnswidth aren't being maintained at all and I would need to adjust the numbers manually for whatever reason.

Here is the apex code that is creating the table. And depending on the program these widths change, and it has nothing to do with the information in the cells as the information won't fill a whole cell, it is at most 7 letters. Like I said, when this was created, those % values worked fine, but now they aren't and what's even weirder to me is sometimes the table will only fill up half the page, so the last column ends at half the page length, sometimes 70% of the page length but never like it was in the Sandbox

<apex:pageBlockSection columns="1">
<apex:pageblockTable headerClass="hideTableHeader" value="{!myProgram}" var="ProgramID" columnsWidth="30%, 22%, 12%, 12%, 12%, 12%">
<apex:column styleclass="ProgName" value="{!ProgramID.name}"/>
<apex:column styleclass="topContent" value="{!ProgramID.Electrical_System__c}"/>
<apex:column styleclass="topContent" value="{!ProgramID.Bootloader__c}"/>
<apex:column styleclass="topContent" value="{!ProgramID.Base_Program__c}"/>
<apex:column styleclass="topContent" ><apex:outputText value="{!if((myProgram.Active__c)=true, "Active", "Inactive")}"/></apex:column>
<apex:column styleclass="topContent"  value="{!myProgram.Status_Reason__c}"/>
</apex:pageblockTable>
</apex:pageBlockSection>