Master Check Box To select all records in Table VisualForce Page.


Provide a master checkbox before all record rows means if user selects that all records will be selected.

- Create VisualForce Component for master check Box.

Component >>


<apex:component >

<script>
function cvCheckAllOrNone(allOrNoneCheckbox) {

    // Find parent table
    var container = allOrNoneCheckbox;
    while (container.tagName != "TABLE") {
        container = container.parentNode;
    }

    // Switch all checkboxes
    var inputs = container.getElementsByTagName("input");
    var checked = allOrNoneCheckbox.checked;
    for (var i = 0; i < inputs.length; i++) { 
        var input = inputs.item(i);
        if (input.type == "checkbox") {
            if (input != allOrNoneCheckbox) {
                input.checked = checked;
            }
        }
    }
}
</script>

<apex:inputCheckbox onclick="cvCheckAllOrNone(this)" title="Toggle All Rows"/>

</apex:component>


You can add a checkbox to the header row of your checkbox column that uses it to check all or none of the checkboxes:

In visualforce page add the component.

<apex:column >
    <apex:facet name="header">
        <c:CheckAllOrNone />
    </apex:facet>
    <apex:inputCheckbox value="YOUrCheckBoxValue"/>
</apex:column>


As this runs at the client side it is nice and quick.

Salesforce auto-create Folder for New Account.



Trigger for Creating Folder On Account Insert.

trigger BoxFolderCreationTrigger on Account (after insert) {
    
    public Set<ID> accids = new Set<ID>();

 for(Account acc : Trigger.New) {
  accIds.add(acc.Id);
 }
 
 if(accIds.size() > 0) {
  BoxFutureClass.createFolder(accIds);
 }
    
}


As Call-out is not allowed in Trigger.Here i have call Future class method for call-out.





Snippet OF Future Class.



global class BoxFutureClass
{
    @future(callout=true)
    public static void createFolder(set<ID> AccIds) {   
        Map<String,String> boxFRUPMap = new Map<String,String>();

        for(box__FRUP__c bF : [SELECT box__Folder_ID__c,box__Record_ID__c FROM box__FRUP__c where box__Object_Name__c = 'Account' limit 9999]) {
            boxFRUPMap.put(bF.box__Record_ID__c,bF.box__Folder_ID__c);
        }
        
        for(Account acc : [Select id,name from account where id IN :AccIds]) 
        {
         
            box.Toolkit boxToolkit ;
       
            if(!boxFRUPMap.containsKey(acc.Id))
            {
                boxToolkit = new box.Toolkit();
               
                String accountFolderId = boxToolkit.createFolderForRecordId(acc.Id,null, true);
             
                boxToolkit.commitChanges();
            }
               
                
          }
    }
 }


box__FRUP__c is custom object for box folder to keep track of folder created by recordId.







Embedding Box Custom Object Records

  1. Log into Salesforce as a Salesforce Admin
  2. For an existing custom object (for example, Custom_Object), create a new custom field in Custom_Object. 
    1. Select Text.
    2. In the Field Label box, type FolderID. In the Length box, type 18 as the maximum length for the text box.
    3. Select the required access level for this object and click Next.
    4. Click Save.
  3. Create a new Visual Force page for Custom_Object, for example, Custom_Object_Box_Section 
  4. Copy the following Visual Force page code and paste it in this new page.
<apex:page standardController="Custom_Object__c" extensions="box.DisplayWidget" showheader="false" sidebar="false" action="{!GetLoginToken}">
 <apex:stylesheet value="{!URLFOR($Resource.box__BoxEmbed, 'BoxEmbed/style.css')}"/> 
<apex:iframe src="/apex/box__BOXSection?id={!Custom_Object__c.Id}&param=Custom_Object_Box_Section" rendered="{!DisplayBoxSection}"/>
<apex:iframe src="{!folderShareLink}" rendered="{!DisplayBoxWidget}" width="100%" height="100%" frameborder="0" scrolling="NO"/>
</apex:page





  • Note: Parameters marked in bold are variables. Change these parameters to match your enterprise setup. For example:
    • Custom_Object__c: Change this variable to the API name of your custom object.
    • Custom_Object__c.Id: Change this variable to the API name of your custom object ID field.
    • Custom_Object_Box_Section: Change this variable to the API name of your Visual Force page.
    1. Add this newly created section to the Custom Object Page Layout. See the Embedding Box in Standard Object Records section for more details.
  • Box For Salesforce

    Installation and Initial Setup


    1. Log into Salesforce as a Salesforce Admin.
    2. Navigate to the package installation link.
    3. At separate points during the installation, you will be asked to:
      • Accept and Approve Third-Party Access for remote settings.
      • Grant access to all users.
      • Click Next or Continue in other screens to complete the installation.
    4. When you complete the installation, the screen will return to the Salesforce Box Connector App (Managed) page.

    5. Click the + tab to view the All Tabs page.
    6. Click Box Settings to view the Connect Salesforce to Box page.
    7. Click the Box API Admin Login button to view the Box API login page.
    8. Enter the Box Service Account credentials.

    9. Specify the name for your Root Folder, e.g. Salesforce-<Org Identifier>.
    10. Specify folder settings for Lead conversions (optional)
    11. Specify your company's subdomain, e.g. if you log into Box at cloud.app.box.com, your subdomain is "cloud".
    12. At this point, you can enable (suggested) or disable Seamless Login and Auto-Collab on the same page, and click Save Settings.
    13. Add the Box functionality to Salesforce objects (e.g. Opportunities, Accounts, etc.)

    Embedding Box in Standard Object Records


    Use the following procedure for all Salesforce standard objects (e.g. Account, Lead, Contact, Opportunity, etc.) requiring a Box Embed addition as part of the page layout.
    1. Access the Salesforce Menu and click Setup (top right corner).
    2. From the left menu, navigate to Build > Customize to find the appropriate object (e.g., Lead, Opportunities, Accounts, or any Custom_Object).
    3. Expand the object's menu and select Page Layouts.
    4. Edit the Page Layout where Box Embed must be added.
    5. From the [Object] Layout > Field menu, drag a new Section into the Page Layout in the desired position. 
    6. Change the Section parameters:
      1. Assign a name for the section (for example, Box Files).
      2. Make the section 1-Column
      3. Click OK
    7. Add the newly-created Visual Force Page to the Page Layout:
      1. From the Lead Layout menu, click Visualforce Pages.
      2. Drag [object_name]BoxSection into your newly created Section.
      3. Click the wrench on the [object_name]BoxSection Visualforce page.
      4. Set the height to 600 pixels (minimum) for best viewing.
      5. Save the page layout.

    How To Create chatter feeds (FeedItem) Or SF File From Attachment?

    Snippet Code for Creating FeedItem.


    - Most of time user easily create feedItem but it seems that file created is not Previewable.

           The only solution to it is add extension to ContentFileName.




    for(Attachment att : [SELECT id,body,parentId FROM ]
    {
     Blob body = att.body;

                String name = (att.name).substringBeforeLast('.');
                String extension = (att.name).substringAfterLast('.');
                
                FeedItem file = new FeedItem();
                file.ParentId =  String.valueof(att.parentid) ;   // ID of parent object of file (Record Id)
                file.ContentData = body;
                file.ContentFileName = name + '.' + extension;
                file.Title = name;
                System.debug('file::' + file);
                
                feedItemList .add(file);
    }

    If(feedItemList.size() > 0)
    {
    insert feedItemList;
    }


    File will get Show up in File related list of Record(Parent id).