• vpm
  • NEWBIE
  • 0 Points
  • Member since 2013

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

Hi,

 I want to display an image from attached file on vf page.

 

//vf

<apex:page standardController="stdCust_obj__c" extensions="displayImageExtension">
<table><tr>
<td><h1>Photo:</h1></td>
<td>
<apex:image url="/servlet/servlet.FileDownload?file=file.Id"/>
</td>
</tr>
</table>
</apex:page>

 

//apex

 

public class displayImageExtension {

private id StCustId;
List<Attachment> file;

 

public displayImageExtension(ApexPages.StandardController stdController) {
this.StCustId = ApexPages.currentPage().getParameters().get('id');
}

public List<Attachment> getfile(){

file=[Select Id,Name,LastModifiedDate from attachment where ParentId=:StCustId];
return file; 
}

 

}

 

Thanks in advance.

  • July 20, 2013
  • Like
  • 0

Hi,

 

I have a custom object which has lookup relationship with account. For attachment info, ParentId is required. How can I get parentId?

 

http://blog.jeffdouglas.com/2010/04/28/uploading-an-attachment-using-visualforce-and-a-custom-controller/

 

I tried the above link. I got errors like,

 

  • Required fields are missing: [Parent]
  • Error uploading attachment

 

Please suggest me to rectify my error.

  • July 16, 2013
  • Like
  • 0

Hi,

       

Here i attached my Update trigger and test class method. Test class method fails.Please help me where i went wrong.

    

////Trigger    

trigger updateContactOpportunity on Account (before update) {
 
 Set<Id> ids=new Set<Id>();
 for(Account a:Trigger.new){
 ids.add(a.id);
 }
 List<Contact> con=[Select id, accountId, phone from Contact where accountId in:ids];
 
 List<Opportunity> opp= [Select id, AccountId, Custom_Opportunity_Number__c from Opportunity where accountId in:ids];
 for(Account a:Trigger.new){
 
 for(integer j=0;j<con.size();j++){
 if(a.id==con[j].accountId){
  con[j].phone=a.phone;
 }
 }
 for(integer i=0; i<opp.size();i++){
 
  if(a.id==opp[i].accountid){
       
   opp[i].Custom_Opportunity_Number__c=a.Custom_Account_Number__c;
   
  }
 }
 }
 update con;
 update opp;

}

 

////TestClass

@isTest
private class testupdateConOpp{
 
  static testMethod void testUpdate(){
  Account a=new Account(name='test',phone='2234',Custom_Account_Number__c='6537');
   insert a;
   Contact c= new Contact(lastName='test', accountId='test.id',phone='2234');
   insert c;
   Opportunity o=new Opportunity(accountId='a.id', Custom_Opportunity_Number__c='6537');
   insert o;
   
   a.phone='111';
   a.Custom_Account_Number__c='222';
   update a;
   
   Contact updatedContact=[Select accountid, phone from Contact where id =:a.id ];
   
   system.assertEquals(updatedContact.phone,'111');
   
   Opportunity updatedOpp=[Select accountId,Custom_Opportunity_Number__c from opportunity where id=:a.id];
   
   system.assertEquals(updatedOpp.Custom_Opportunity_Number__c,'222');
   
}
}

  • July 13, 2013
  • Like
  • 0

When an opportunity is created as Stage Name = =’Closed Won ‘ create an opportunity of this opportunity whose Name will be as  "Cloned+Name of new Opportunity".

As well as Associated Account will be same as new opportunity

 

Thanks in advance

  • July 10, 2013
  • Like
  • 0

If user click on upload button to attach any image, it will open page like standard attach file. 

 

 

 

  • July 10, 2013
  • Like
  • 0

In visualforce developer guide Page no :19

 

<apex:page standardController="Account">
Hello {!$User.FirstName}!
<p>You are viewing the {!account.name} account.</p>
</apex:page>

  • July 09, 2013
  • Like
  • 0

Hi,

 

how to retrieve parent object field from attachment query..

 

Thanks,

Lakshmi

Hi,

 I want to display an image from attached file on vf page.

 

//vf

<apex:page standardController="stdCust_obj__c" extensions="displayImageExtension">
<table><tr>
<td><h1>Photo:</h1></td>
<td>
<apex:image url="/servlet/servlet.FileDownload?file=file.Id"/>
</td>
</tr>
</table>
</apex:page>

 

//apex

 

