• Alagar
  • NEWBIE
  • 0 Points
  • Member since 2011

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 15
    Replies

Hi,

 

I have uploaded an image through vf page and stored in a rich text field(Picture__c) of a custom object (Image__c).

i m facing some difficulties in displaying the image from rich text field(Picture__c) in a page block table. 

I have used wrapper class to convert the rich text field (Data type: STRING) in to BLOB values, after converting the it to BLOB the values are displaying something like below...

 

core.filemanager.ByteBlobValue@23b3379d

core.filemanager.ByteBlobValue@4b0836ba

core.filemanager.ByteBlobValue@4b0836ba

core.filemanager.ByteBlobValue@7d9d25de

 

Here is my code..

 

<apex:page standardController="Image__c" extensions="ImageUpload1">
   <apex:form >
         <apex:pageBlock > //to upload the image
                       <apex:pageBlockSection >
                                 <apex:inputField value="{!Image__c.Name}" label="File Name"/>
                                 <apex:inputField value="{!Image__c.Description__c}" />
                                 <apex:pageblockSectionItem >
                                             <apex:Outputlabel value="Browse" for="files" />
                                                        <apex:inputFile id="files" value="{!Image__c.Picture__c}" contentType="{!imageContentType}" fileName="{!imageName}"/>
                                   </apex:pageblockSectionItem>
                     </apex:pageBlockSection>
                     <apex:pageblockButtons location="Bottom" >
                                   <apex:commandButton value="save" action="{!save}"/>
                      </apex:pageblockButtons>
          </apex:pageBlock>

             <apex:pageBlock >  // to display the image 
                      <apex:pageblockTable value="{!wrapperList}" var="i">
                                  <apex:column value="{!i.img.Name}" headerValue="Name"/>
                                  <apex:column value="{!i.img.Description__c}" headerValue="Description"/>

                                    <apex:column headerValue="Picture" >

                                                  <img src="data&colon;MIME/png;base64,{!i.convertToImage}" />
                                     </apex:column>

                                         <apex:column >
                                                     <apex:outputText value="{!i.picture}" />
                                          </apex:column>

                      </apex:pageblockTable>
               </apex:pageBlock>
       </apex:form>
</apex:page>

 

public with sharing class ImageUpload1 {

    public Blob picture {get; set;}
    public Image__c img {get; set;}
    public string imageContentType {get; set;}
    public string imageName {get; set;}
    public List<Image__c> imgRecords {get; set;}
    public List<blobWrapper> wrapperList {get; set;}

     public ImageUpload1(ApexPages.StandardController controller) {
                img = (Image__c)controller.getRecord();
                imgRecords = [select id, Name, Description__c, Picture__c from image__c];

                 wrapperList = new List<blobWrapper>();
                 for(Image__c imgs : imgRecords ){
                             wrapperList.add(new blobWrapper(imgs));
                  }
      }

    public void save(){
            system.debug('@@Name ' + imageName +'**content Type ' + imageContentType );
            insert img;
     }

public class blobWrapper{
    public Blob picture {get; set;}
    public string convertToImage { get; set;}
    public Blob DecodeToImage { get; set;}
    public Image__c img {get; set;}

   public blobWrapper(Image__c rec){
         img = rec;
         if(img.Picture__c != null){
                   system.debug('!!!In:' + img.Picture__c);
                   picture = Blob.valueof(img.Picture__c);
                   convertToImage = EncodingUtil.base64Encode(picture);
                   DecodeToImage = EncodingUtil.base64Decode(convertToImage);
                  system.debug('**In:' + picture + 'Rec: '+ convertToImage );
         }
    }

}

 

thanks in advance...

  • March 07, 2013
  • Like
  • 0

I have 2 picklist fields(Available fields and Selected fields) and Add button in between the fields.

 

values in Available fields:

 

 Account

 contact

 Opportunity

 

If i select the Account value in Available fields and then by clicking on the Add button it (Account value) should move to Selected fields.How to acheive this?

 

Thanks in Advance.

 

  • October 30, 2012
  • Like
  • 0

1) When am clicking on "Convert" button in the Lead page. It is opening one standard page with some fields like Opportunity,Account look up and some other details. In that page again it is displaying "Convert" button. when we click on that button it will create one record in "Account" and "Opportunity" object.

 

2) While inserting record into Opportunity Object i want to validate some custom fields values entered or not. If they are not entered want to display error message and allow them to fill those custom fields values.

 

In Opportunity object i have some custom fields like Amount,Marketing type, Marketing information and one more fields while inserting record into opportunity at the time of converting lead to Opportunity want to check these values. And want to allow the values for their fields.

 

3) How can i achiece this functionality? can any provide ideas on this. Thanks in advance.

  • March 20, 2013
  • Like
  • 0

Hi,

 

I have uploaded an image through vf page and stored in a rich text field(Picture__c) of a custom object (Image__c).

