0

I am trying to create a printable packing slip via visualforce page in a button on the case object.

I've created the button and everything seems to be working fine UNTIL I try to reference fields on the account. Is there a way to reference the related account (lookup on the case) fields, such as shipping address?

Can this be done with ONLY using the standard controller? Because I know next-to-nothing about controllers, controller extensions, etc. and the documentation might as well be a foreign language... (I'm a visualforce noob...)

Here is my visualforce page...

<apex:page showheader="false" sidebar="false" standardController="Case">
<apex:variable value="{!Case}" var="c" />
<script>      
    window.onload = function() { 
        window.print();
    }
</script>
<style>
    @media print{
        h1{
            font-size:x-large;
        }
        p{
            font-size: medium;
        }
        table{
            font-size: medium;
        }
    }
</style><br /><br />
    <p>
    <apex:outputField value="{!c.Account.Name}"/><br />
    <apex:outputField value="{!c.Account.ShippingAddress}"/><br />
    Item(s) shipped on <apex:outputField value="{!c.Shipped_On__c}"/><br />
    </p>
</apex:page>

Thanks!

  • did you try eliminating the apex:variable and using merge fields {!Case.account.name} etc. ? – cropredy Nov 10 '15 at 21:04
  • I have not tried eliminating the variable, but the Account.Name is populating fine. It's the additional fields, specifically Account.Shipping address that I'm having trouble with... – BeckBeck Nov 11 '15 at 21:26
  • this is addressed here: stackoverflow.com/questions/19559475/… – cropredy Nov 11 '15 at 21:32
  • Thank you! Embarrassed I didn't think to do that on my own. Again, thanks! – BeckBeck Nov 19 '15 at 16:43
0

The problem you seem to be having is that the field Account.ShippingAddress won't render on the VF page because it is a compound field

Instead, reference the individual fields

{!Account.ShippingAddress}
{!Account.ShippingCity}
{!Account.ShippingState}
etc.
0

Standard controller do not bring data from related records directly. So, the best way will be to use controller extensions to pull account details and display on VF Page.

However, as you stated you don't want to go via Apex route, then the alternative (not highly recommended) I can think of is to create custom fields on case to store account field information and create workflow/ lightning process to populate these fields. So, on creation/ updation of case, it can pull data from account fields. Once the case fields are populated, you can very well use them to display data within visualforce page

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.