• sarvendra aeturu 10
  • NEWBIE
  • 15 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 3
    Replies
i have a requirement to display custom object attachments on a visualforce page with a search functioanlity(able to search by the document name) i can able to develope the visualforce page to display the attachments in a visualforce page. please help me in writing the search functionality.

below is the code 

VF page

<apex:page controller="KnowledgeBaseAttachment" showheader="false" >
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection columns="2">
<apex:repeat value="{!listAttachment}" var="att">
<apex:pageBlockSectionItem >
<apex:outputLink value="{!URLFOR($Action.Attachment.Download, att.id)}" target="_blank">{!att.name}
</apex:outputLink>
</apex:pageBlockSectionItem>
</apex:repeat>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>

controller code 

public class KnowledgeBaseAttachment {
    public List<Attachment> listAttachment {get; set;}
    public KnowledgeBaseAttachment() {
        listAttachment = new List<Attachment>();
        List<aeturu__Knowlegde_Base__c> lstKnowledgeBase = [Select Id, (Select Id, Name from Attachments)
                                                            from aeturu__Knowlegde_Base__c];
        for (aeturu__Knowlegde_Base__c obj : lstKnowledgeBase) {
            listAttachment.addAll(obj.Attachments);
        }
    }
}

any help is appriciated

thanks 
sarvam
i have a requirement to display custom object attachments on a visualforce page with a search functioanlity(able to search by the document name) i can able to develope the visualforce page to display the attachments in a visualforce page. please help me in writing the search functionality.

below is the code 

VF page

<apex:page controller="KnowledgeBaseAttachment" showheader="false" >
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection columns="2">
<apex:repeat value="{!listAttachment}" var="att">
<apex:pageBlockSectionItem >
<apex:outputLink value="{!URLFOR($Action.Attachment.Download, att.id)}" target="_blank">{!att.name}
</apex:outputLink>
</apex:pageBlockSectionItem>
</apex:repeat>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>

controller code 

public class KnowledgeBaseAttachment {
    public List<Attachment> listAttachment {get; set;}
    public KnowledgeBaseAttachment() {
        listAttachment = new List<Attachment>();
        List<aeturu__Knowlegde_Base__c> lstKnowledgeBase = [Select Id, (Select Id, Name from Attachments)
                                                            from aeturu__Knowlegde_Base__c];
        for (aeturu__Knowlegde_Base__c obj : lstKnowledgeBase) {
            listAttachment.addAll(obj.Attachments);
        }
    }
}

any help is appriciated

thanks 
sarvam

Kindly provide a solution to the following : 

 

Details

I as a product manager require a custom search page for my salesforce CRM account. I don’t want to use the standard search functionality for this. Here is what I want to be done:

 

    1. On the VF page, create accustom “search” button and a checkbox with the name “limit to accounts I own”
    2. I should be able to enter and search on the following fields (these are the search criteria fields):
      1. Account name(standard field)
      2. Industry (standard field)
      3. Rating(standard field)
      4. Account  region(custom field)
      5. Account priority(custom filed)
      6. Account summary(text)
    3. The search functionality should be a logical OR of all the above combinations.
    4. The correct search results should be displayed ON THE SAME PAGE only after clicking the “submit” button.Display columns should have these fields: account name, industry, rating, account priority.
    5. If the checkbox “limit to accounts I Own” is checked before clicking on search the display only those accounts where the owner=current logged in user. 

I have developed the following code:

 

<apex:page Controller="AccountSearch">
<apex:form >
 
<apex:outputPanel layout="block">
<label for="checkbox"> Limit to Account I own: </label>
<input id="checkbox" type="checkbox"/>
</apex:outputPanel>
<apex:commandButton action="{!search}" value="Search"/>
 
<apex:pageBlock mode="edit" id="block">
         <apex:pageBlockSection >
            <apex:pageBlockSectionItem >
               <apex:outputLabel for="searchText">Search Text</apex:outputLabel>
               <apex:panelGroup >
                  <apex:inputText id="searchText" value="{!searchText}"/>
                  <apex:commandButton value="Submit" action="{!search}" 
                                      rerender="block"/>
               </apex:panelGroup>
            </apex:pageBlockSectionItem>
        </apex:pageBlockSection>
 <apex:actionStatus id="status" startText="requesting..."/>
<apex:pageBlockSection title="Results" id="results" columns="1">
           <apex:pageBlockTable value="{!results}" var="a"
                               rendered="{!NOT(ISNULL(results))}">
                               
              <apex:column value="{!a.Name}"/>
              <apex:column value="{!a.Industry}"/>
              <apex:column value="{!a.Rating}"/>
              <apex:column value="{!a.Account_Region__c}"/>
              <apex:column value="{!a.Account_Priority__c}"/>
              <apex:column value="{!a.Account_Summary__c}"/>
   </apex:pageBlockTable>
   </apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
__________________________________________________________________________________________
 
public class AccountSearch {
 
  String searchText;
   List<Account> results;
 
public String getSearchText() {
      return searchText;
   }
 
   public void setSearchText(String s) {
      searchText = s;
   }
 
   public List<Account> getResults() {
      return results;
   }
    public PageReference search() {
    results = (List<Account>)[FIND :searchText RETURNING Account(Name, Industry, Rating, Account_Region__c, Account_Priority__c, Account_Summary__c)][0];  
        return null;
    }
 
}
Please provide the necessary modifications
  • May 27, 2013
  • Like
  • 3

I am having trouble inserting a list of chatter feed items of type 'ContentPost'. These feed items are being dynamically created for a list of contacts/campaign members (post.ParentId = 'contact id goes here') associated to a campaign; as well as the campaign itself. While I am iterating over the list of contacts I am also creating an attachment for each of them then
associating this attachment to the feed item. Both Attachments and Feed Items are added to separate lists then post for loop are inserted into the database.

 

I am able to successfully insert the chatter feed items (as text post posts, not content) if I don't associated the attachments, however when I associate the attachment body to the content data field of the feed item I get the following error:

 

Insert failed. First exception on row 0; first error: INVALID_ID_FIELD, You do not have the level of access necessary to perform the operation you requested. Please contact the owner of the record or your administrator if access is necessary.: []

 

I am running this as a system administrator on our dev sandbox, so I'm not sure what is causing this insufficient privileges error. I would appreciate any help on this, and if needed I can provide a more technical description with code snippets of the logic.