Showing posts with label Visuaflroce. Show all posts
Showing posts with label Visuaflroce. Show all posts

Tuesday, July 8, 2014

How to Use Salesforce Static Resource as a Dynamically?

How to Use Salesforce Static Resource as a Dynamically

Let’s suppose we have an archive in static resource with name "Contact" and you want to use this static resource on a page that displays Contact Photos dynamically. Assumption is that the images are stored with same name as product codes.
Code:

//Declare an apex variable which gets the Contact code from an apex property

<img alt="" src="{!URLFOR($Resource.Products,contact_photo)}')" />




Friday, April 18, 2014

How to Generate MS-Word document using VF pages?

How to Generate MS-Word document using VF pages?



I have a VF which renders as MS-Word. for this you need to mention content type in <apex:page> tag. 

EX:-

<apex:page standardController="Account"  contentType="application/msword#sfdcsrini.doc" cache="true">

<html xmlns:w="urn:schemas-microsoft-com:office:word">

<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<body>
<apex:outputText title="Welcome to word" value="{!$User.FirstName}"/>
<br/>
<br/>
<apex:pageBlock >
<div style="text-align:left" >
<b>Account Name :</b><apex:outputText value="{!account.name}"/><br/>
<b>Account Number: </b><apex:outputText value="{!account.AccountNumber}"/><br/>
</div>            
</apex:pageBlock>
</body>
</html>


</apex:page>


once you save this code in to your vf page you need to pass the account id in to url like

https://c.ap1.visual.force.com/apex/worddocvf?id=0019000000RMAaF


 here contentType="application/msword#sfdcsrini.doc" tells that page should render as ms-word document.(sfdcsrini) is the name of the document in content type, you can give your own name. 




 
| ,