public class displayImageExtension {

private id StCustId;
List<Attachment> file;

 

public displayImageExtension(ApexPages.StandardController stdController) {
this.StCustId = ApexPages.currentPage().getParameters().get('id');
}

public List<Attachment> getfile(){

file=[Select Id,Name,LastModifiedDate from attachment where ParentId=:StCustId];
return file; 
}

 

}

 

Thanks in advance.

  • July 20, 2013
  • Like
  • 0

Hi,

 

I have a custom object which has lookup relationship with account. For attachment info, ParentId is required. How can I get parentId?

 

http://blog.jeffdouglas.com/2010/04/28/uploading-an-attachment-using-visualforce-and-a-custom-controller/

 

I tried the above link. I got errors like,

 

  • Required fields are missing: [Parent]
  • Error uploading attachment

 

Please suggest me to rectify my error.

  • July 16, 2013
  • Like
  • 0

Hi,

       

Here i attached my Update trigger and test class method. Test class method fails.Please help me where i went wrong.

    

////Trigger    

trigger updateContactOpportunity on Account (before update) {
 
 Set<Id> ids=new Set<Id>();
 for(Account a:Trigger.new){
 ids.add(a.id);
 }
 List<Contact> con=[Select id, accountId, phone from Contact where accountId in:ids];
 
 List<Opportunity> opp= [Select id, AccountId, Custom_Opportunity_Number__c from Opportunity where accountId in:ids];
 for(Account a:Trigger.new){
 
 for(integer j=0;j<con.size();j++){
 if(a.id==con[j].accountId){
  con[j].phone=a.phone;
 }
 }
 for(integer i=0; i<opp.size();i++){
 
  if(a.id==opp[i].accountid){
       
   opp[i].Custom_Opportunity_Number__c=a.Custom_Account_Number__c;
   
  }
 }
 }
 update con;
 update opp;

}

 

////TestClass

@isTest
private class testupdateConOpp{
 
  static testMethod void testUpdate(){
  Account a=new Account(name='test',phone='2234',Custom_Account_Number__c='6537');
   insert a;
   Contact c= new Contact(lastName='test', accountId='test.id',phone='2234');
   insert c;
   Opportunity o=new Opportunity(accountId='a.id', Custom_Opportunity_Number__c='6537');
   insert o;
   
   a.phone='111';
   a.Custom_Account_Number__c='222';
   update a;
   
   Contact updatedContact=[Select accountid, phone from Contact where id =:a.id ];
   
   system.assertEquals(updatedContact.phone,'111');
   
   Opportunity updatedOpp=[Select accountId,Custom_Opportunity_Number__c from opportunity where id=:a.id];
   
   system.assertEquals(updatedOpp.Custom_Opportunity_Number__c,'222');
   
}
}

  • July 13, 2013
  • Like
  • 0

When an opportunity is created as Stage Name = =’Closed Won ‘ create an opportunity of this opportunity whose Name will be as  "Cloned+Name of new Opportunity".

As well as Associated Account will be same as new opportunity

 

Thanks in advance

  • July 10, 2013
  • Like
  • 0

If user click on upload button to attach any image, it will open page like standard attach file. 

 

 

 

  • July 10, 2013
  • Like
  • 0

if(themecontent.size()>0)
{
ck=true;
}
else{
ApexPages.Message errMsg= new ApexPages.Message(ApexPages.severity.ERROR, 'Please Create a Layout First ! ');
ApexPages.addMessage(errMsg);

 } 

 

Need a test class for this.......help pls

Hi all,

 

i have this tag, which should display an image (the id is stored in a custom field ):

 

<apex:image value="/servlet/servlet.FileDownload?file={!p.image_id__c}" width="113" height="86" align="left" />

 

I need, in my website, that the text is placed to the right of this picture, but the "align" parameter does not exist in tag <apex:image>.

 

How can i do?

 

Thanks in advance!! 

Message Edited by the_wolf on 02-03-2010 01:48 AM

Hi All,

 

I'm developing application on force.com platform and I need to do the following:

 

1) upload image using Visualforce page

2) save uploaded image to the force.com database 

3) retrieve saved image from the database and display it on another Visualforce page 

 

For step 1 I can use <apex:inputFile ../> component to get an Apex blob object representing uploaded image.

However, for step 2 I don't know how to save this object to force.com database as it doesn't support blob fields.

For step 3 I assume I can use <apex:image .. /> component to display the image.

 

Could anyone advice if I'm on the right track or what is the right way to do this kind of things on Force.com platform?

 

Thanks in advance,

Dennis