i m facing some difficulties in displaying the image from rich text field(Picture__c) in a page block table. 

I have used wrapper class to convert the rich text field (Data type: STRING) in to BLOB values, after converting the it to BLOB the values are displaying something like below...

 

core.filemanager.ByteBlobValue@23b3379d

core.filemanager.ByteBlobValue@4b0836ba

core.filemanager.ByteBlobValue@4b0836ba

core.filemanager.ByteBlobValue@7d9d25de

 

Here is my code..

 

<apex:page standardController="Image__c" extensions="ImageUpload1">
   <apex:form >
         <apex:pageBlock > //to upload the image
                       <apex:pageBlockSection >
                                 <apex:inputField value="{!Image__c.Name}" label="File Name"/>
                                 <apex:inputField value="{!Image__c.Description__c}" />
                                 <apex:pageblockSectionItem >
                                             <apex:Outputlabel value="Browse" for="files" />
                                                        <apex:inputFile id="files" value="{!Image__c.Picture__c}" contentType="{!imageContentType}" fileName="{!imageName}"/>
                                   </apex:pageblockSectionItem>
                     </apex:pageBlockSection>
                     <apex:pageblockButtons location="Bottom" >
                                   <apex:commandButton value="save" action="{!save}"/>
                      </apex:pageblockButtons>
          </apex:pageBlock>

             <apex:pageBlock >  // to display the image 
                      <apex:pageblockTable value="{!wrapperList}" var="i">
                                  <apex:column value="{!i.img.Name}" headerValue="Name"/>
                                  <apex:column value="{!i.img.Description__c}" headerValue="Description"/>

                                    <apex:column headerValue="Picture" >

                                                  <img src="data&colon;MIME/png;base64,{!i.convertToImage}" />
                                     </apex:column>

                                         <apex:column >
                                                     <apex:outputText value="{!i.picture}" />
                                          </apex:column>

                      </apex:pageblockTable>
               </apex:pageBlock>
       </apex:form>
</apex:page>

 

public with sharing class ImageUpload1 {

    public Blob picture {get; set;}
    public Image__c img {get; set;}
    public string imageContentType {get; set;}
    public string imageName {get; set;}
    public List<Image__c> imgRecords {get; set;}
    public List<blobWrapper> wrapperList {get; set;}

     public ImageUpload1(ApexPages.StandardController controller) {
                img = (Image__c)controller.getRecord();
                imgRecords = [select id, Name, Description__c, Picture__c from image__c];

                 wrapperList = new List<blobWrapper>();
                 for(Image__c imgs : imgRecords ){
                             wrapperList.add(new blobWrapper(imgs));
                  }
      }

    public void save(){
            system.debug('@@Name ' + imageName +'**content Type ' + imageContentType );
            insert img;
     }

public class blobWrapper{
    public Blob picture {get; set;}
    public string convertToImage { get; set;}
    public Blob DecodeToImage { get; set;}
    public Image__c img {get; set;}

   public blobWrapper(Image__c rec){
         img = rec;
         if(img.Picture__c != null){
                   system.debug('!!!In:' + img.Picture__c);
                   picture = Blob.valueof(img.Picture__c);
                   convertToImage = EncodingUtil.base64Encode(picture);
                   DecodeToImage = EncodingUtil.base64Decode(convertToImage);
                  system.debug('**In:' + picture + 'Rec: '+ convertToImage );
         }
    }

}

 

thanks in advance...

  • March 07, 2013
  • Like
  • 0

Hello friends , i am writing a test class. in this test class i need to create a user - for this i wrote following code

User u = new User();
        Profile pf = [Select id, Name from Profile where Name =:'APAC' limit 1];
           system.debug('-------'+pf);
            u.LastName = 'Nicomatic2';
            u.Email = 'test@gmail.com.sandbox';
            u.CompanyName = 'test.com';
            u.Title = 'Test User';
            u.Username = 'test@gmail.com.sandbox';
            u.Alias = 'ni';
            u.CommunityNickname = 'nicomatic21';
            u.TimeZoneSidKey = 'America/Mexico_City';
            u.LocaleSidKey = 'en_US';
            u.EmailEncodingKey = 'ISO-8859-1';
            u.ProfileId = pf.Id;
            u.LanguageLocaleKey = 'en_US';       
            insert u;

 During excecution of this i get's error : Error - INVALID_CROSS_REFERENCE_KEY, invalid cross reference id: [] in insert U; line.

In system.debug line i am geeting profile name and id but still it's not working. But when i put 'standar user' Or 'System Admin' than it works. Why ? 

Hi To All,

 

         I am trying to write parent to child relation ship qery between custom object and ProcessInstances and ProcessInstancesworkitems, then i need to display this all in pageblock table.

 

I am able to write query between custom object and ProcessInstances.it's fetching records fine.here i am unable show ProcessInstances details in page block table

<apex:page controller="approvallistclass" >
<apex:form >
<apex:pageBlock >
<apex:pageBlockTable value="{!apprlst.}" var="v">

<apex:column value="{!v.TargetObjectId }" />   I am unable to show this two fields in VF Page
<apex:column value="{!v.Status}"/>
<apex:column value="{!v.IsDeleted}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>

 

public with sharing class approvallistclass {


public list<position__C> apprlst {get;set;}
public approvallistclass() {
apprlst = new list<Position__C>();

 This is working fine

apprlst = [select id,name,(SELECT Id,IsDeleted,Status,TargetObjectId FROM ProcessInstances) from position__C where id='a0A9000000Cbu2p'];  }  }

 

This is not working 

apprlst = [select id,name,(SELECT Id,IsDeleted,Status,TargetObjectId FROM ProcessInstances),(SELECT ActorId,d,IsDeleted, FROM ProcessInstanceWorkitem) from position__C where id='a0A9000000Cbu2p']  

i am getting following error.

 

Didn't understand relationship 'ProcessInstanceWorkitem' in FROM part of query call. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names. at line 9 column 13

I think it may be because there is no relation ship between Position__C and procesinstanceworkitem ,but id need procesinstanceworkitem ID 

 

Can Any give me any idea on this query then how to dispaly that all in VF Page.

 

 

Hi Everyone,

 

I want to copy approval histroy from one object to another object. Could anyone help me on this. Does anyone know how to copy 

this using apex.

 

Regards,

Rajiv

  • January 23, 2013
  • Like
  • 0

Hi,

   I ahve two objects Opportunity and Attcahment_c, One opportunity can have multiple atachments. I ahve wrtiien this login on them:

for(Opportunity opp: Trigger.new)
       {
         attchmnt=[select id,DownloadedIndicator__c from Attachment__c where (Opportunity__c=: opp.id  AND Source__c='Sales')];
         for(i=0;i< attchmnt.size();i++)
         {
            attchmnt[i].DownloadedIndicator__c=false;
         }
       }
// Updating the list of attchments      
        if(attchmnt.size()!=0)
        {
             update attchmnt;
        }

Need to get soql out of the for loop. Can anyone please help me with this?

I have 2 picklist fields(Available fields and Selected fields) and Add button in between the fields.

 

values in Available fields:

 

 Account

 contact

 Opportunity

 

If i select the Account value in Available fields and then by clicking on the Add button it (Account value) should move to Selected fields.How to acheive this?

 

Thanks in Advance.

 

  • October 30, 2012
  • Like
  • 0

I need to determine if an approval process exists for my object in an org, dynamically, so I can determine if I should display a 'Submit for Approval' button.

 

I can't find anyway to directly query for the existance of an Approval Process, (the standard recordtype: Approval, I believe, relates specific approvals that are already started for a particular object, I can't test these, as I need to know, ideally before any of them exist)

 

