function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
gribisgribis 

"An internal server error has occurred" when rendered as pdf

We are trying to render build specifications based on sales order data. Various data elements need to be pulled in and related to output the necessary content. The Visual Force page leverages the standard controller for the SalesOrder custom object, and uses an extension controller to pull together all the relevant related records.

 

Problem: When this page is rendered as HTML, the page displays as expected. However, if the page is rendered as PDF, a generic error message appears:

 

An internal server error has occurred
An error has occurred while processing your request. The salesforce.com support team has been notified of the problem. If you believe you have additional information that may be of help in reproducing or correcting the error, please contact support@salesforce.com. Please indicate the URL of the page you were requesting, any error id shown on this page as well as any other related information. We apologize for the inconvenience.

Thank you again for your patience and assistance. And thanks for using Salesforce!

Error ID: 938602852-1015 (-236663650)

 

How can we get more information about the source of the issue that causes this error? Better yet, what is the cause of the problem?

 

The related code is attached below:

Main VS Page:

<apex:page standardController="kaz_salesorder__c" extensions="extSalesOrderPrint" showHeader="false" renderAs="pdf"> <html> <head> <style type="text/css" media="print"> .PB { page-break-inside: avoid; page-break-after: always; height: 100%; width: 100%; border: solid 0px #000000; } .PBAVOID, .PBAVOID div, .PBAVOID table{ page-break-inside: avoid;} body { margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font-family: Arial, Helvetica, Geneva, SunSans-Regular, sans-serif; } @page { size: portrait; } </style> <style type="text/css" media="screen,print"> body, td, span, div { font-family: Arial, Helvetica, Geneva, SunSans-Regular, sans-serif; font-size: 11px;} .OUTLINE_DARK, .OUTLINE_MEDIUM, .OUTLINE_LIGHT { border: solid 1px #000000; padding: 5px; } .OUTLINE_DARK { background-color: #CCCCCC; } .OUTLINE_MEDIUM { background-color: #EEEEEE; } .OUTLINE_LIGHT { background-color: none; } .LABEL_BOLD { font-weight: bold; font-size: 12px;} .LABEL_LARGE { font-weight: bold; font-size:16px; } .LABEL_HEADING { font-weight: bold; font-size:22px; } td.BOMChecklist, th.BOMChecklist { border-bottom: 1px solid #000000;border-right: 1px solid #000000;} table.BOMChecklist { border-top: 1px solid #000000;border-left: 1px solid #000000;} table.BOMChecklist th, th.BOMChecklist{ Background-Color: #eeeeee; font-size: 14; } table.ProductList td, table.ProductList th { border-bottom: 1px solid #000000;border-right: 1px solid #000000;} table.ProductList th { Background-color: #eeeeee; font-size: 14; text-align: right;} table.ProductList { border-top: 1px solid #000000;border-left: 1px solid #000000;} table.AvoidBorder td, table.AvoidBorder th { border-bottom: 0px solid #000000;border-right: 0px solid #000000;} </style> </head> <body> <apex:variable var="itemIndex" value="{!0}" /> <apex:outputPanel rendered="{!(HwBaseItems.size>0)}" layout="none" id="hw"> <apex:repeat value="{!HwBaseItems.items}" var="li" id="HwLineItems"> <apex:repeat value="{!li.assets}" var="ia" id="ItemAssets"> <apex:variable var="itemIndex" value="{!(itemIndex+1)}" /> <div class="PB"> <c:BuildSheetHeader so="{!kaz_salesorder__c}" /> <br /> <apex:variable var="FeatureLicensesCombined" value="{!IF(ISNULL(li.item.Product__r.Addon_Licenses__c),'',li.item.Product__r.Addon_Licenses__c)}" /> <apex:repeat value="{!ia.assets}" var="ra" id="RelatedAssets2"><apex:variable var="FeatureLicensesCombined" value="{!IF(FeatureLicensesCombined='','',FeatureLicensesCombined&' ')&IF(ISNULL(ra.itemAsset.Sales_Order_Item__r.Product__r.Addon_Licenses__c),'',ra.itemAsset.Sales_Order_Item__r.Product__r.Addon_Licenses__c)}" /></apex:repeat> <c:BuildSheetItemDetails ProductCategory="Appliance" ProductItemIndex="{!Text(itemIndex/1)}" ProductCode="{!li.item.ProductCode__c}" ItemName="{!ia.item.Name}" Release="{!kaz_salesorder__c.Release__c}" Duration="{!ia.duration}" ProductName="{!li.item.ProductName__c}" BaseLicense="{!li.item.Product__r.Base_License__c}" FeatureLicense="{!FeatureLicensesCombined}"/> <br /> <c:BillOfMaterialChecklist bom="{!li.bom}" channel="{!kaz_salesorder__c.Channel__c}" /> <apex:variable var="itemSubIndex" value="{!0}" /> <apex:repeat value="{!ia.assets}" var="ra" id="RelatedAddonAssets"> <apex:variable var="itemSubIndex" value="{!(itemSubIndex+1)}" /> <br /> <c:BuildSheetItemDetails ProductCategory="Installed Add-on Item" ProductItemIndex="{!TEXT(itemIndex/1)&'.'&TEXT(itemSubIndex/1)}" ProductCode="{!ra.itemAsset.Sales_Order_Item__r.Product__r.ProductCode}" ItemName="{!ra.item.Name}" Release="{!kaz_salesorder__c.Release__c}" Duration="{!ra.duration}" ProductName="{!ra.itemAsset.Sales_Order_Item__r.Product__r.Name}" BaseLicense="{!ra.itemAsset.Sales_Order_Item__r.Product__r.Base_License__c}" FeatureLicense="{!ra.itemAsset.Sales_Order_Item__r.Product__r.Addon_Licenses__c}"/> <br /> <c:BillOfMaterialChecklist bom="{!ra.bom}" channel="{!kaz_salesorder__c.Channel__c}" /> </apex:repeat> </div> </apex:repeat> </apex:repeat> </apex:outputPanel> <apex:outputPanel rendered="{!(SwBaseItems.size>0)}" layout="none" id="sw"> <apex:repeat value="{!SwBaseItems.items}" var="li" id="SwLineItems"> <apex:repeat value="{!li.assets}" var="ia" id="ItemAssets"> <apex:variable var="itemIndex" value="{!(itemIndex+1)}" /> <div class="PB"> <c:BuildSheetHeader so="{!kaz_salesorder__c}" /> <br /> <apex:variable var="FeatureLicensesCombined" value="{!IF(ISNULL(li.item.Product__r.Addon_Licenses__c),'',li.item.Product__r.Addon_Licenses__c)}" /> <apex:repeat value="{!ia.assets}" var="ra" id="RelatedAssets2"><apex:variable var="FeatureLicensesCombined" value="{!IF(FeatureLicensesCombined='','',FeatureLicensesCombined&' ')&IF(ISNULL(ra.itemAsset.Sales_Order_Item__r.Product__r.Addon_Licenses__c),'',ra.itemAsset.Sales_Order_Item__r.Product__r.Addon_Licenses__c)}" /></apex:repeat> <c:BuildSheetItemDetails ProductCategory="Software Only" ProductItemIndex="{!Text(itemIndex/1)}" ProductCode="{!li.item.ProductCode__c}" ItemName="{!ia.item.Name}" Release="{!kaz_salesorder__c.Release__c}" Duration="{!ia.duration}" ProductName="{!li.item.ProductName__c}" BaseLicense="{!li.item.Product__r.Base_License__c}" FeatureLicense="{!FeatureLicensesCombined}"/> <br /> <c:BillOfMaterialChecklist bom="{!li.bom}" channel="{!kaz_salesorder__c.Channel__c}" /> <apex:variable var="itemSubIndex" value="{!0}" /> <apex:repeat value="{!ia.assets}" var="ra" id="RelatedAddonAssets"> <apex:variable var="itemSubIndex" value="{!(itemSubIndex+1)}" /> <br /> <c:BuildSheetItemDetails ProductCategory="Installed Add-on Item" ProductItemIndex="{!TEXT(itemIndex/1)&'.'&TEXT(itemSubIndex/1)}" ProductCode="{!ra.itemAsset.Sales_Order_Item__r.Product__r.ProductCode}" ItemName="{!ra.item.Name}" Release="{!kaz_salesorder__c.Release__c}" Duration="{!ra.duration}" ProductName="{!ra.itemAsset.Sales_Order_Item__r.Product__r.Name}" BaseLicense="{!ra.itemAsset.Sales_Order_Item__r.Product__r.Base_License__c}" FeatureLicense="{!ra.itemAsset.Sales_Order_Item__r.Product__r.Addon_Licenses__c}"/> <br /> <c:BillOfMaterialChecklist bom="{!ra.bom}" channel="{!kaz_salesorder__c.Channel__c}" /> </apex:repeat> </div> </apex:repeat> </apex:repeat> </apex:outputPanel> <apex:outputPanel rendered="{!(AddonItems.size>0)}" layout="none" id="addon"> <apex:repeat value="{!AddonItems.items}" var="li" id="AssonLineItems"> <apex:repeat value="{!li.assets}" var="ia" id="ItemAssets"> <apex:outputPanel rendered="{!NOT(ia.HasParent)}" layout="none" id="addon"> <apex:variable var="itemIndex" value="{!(itemIndex+1)}" /> <div class="PB"> <c:BuildSheetHeader so="{!kaz_salesorder__c}" /> <br /> <apex:variable var="FeatureLicensesCombined" value="{!IF(ISNULL(li.item.Product__r.Addon_Licenses__c),'',li.item.Product__r.Addon_Licenses__c)}" /> <apex:repeat value="{!ia.assets}" var="ra" id="RelatedAssets2"><apex:variable var="FeatureLicensesCombined" value="{!IF(FeatureLicensesCombined='','',FeatureLicensesCombined&' ')&IF(ISNULL(ra.itemAsset.Sales_Order_Item__r.Product__r.Addon_Licenses__c),'',ra.itemAsset.Sales_Order_Item__r.Product__r.Addon_Licenses__c)}" /></apex:repeat> <c:BuildSheetItemDetails ProductCategory="Add-on Item" ProductItemIndex="{!Text(itemIndex/1)}" ProductCode="{!li.item.ProductCode__c}" ItemName="{!ia.item.Name}" Release="{!kaz_salesorder__c.Release__c}" Duration="{!ia.duration}" ProductName="{!li.item.ProductName__c}" BaseLicense="{!li.item.Product__r.Base_License__c}" FeatureLicense="{!FeatureLicensesCombined}"/> <br /> <c:BillOfMaterialChecklist bom="{!li.bom}" channel="{!kaz_salesorder__c.Channel__c}" /> <apex:variable var="itemSubIndex" value="{!0}" /> <apex:repeat value="{!ia.assets}" var="ra" id="RelatedAddonAssets"> <apex:variable var="itemSubIndex" value="{!(itemSubIndex+1)}" /> <br /> <c:BuildSheetItemDetails ProductCategory="Installed Add-on Item" ProductItemIndex="{!TEXT(itemIndex/1)&'.'&TEXT(itemSubIndex/1)}" ProductCode="{!ra.itemAsset.Sales_Order_Item__r.Product__r.ProductCode}" ItemName="{!ra.item.Name}" Release="{!kaz_salesorder__c.Release__c}" Duration="{!ra.duration}" ProductName="{!ra.itemAsset.Sales_Order_Item__r.Product__r.Name}" BaseLicense="{!ra.itemAsset.Sales_Order_Item__r.Product__r.Base_License__c}" FeatureLicense="{!ra.itemAsset.Sales_Order_Item__r.Product__r.Addon_Licenses__c}"/> <br /> <c:BillOfMaterialChecklist bom="{!ra.bom}" channel="{!kaz_salesorder__c.Channel__c}" /> </apex:repeat> </div> </apex:outputPanel> </apex:repeat> </apex:repeat> </apex:outputPanel> </body> </html> </apex:page>

BuildSheetHeader code:

 

<apex:component > <apex:attribute name="so" description="Items reflects the Sales Order object" type="kaz_salesorder__c" required="true"/> <div class="OUTLINE_DARK"> <table width="100%"> <tr> <td width="0%"><img src="{!$Resource.TrainingCertificate}/kazeon_logo_hd.png" height="20px"/></td> <td width="60%" align="center"><span class="LABEL_HEADING">BUILD ORDER</span></td> <td width="20%"> <span class="LABEL_BOLD">Kazeon SO</span><br /><apex:outputText value="{!so.Name}" /> </td> <td width="20%"> <span class="LABEL_BOLD">Date</span><br /><apex:outputText value="{!TEXT(MONTH(TODAY()))&'/'&TEXT(DAY(TODAY()))&'/'&TEXT(YEAR(TODAY()))}" /> </td> </tr> </table> </div> <div class="OUTLINE_LIGHT"> <table cellpadding="2" cellspacing="0" border="0" width="100%"> <tr> <td valign="top"> <table cellpadding="4" cellspacing="0" border="0" width="100%"> <tr> <td align="right"><span class="LABEL_BOLD">Customer: </span></td> <td><apex:outputText styleClass="" value="{!so.Account__r.Name}" /></td> </tr> <tr> <td align="right"><span class="LABEL_BOLD">PO: </span></td> <td><apex:outputText value="{!so.PurchaseOrderNumber__c}" /></td> <tr> <apex:outputPanel rendered="{!NOT(ISNULL(so.Partner_Sales_Order__c))}" layout="none"> <tr> <td align="right"><span class="LABEL_BOLD">Partner SO: </span></td> <td><apex:outputText value="{!so.Partner_Sales_Order__c}" /></td> </tr> </apex:outputPanel> </table> </td> <td> <table cellpadding="4" cellspacing="0" border="0" width="100%"> <tr> <td valign="top" align="right"><span class="LABEL_BOLD">Shipping Address:</span></td> <td> <pre><apex:outputPanel rendered="{!NOT(ISNULL(so.ShippingStreet__c))}" layout="none"><apex:outputText value="{!so.ShippingStreet__c}" /><br /></apex:outputPanel> <apex:outputPanel rendered="{!NOT(ISNULL(so.ShippingCity__c))}" layout="none"><apex:outputText value="{!so.ShippingCity__c}" />,&nbsp;</apex:outputPanel> <apex:outputPanel rendered="{!NOT(ISNULL(so.ShippingState__c))}" layout="none"><apex:outputText value="{!so.ShippingState__c}" />&nbsp;</apex:outputPanel> <apex:outputPanel rendered="{!NOT(ISNULL(so.ShippingPostalCode__c))}" layout="none"><apex:outputText value="{!so.ShippingPostalCode__c}" /></apex:outputPanel> <apex:outputPanel rendered="{!NOT(ISNULL(so.ShippingCountry__c))}" layout="none"><br />(<apex:outputText value="{!so.ShippingCountry__c}" />)</apex:outputPanel></pre> </td> </tr> </table> </td> </tr> </table> </div> </apex:component>

 

Best Answer chosen by Admin (Salesforce Developers) 
Alexy1967Alexy1967

Issue was being caused by the page trying to access an object that had not yet been deployed...hence the reason why I as the Administrator could render the page as PDF with no problems but my user (who was on another Profile) could not.

 

 

All Answers

gribisgribis

BuilSheetItemDetails:

<apex:component > <apex:attribute name="ProductCategory" description="High-level product type" type="String" required="false"/> <apex:attribute name="ProductItemIndex" description="Item index on page" type="String" required="false"/> <apex:attribute name="ProductCode" description="Product Code value" type="String" required="false"/> <apex:attribute name="ItemName" description="Name of Asset" type="String" required="true"/> <apex:attribute name="Release" description="Requested release" type="String" required="false"/> <apex:attribute name="Duration" description="Duration of Licenes" type="Integer" required="false"/> <apex:attribute name="ProductName" description="Name of Product" type="String" required="true"/> <apex:attribute name="BaseLicense" description="Type of Base Liencese" type="String" required="false"/> <apex:attribute name="FeatureLicense" description="Add on module licenses" type="String" required="false"/> <div class="PBAVOID"> <table class="ProductList" cellpadding="2" cellspacing="0" border="0" width="100%"> <apex:outputPanel rendered="{!NOT(ISNULL(ProductCategory))}" layout="none"> <tr><td colspan="2" class="OUTLINE_DARK"> <table class="AvoidBorder" width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td width="80%"> <span class="LABEL_LARGE"><apex:outputText value="{!ProductCategory}"/></span></td> <td width="20%" align="right"><span class="LABEL_BOLD">Item {!ProductItemIndex}</span></td> </tr></table> </td></tr> </apex:outputPanel> <tr> <th width="30%">Part Number</th> <td width="90%"><apex:outputText value="{!ProductCode}" />&nbsp;</td> </tr><tr> <th>NickName/Serial Number</th> <td><apex:outputText value="{!ItemName}" />&nbsp;</td> </tr><tr> <th>Software Version</th> <td><apex:outputText value="{!Release}" />&nbsp;</td> </tr><tr> <th>License Duration</th> <td><apex:outputText value="{!Duration}" />&nbsp;</td> </tr><tr> <th>Product Name</th> <td><apex:outputText value="{!ProductName}" />&nbsp;</td> </tr><tr> <th>Model</th> <td><apex:outputText value="{!BaseLicense}" />&nbsp;</td> </tr><tr> <th>Features/Advanced Modules</th> <td><apex:outputText value="{!FeatureLicense}" />&nbsp;</td> </tr> </table> </div> </apex:component>

 

Extension Controller:

public class extSalesOrderPrint { /////////////////////////////////////// // Initialize the SalesOrder product // /////////////////////////////////////// public extSalesOrderPrint(ApexPages.StandardController controller) { kaz_salesorder__c tmpSO = (kaz_salesorder__c)controller.getRecord(); if (tmpSO == null) return; if (tmpSO.Id == null) return; this.theSalesOrder = [select id, Total_Items__c, Total_Returned__c, Total_Shipped__c, Status__c, Required_Ship_Date__c, Expected_Delivery_Date__c, PurchaseOrderNumber__c, name, Account__c, RecordType.DeveloperName, Price_Book__c from kaz_salesorder__c where id=:tmpSO.Id]; // Read drop URL param, set remove attribute } public kaz_salesorder__c theSalesOrder {get;set;} public static final String LINE_ITEMS_TYPE_WITH_HW = 'Assets With Hardware'; public static final String LINE_ITEMS_TYPE_WITH_ADDON = 'Addon SW'; public static final String LINE_ITEMS_TYPE_WITH_SW = 'Base SW'; public static final integer MAXIMUM_ASSET_RELATION_DEPTH = 2; // MAP of all SO related Assets // public Map<id, kaz_salesorder_item_asset__c> SoAssetMap{ get{ if(SoAssetMap==null) { //List<id> AssetIdList = new List<id>{}; //for(kaz_salesorder_item_asset__c theIA: [select Asset__c from kaz_salesorder_item_asset__c where Sales_Order_Item__r.SalesOrder__c =:this.theSalesOrder.id]) // AssetIdList.add(theIA.Asset__c); this.SoAssetMap = new Map<id, kaz_salesorder_item_asset__c>{}; for (kaz_salesorder_item_asset__c theItemAsset: [select id, Asset__r.id, Asset__r.Name, Asset__r.Parent_Asset__c, Asset__r.SerialNumber, Sales_Order_Item__c, Sales_Order_Item__r.Product__r.Build_Of_Material__c, Sales_Order_Item__r.Product__r.Base_License__c, Sales_Order_Item__r.Product__r.Addon_Licenses__c, Sales_Order_Item__r.Product__r.ProductCode, Sales_Order_Item__r.Product__r.Name, Sales_Order_Item__r.Product__c, Sales_Order_Item__r.Term__c, Sales_Order_Item__r.License_Duration__c, Sales_Order_Item__r.SalesOrder__r.Expected_Delivery_Date__c from kaz_salesorder_item_asset__c where Sales_Order_Item__r.SalesOrder__c =:this.theSalesOrder.id and Asset__c!=null ]){ this.SoAssetMap.put(theItemAsset.Asset__c, theItemAsset); // Add asset to parent relationship map if applicable if (theItemAsset.Asset__r.Parent_Asset__c!=null) { if (!SoAssetParentChildMap.containsKey(theItemAsset.Asset__r.Parent_Asset__c))SoAssetParentChildMap.put(theItemAsset.Asset__r.Parent_Asset__c, new List<id>{theItemAsset.Asset__r.id}); else SoAssetParentChildMap.get(theItemAsset.Asset__r.Parent_Asset__c).add(theItemAsset.Asset__r.id); } } } return SoAssetMap; } set; } public Map <id, kaz_bom__c> SoBomMap { get { if(this.SoBomMap==null) { List<id> BomIdList = new List<id>{}; for (kaz_salesorder_item_asset__c theItemAsset: SoAssetMap.values()) { BomIdList.add(theItemAsset.Sales_Order_Item__r.Product__r.Build_Of_Material__c); } this.SoBomMap = new Map<id, kaz_bom__c>( [select Name, Maximum_Sequence__c, Description__c, Active__c, ( select Name, Part_Number__c, Description__c, Refrence__c, Only_for_Channel__c from BOM_Parts__r order by Sequence__c) from kaz_bom__c where id in:BomIdList ] ); } return this.SoBomMap; } private set; } ////////////////////////////////////////////////////////////////// // MAP for parent-child relationship between assets within SO // public Map<id, List<id>> SoAssetParentChildMap { get { if (SoAssetParentChildMap==null) this.SoAssetParentChildMap = new Map<id, List<id>>{}; return this.SoAssetParentChildMap; } private set; } ///////////////////////////////// // Hardware Based BASE Items // public LineItems HwBaseItems { get{ if(HwBaseItems==null) HwBaseItems=new LineItems(extSalesOrderPrint.LINE_ITEMS_TYPE_WITH_HW, this.theSalesOrder, this.SoAssetMap,this.SoAssetParentChildMap, this.SoBomMap); return HwBaseItems; } private set; } ///////////////////////////////// // Software Based BASE Items // public LineItems SwBaseItems { get{ if(SwBaseItems==null) SwBaseItems=new LineItems(extSalesOrderPrint.LINE_ITEMS_TYPE_WITH_SW, this.theSalesOrder, this.SoAssetMap,this.SoAssetParentChildMap, this.SoBomMap); return SwBaseItems; } private set; } ///////////////////////////////// // Addon Items // public LineItems AddonItems { get{ if(AddonItems==null) AddonItems=new LineItems(extSalesOrderPrint.LINE_ITEMS_TYPE_WITH_ADDON, this.theSalesOrder, this.SoAssetMap,this.SoAssetParentChildMap, this.SoBomMap); return AddonItems; } private set; } /////////////////////////////////////////// // S T A T I C M E T H O D S /////////////////////////////////////////// // s t a r t /////////////////////////////////////////// public static integer LicenseDuration(Date pExpectedStartDate, double addTermInMonths, double addDays) { Date lExpirationDate; if (pExpectedStartDate==null) pExpectedStartDate=System.today(); if(addTermInMonths!=null) lExpirationDate = pExpectedStartDate.addMonths(addTermInMonths.intValue()); else if (addDays!=null) lExpirationDate = pExpectedStartDate.addDays(addDays.intValue()); //system.debug('Start Date: '+pExpectedStartDate); //system.debug('Expiration Date: '+lExpirationDate); //system.debug('Duration: '+((lExpirationDate!=null) ? pExpectedStartDate.daysBetween(lExpirationDate).format():'n/a')); return (lExpirationDate!=null)?pExpectedStartDate.daysBetween(lExpirationDate):null; } ///////////////////////////////////// // C L A S S E S D E F ///////////////////////////////////// // s t a r t ///////////////////////////////////// public class LineItems { public List<LineItem> items {get{if(this.items==null)this.items=new List<lineItem>{};return this.items;}set;} public integer size { get { if(this.size==null) { this.size=(this.items==null?0:this.items.size()); System.debug('Updated size: '+this.size.format()); } System.debug('Returning size: '+this.size.format()); return this.size; } private set; } public LineItems(String pType, kaz_salesorder__c pSalesOrder, Map<id, kaz_salesorder_item_asset__c> pAssetCollection, Map<id,List<id>> pAssetParentChildMap, Map <id, kaz_bom__c> pSoBomMap){ // Select all line items that include a hardware asset and are base products if(pType==extSalesOrderPrint.LINE_ITEMS_TYPE_WITH_HW) { for(kaz_salesorder_item__c theSoItem: [Select Term__c, SalesOrder__c, ProductName__c, ProductCode__c, Product__r.Includes_Tangible_Component__c, Product__r.Base_License__c, Product__r.Addon_Licenses__c, Product__r.Build_Of_Material__c, PO_Line_Number__c, (Select id, Asset__c From Item_Assets__r) from kaz_salesorder_item__c where Product__r.Has_Hardware_Asset__c=true and Product__r.Allow_Addon_Products__c=1 and SalesOrder__c=:pSalesOrder.id order by PO_Line_Number__c]) { this.items.add(new LineItem(theSoItem,pAssetCollection,pAssetParentChildMap, pSoBomMap)); } // Select all line items that do NOT include a hardware asset and are base products } else if(pType==extSalesOrderPrint.LINE_ITEMS_TYPE_WITH_SW) { for(kaz_salesorder_item__c theSoItem: [Select Term__c, SalesOrder__c, ProductName__c, ProductCode__c, Product__r.Includes_Tangible_Component__c, Product__r.Base_License__c, Product__r.Addon_Licenses__c, Product__r.Build_Of_Material__c, PO_Line_Number__c, (Select id, Asset__c From Item_Assets__r) from kaz_salesorder_item__c where Product__r.Has_Hardware_Asset__c!=true and Product__r.Allow_Addon_Products__c=1 and SalesOrder__c=:pSalesOrder.id order by PO_Line_Number__c]) { this.items.add(new LineItem(theSoItem,pAssetCollection,pAssetParentChildMap, pSoBomMap)); System.debug(theSoItem.ProductCode__c); } // Select all line items that are not base products } else if(pType==extSalesOrderPrint.LINE_ITEMS_TYPE_WITH_ADDON) { for(kaz_salesorder_item__c theSoItem: [Select Term__c, SalesOrder__c, ProductName__c, ProductCode__c, Product__r.Includes_Tangible_Component__c, Product__r.Base_License__c, Product__r.Addon_Licenses__c, Product__r.Build_Of_Material__c, PO_Line_Number__c, (Select id, Asset__c From Item_Assets__r) from kaz_salesorder_item__c where Product__r.Has_Software_License__c=true and Product__r.Allow_Addon_Products__c!=1 and SalesOrder__c=:pSalesOrder.id order by PO_Line_Number__c]) { this.items.add(new LineItem(theSoItem,pAssetCollection,pAssetParentChildMap, pSoBomMap)); } } } } public class LineItem { public kaz_salesorder_item__c item {get;set;} public kaz_bom__c bom {get;set;} public integer size { get {if(this.size==null)this.size=(this.assets==null?0:this.assets.size());return this.size;}private set;} public List<LineItemAsset> assets {get{if(this.assets==null)this.assets=new List<LineItemAsset>{}; return this.assets;}private set;} public LineItem(kaz_salesorder_item__c pLineItem,Map<id, kaz_salesorder_item_asset__c> pAssetCollection, Map<id,List<id>> pAssetParentChildMap, Map <id, kaz_bom__c> pSoBomMap) { this.item = pLineItem; this.bom = pSoBomMap.containsKey(pLineItem.Product__r.Build_Of_Material__c)? pSoBomMap.get(pLineItem.Product__r.Build_Of_Material__c) : null ; // Load the related Assets for(kaz_salesorder_item_asset__c theIA: this.item.Item_Assets__r) { // Add LineItemAsset object if (pAssetCollection.containsKey(theIA.Asset__c)) { this.assets.add(new LineItemAsset(pAssetCollection.get(theIA.Asset__c), pAssetCollection, pAssetParentChildMap, 0, pSoBomMap)); } } } } public class LineItemAsset { public Asset item {get;set;} public kaz_bom__c bom {get;set;} private boolean durationSet = false; public kaz_salesorder_item_asset__c itemasset {get;set;} public boolean HasParent { get { return this.HasParent; } private set; } public integer duration{ get { if (duration==null) { durationSet = true; this.duration = extSalesOrderPrint.LicenseDuration( this.itemasset.Sales_Order_Item__r.SalesOrder__r.Expected_Delivery_Date__c, this.itemasset.Sales_Order_Item__r.Term__c, this.itemasset.Sales_Order_Item__r.License_Duration__c ); } return this.duration; } private set; } public integer size { get {if(this.size==null)this.size=(this.assets==null?0:this.assets.size());return this.size;}private set;} public List<LineItemAsset> assets {get{if(this.assets==null)this.assets=new List<LineItemAsset>{}; return this.assets;}private set;} public LineItemAsset (kaz_salesorder_item_asset__c pItemAsset,Map<id, kaz_salesorder_item_asset__c> pAssetCollection, Map<id,List<id>> pAssetParentChildMap, integer pDepth, Map <id, kaz_bom__c> pSoBomMap) { this.itemasset = pItemAsset; this.item = this.itemasset.Asset__r; this.bom = pSoBomMap.containsKey(pItemAsset.Sales_Order_Item__r.Product__r.Build_Of_Material__c) ? pSoBomMap.get(pItemAsset.Sales_Order_Item__r.Product__r.Build_Of_Material__c) : null; // Load child asset records if (this.item!=null) { if(pAssetParentChildMap.containsKey(this.item.id) && pDepth <= extSalesOrderPrint.MAXIMUM_ASSET_RELATION_DEPTH){ for(id theAssetId: pAssetParentChildMap.get(this.item.id)) { if(pAssetCollection.containsKey(theAssetId)) { this.assets.add(new LineItemAsset(pAssetCollection.get(theAssetId), pAssetCollection, pAssetParentChildMap, pDepth+1, pSoBomMap)); } } } // Set has parent flag this.HasParent = pAssetParentChildMap.containsKey(this.item.Parent_Asset__c); } else { this.HasParent = false; } } } ///////////////////////////////////// // C L A S S E S D E F ///////////////////////////////////// // e n d ///////////////////////////////////// }

prageethprageeth

I know its too late to reply for this question.

But I have seen a lot of similar questions which are related to the PDF rendering and "Internal Server Error". 

So I write this to be helpful for a future user.

 

The main reason for this kind of errors is the Bad format of the page markup. If you put something which can't be rendered, this error is generated.

 

For an example following simple markup gives an Internal Server Error.

 

<apex:page Controller="A" renderAs="pdf">

<div style="position:absolute;top:-50px;"/> 

</apex:page>

 

The reason is the 'top' value is negative.

This page can't be rendered in to pdf.

If you tried to render this as HTML it will rendered because the browser handles the situation.

Or try changing the 'top' value to a positive value, now it will work.

(I am not saying that top value can't be negative. But in this case if the top value is negative there is no place to put the div

 

In order to find the location of the error easily, remove the parts of the VF page markup one by one (Part by part) and re try to generae the page.

Then you will be able to find the part of the markup which causes this error.

Message Edited by prageeth on 09-29-2009 09:44 PM
Alexy1967Alexy1967

I have a very basic VF page with a standard controller and no extensions (i.e no APEX).

 

Everything works fine but when another user in the same role and with the same (administrator) profile as myself tries to render the page as PDF they are getting  the "internal server error".

 

I can understand if the page won't render due to badly formatted HTML (my HTML skills leave a lot to be desired). What I don't understand is why it works for one user but not another? Is it a browser compatibility issue. I am running IE8... not sure what my user is running... probably IE6.

 

Any assistance would be most appreciated.

 

 

Alexy1967Alexy1967

Issue was being caused by the page trying to access an object that had not yet been deployed...hence the reason why I as the Administrator could render the page as PDF with no problems but my user (who was on another Profile) could not.

 

 

This was selected as the best answer