• cpebre3
  • NEWBIE
  • 25 Points
  • Member since 2009

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

Hey everyone. I have a page that we were rendering as a pdf. It was decided by the powers above that we wanted this as a Word document instead. I was hoping that I could easily make the switch by changing renderas="pdf" into contentType= "application/msword"  For grins, I also used .vnd.ms-excel and got the same red x.

 

For the most part this has worked. But I have one issue with an apex image on my page. It's calling a static resource (gif) which renders fine with a PDF or html - but shows up as a nice red X on the MS word. Anyone know how I can fix this? Is there a trick to using static resources for pages rendering as MS word  / excel that's different from PDF or HTML?

 

Page Code:

<apex:page standardcontroller="Opportunity" showheader="false" contentType="application/msword"> <!-- bunch of other stuff --> <apex:image url="{!$Resource.p1source_lrg_logo}" / > <!-- More bunches fo other stuff --> </page>

 

I don't change the apex image code at all between the renderas PDF, HTMl or setting the contenttype

A new problem has suddenly appeared this week in our sandboxes. When I update an OpportunityLineItem, my "before update" trigger sees a null value in the PricebookEntryId field. But this is an update to an existing OpportunityLineItem, so it should have an associated PricebookEntry. When I extract the record in the data loader, it does in fact have a PricebookEntryId. This worked flawlessly last week. Our sandboxes run on CS17, and I can see that Winter 15 is released this weekend, so I guess it is related to that release. It seems like a bug in the platform. Does anybody know of a workaround? We are in the finishing phase of a large project, and our UAT testing is heavily impacted by this, since users are no longer able to make any updates to existing OpportunityLineItems.

I'm pretty sure I'm just trying to do some straightforward AJAX here.  When I use oncomplete or reRender widhin actionFunction, I see the following Javascript error (via Firebug):

 

element.selectNodes is not a function

 

And the Javascript engine basically choke at this point.   The error happens within the Salesforce AJAX library: 

3_3_0.GAorg.ajax4jsf.javascript.AjaxScript on line 101.  This occurs at a point where the code does a try{selectNodes()} to figure out of it should run either selectNodes() or getElementsByTagName().  If the try{} fails, the catch(){} should run the getElementsByTagName().

 

I've seen this in FF3.5.6, though things seem to work fine in FF3.0.16.   In IE7 and IE8 I get data back inconsistently.  Generally if I put trash data in yahooProduct and then try good data, I will things will work fine.  However, until I do this special sequence, the AJAX will not work in IE.  I know, this part this sounds like a bug of my own making... probably is... but for the life of me I cannot pin point it.  The code isn't all that complicated.

 

If I take out oncomplete and reRender, I get no Javascript errors.  Of course, I have no way to see if the AJAX did anything, either.

 

Strangely, I can find no references to this issue on the discussion boards.  I'm not doing anything particularly fancy.  Anything stand out in my code below?

 

 

My Visualforce:

 

 

<apex:page standardController="Purchase__c" extensions="PurchaseExtension" recordSetVar="purchases" title="New Purchase">

<apex:sectionHeader title="Purchase Edit" subtitle="New Purchase"/>

<apex:messages layout="table"/>

<style>
td.labelCol {
vertical-align: middle;
}
</style>
<apex:form styleclass="p-form" id="p_form">

<apex:pageBlock title="Purchase Edit" mode="edit">

<apex:actionFunction name="updateProductDetails" action="{!updateProductDetails}" immediate="true" reRender="field_table">
<apex:param name="firstParam" assignTo="{!yahooProduct}" value="" />
</apex:actionFunction>

<apex:outputPanel id="field_table">
<table cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr>
<td class="labelCol requiredInput">Contact</td>
<td class="dataCol col02" style="height:20px;">
<apex:inputField value="{!p.Contact__c}" required="true"/>
</td>
</tr>
<tr>
<td class="labelCol requiredInput">Purchase Date</td>
<td class="dataCol col02">
<apex:inputField value="{!p.Purchase_Date__c}" required="true"/>
</td>
</tr>
<tr>
<td class="labelCol requiredInput">Yahoo! Product</td>
<td class="dataCol col02">
<apex:inputField value="{!p.Yahoo_Product__c}" required="true" onchange="updateProductDetails(this.value)" />
</td>
</tr>
<tr>
<td class="labelCol requiredInput">Item Description</td>
<td class="dataCol col02">
<input disabled="true" id="item-desc" type="text" value="{!productDesc}"/>
</td>
</tr>
<tr>
<td class="labelCol requiredInput">Item Price</td>
<td class="dataCol col02">
<input disabled="true" id="item-price" type="text" value="{!productPrice}"/>
</td>
</tr>
<tr>
<td class="labelCol requiredInput">Quantity</td>
<td class="dataCol col02">
<apex:inputField value="{!p.Quantity__c}"/>
</td>
</tr>
<tr>
<td class="labelCol requiredInput">Total</td>
<td class="dataCol col02">
<input id="total" type="text"/>
</td>
</tr>
<tr>
<td class="labelCol requiredInput">Ship Date</td>
<td class="dataCol col02">
<apex:inputField value="{!p.Ship_Date__c}" />
</td>
</tr>
</tbody>
</table>
</apex:outputPanel>

