• Visweswara Rao Pamala
  • NEWBIE
  • 0 Points
  • Member since 2015
  • Salesforce Expert
  • Documill

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 3
    Replies
Hi all,

Can you please help me how to add rows dynamically in vf page based on record getting in query in controller.
Below is the code iam using, in this currently adding one row, but need to add rows based on the record getting in SQL query.

VF page:
<apex:page standardController="Opportunity" extensions="ListsControllernew">
  <apex:form >   
<apex:pageBlock title="Files">
     
       <apex:pageBlockButtons location="top" >
               <apex:commandButton value="Upload Files" />
       </apex:pageBlockButtons>
      
      <apex:pageBlockTable value="{!oppname}" var="acc">
            <apex:column headerValue="Action" value="{!oppname}" />
            <apex:column headerValue="Title" value="{!title}" />
            <apex:column headerValue="Last Modified by" value="{!Modified}" />
            <apex:column headerValue="Is Locked" value="{!Lockvalue}" />
           
        </apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>

Controller:
public class ListsControllernew  {

    private final Opportunity opp;
    public string title{get; set;}
    public String Modified{get; set;}
    public String Lockvalue{get; set;}
    public String oppname {get; set;}
    
  
    public ListsControllernew(ApexPages.StandardController stdController) {
        this.opp= (Opportunity)stdController.getRecord();
        system.debug('id:'+opp.id);
        //List<Opportunity> customObjects =[select name from Opportunity where Id=:opp.id];
        //SELECT ContentDocumentId, FROM ContentDocumentLink WHERE LinkedEntityId = '[RECORD ID]' 
        integer count = [SELECT count()FROM ContentDocumentLink WHERE LinkedEntityId =: opp.id];
        system.debug('Count:'+count);
        List<ContentDocumentLink> customObjects = [SELECT Id, ContentDocumentId, ContentDocument.LatestPublishedVersionId, ContentDocument.Title, ContentDocument.CreatedById, ContentDocument.LastModifiedDate FROM ContentDocumentLink WHERE LinkedEntityId =: opp.id];
        for (ContentDocumentLink rec: customObjects)
         {
        oppname = rec.ContentDocument.Title;
        title=rec.ContentDocument.Title;
        Modified=rec.ContentDocument.CreatedById;
        Lockvalue= rec.ContentDocument.CreatedById;
         }
        
             
   } 
}

Thanks.
 
Hi All,

I getting the field values (Is_Locked__c & Locked_By__c )from old content version(previous),but these field values are returning NUll.

Use case: For first time on uploading the "new version" of document from chatter feed items, updating the field values Is_Locked__c to "True" and Locked_By__c to username.

And second time when uploading new version for feed item, i am getting the field values (Is_Locked__c& Locked_By__c) of previous content version and comparing. But i am getting Null values for these field values (Is_Locked__c & Locked_By__c).

I am using the below code and please help me to get updated field values instead null value,instead referring to correct document (Previous content version)?

Thanks in Advance.

Code:

Trigger ContentVersionStop_trigger on ContentVersion (before insert, before update) { 

       // Getting the current username
       String userName = UserInfo.getUserName();
       User activeUser = [Select name From User where Username = : userName limit 1];
       String currentusername = activeUser.name;
       system.debug('Current user:' + currentusername );
       system.debug('Trigger New:' + Trigger.new);


   ContentVersion oldCV = [Select Id,CreatedDate, PathOnClient, ContentUrl, Is_Locked__c, Locked_By__c, Title from ContentVersion Order By CreatedDate Desc Limit 1];   

  for (ContentVersion cv : Trigger.new) {

    if (oldCV.Is_Locked__c == NULL && oldCV.Locked_By__c==NULL)
      { 
       system.debug('Into Null Loop:' +oldCV.Is_Locked__c);
      cv.Is_Locked__c='True';
      cv.Locked_By__c=currentusername;
       System.debug('records1 are ' + cv);
      }
      else if(oldCV.Is_Locked__c == 'True' && oldCV.Locked_By__c==currentusername )
      {
      system.debug('Into locked Loop:' +oldCV.Is_Locked__c);
      cv.addError('Version is locked');
      } 
  }
}
Hi All,
I need to run a trigger when user download the attachment from Chatter feed item.
Use case: When user clicks on “Download” link on feed item attachment and downloads successfully, need to run a trigger that executes document locking (i.e., Document is locked for editing and no other user can download or upload new version until user unlocks it).
Is there any way to run trigger, when user clicks on “Download” link in feed item attachment, as show in below screen shot? Any inputs on this.
I tried googling it and gone through salesforce guide, but couldn’t find a way to do it.
Thanks in AdvanceUser-added image
 
Hi,
I am trying to hide Salesforce standard search from custom vf page in Classic and Lightning experience.
By using below, i can able to hide in classic view but not in lightning experience.
apex:page showHeader="false" standardStylesheets="false" sidebar="true"
Any ideas how to hide standard search from lightning experience.
Thanks in Advance.
Br Visu
Hi All,

I getting the field values (Is_Locked__c & Locked_By__c )from old content version(previous),but these field values are returning NUll.

Use case: For first time on uploading the "new version" of document from chatter feed items, updating the field values Is_Locked__c to "True" and Locked_By__c to username.

And second time when uploading new version for feed item, i am getting the field values (Is_Locked__c& Locked_By__c) of previous content version and comparing. But i am getting Null values for these field values (Is_Locked__c & Locked_By__c).

I am using the below code and please help me to get updated field values instead null value,instead referring to correct document (Previous content version)?

Thanks in Advance.

Code:

Trigger ContentVersionStop_trigger on ContentVersion (before insert, before update) { 

       // Getting the current username
       String userName = UserInfo.getUserName();
       User activeUser = [Select name From User where Username = : userName limit 1];
       String currentusername = activeUser.name;
       system.debug('Current user:' + currentusername );
       system.debug('Trigger New:' + Trigger.new);


   ContentVersion oldCV = [Select Id,CreatedDate, PathOnClient, ContentUrl, Is_Locked__c, Locked_By__c, Title from ContentVersion Order By CreatedDate Desc Limit 1];   

  for (ContentVersion cv : Trigger.new) {

    if (oldCV.Is_Locked__c == NULL && oldCV.Locked_By__c==NULL)
      { 
       system.debug('Into Null Loop:' +oldCV.Is_Locked__c);
      cv.Is_Locked__c='True';
      cv.Locked_By__c=currentusername;
       System.debug('records1 are ' + cv);
      }
      else if(oldCV.Is_Locked__c == 'True' && oldCV.Locked_By__c==currentusername )
      {
      system.debug('Into locked Loop:' +oldCV.Is_Locked__c);
      cv.addError('Version is locked');
      } 
  }
}
Hi All,
I need to run a trigger when user download the attachment from Chatter feed item.
Use case: When user clicks on “Download” link on feed item attachment and downloads successfully, need to run a trigger that executes document locking (i.e., Document is locked for editing and no other user can download or upload new version until user unlocks it).
Is there any way to run trigger, when user clicks on “Download” link in feed item attachment, as show in below screen shot? Any inputs on this.
I tried googling it and gone through salesforce guide, but couldn’t find a way to do it.
Thanks in AdvanceUser-added image