I thought about trying to start an approval for the current record and trapping the error message, but, if it succeeded, than the record would be submitted for approval (by the test):

 

try{
Approval.ProcessSubmitRequest req = new Approval.ProcessSubmitRequest();
req.setObjectId(this.object.id);
Approval.ProcessResult result = Approval.process(req);	
}
catch(exception e){
 if(e.contains == "Some ERROR")
   //set my flag
}

 

Thoughts? Am I just missing something?

 

 

 

How can we copy email id from person account to any other related object. E.g. Email id from Person account to Opportunity.
  • May 29, 2012
  • Like
  • 0

Hi all,

 

I am new to this discussion board and I realise that this may have been posted a few times before but I have been unable to find a definitive resolution to this problem whereby it doesn't seem to be possible to get a list of picklist values relative to the record type.

 

My scenario is that we have a lead status picklist field that displays certain statuses if the record type is a Sales Record Type and displays a different set of statuses if the record type is a Marketing Record type. The following code that I use to try and pull out the lead statuses relavent to a particular record type doesn't work and instead the complete list of lead status values for both Sales and Marketing leads is displayed instead:

 

public List<SelectOption> getLeadStatusValue(){
    if(leadStatusValue == null){
        
        Schema.DescribeFieldResult fieldResult = Lead.Status.getDescribe();
        List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
        List<SelectOption> options = new List<SelectOption>();
        options.add(new SelectOption('', ''));
                     
        for( Schema.PicklistEntry f : ple)
        {
            options.add(new SelectOption(f.getLabel(), f.getValue()));
        }       
        leadStatusValue = options;
    }
    return leadStatusValue;
}

 

Does anybody know of any solution to this problem? Any help is greatly appreciated.

 

Thanks a million!

I am trying to import Attachments exported from another Org into this Org. Shortly after attempting to 'Finish' the import using the DataLoader (v17), I am getting a Java Heap Space error. I have tried rebooting the PC. None of the files are larger than 5MB.

 

Any suggestions would be greatly appreciated.