<apex:inputHidden value="{!p.Name}"/>
<apex:inputHidden value="{!p.Contact__c}"/>

<apex:commandButton value="Save" action="{!save}"/>
<apex:commandButton value="Cancel" action="{!cancel}"/>

</apex:pageBlock>

</apex:form>

</apex:page>

 

 

 

 and my Extension:

 

 

public class PurchaseExtension {
public Purchase__c p {
get {
if (p == null)
p = new Purchase__c();
return p;
}
set;
}

public Contact c {
get {
String contactId = Apexpages.currentPage().getParameters().get('id');
if (c == null) {
c = [select c.FirstName,c.LastName from Contact c where c.id = :contactId];
}
return c;
}
set;
}


String productDesc, productPrice;
public String getProductDesc() {
return productDesc;
}
public String getProductPrice() {
return productPrice;
}

String yahooProduct = 'init';
public void setYahooProduct(String p) {
yahooProduct = p;
}
public String getYahooProduct() {
return yahooProduct;
}

public PageReference updateProductDetails() {
if (yahooProduct != null) {
List<Yahoo_Products__c> yp = [select p.Item_Description__c,p.Price__c from Yahoo_Products__c p where p.Name = :yahooProduct];
if (yp.size() > 0) {
productDesc = yp[0].Item_Description__c;
productPrice = ''+yp[0].Price__c;
} else {
productDesc = 'No product details avalable';
productPrice = 'No product details avalable';
}
} else {
productDesc = 'No product?';
productPrice = 'No product?';
}
return null;
}

public PurchaseExtension(ApexPages.StandardSetController ctlr) {
p.Contact__c = c.Id;
p.Purchase_Date__c = Date.today();
}

public PageReference save() {
PageReference pr = null;
// stub
return pr;
}

public PageReference cancel() {
// stub
return null;
}

public static testMethod void testSave() {
Test.setCurrentPage(new PageReference('/?id=003A0000004JoTl'));
List<Purchase__c> pList = new List<Purchase__c>();
ApexPages.StandardSetController ctlr = new ApexPages.StandardSetController(pList);
PurchaseExtension e = new PurchaseExtension(ctlr);
e.c = new Contact(FirstName = 'Foo', LastName = 'Bar');
e.p.Yahoo_Product__c = 'a04A000000101DT';
e.save();
System.assertNotEquals(e, null);
}

public static testMethod void testUpdateProduct() {
Test.setCurrentPage(new PageReference('/?id=003A0000004JoTl'));
List<Purchase__c> pList = new List<Purchase__c>();
ApexPages.StandardSetController ctlr = new ApexPages.StandardSetController(pList);
PurchaseExtension e = new PurchaseExtension(ctlr);
e.setYahooProduct('HistProd');
e.updateProductDetails();
String newDesc = e.getProductDesc();
System.assertNotEquals(newDesc, null);
}
}

 

 

 

 

Message Edited by JasonGabler on 01-05-2010 11:13 AM
Message Edited by JasonGabler on 01-05-2010 02:37 PM

Hey everyone. I have a page that we were rendering as a pdf. It was decided by the powers above that we wanted this as a Word document instead. I was hoping that I could easily make the switch by changing renderas="pdf" into contentType= "application/msword"  For grins, I also used .vnd.ms-excel and got the same red x.

 

For the most part this has worked. But I have one issue with an apex image on my page. It's calling a static resource (gif) which renders fine with a PDF or html - but shows up as a nice red X on the MS word. Anyone know how I can fix this? Is there a trick to using static resources for pages rendering as MS word  / excel that's different from PDF or HTML?

 

Page Code:

<apex:page standardcontroller="Opportunity" showheader="false" contentType="application/msword"> <!-- bunch of other stuff --> <apex:image url="{!$Resource.p1source_lrg_logo}" / > <!-- More bunches fo other stuff --> </page>

 

I don't change the apex image code at all between the renderas PDF, HTMl or setting the contenttype