Bridgeline Digital Logo
Menu

Access Media Library from Salesforce

You can create custom fields on any Salesforce object that are lookups to images stored in the OrchestraCMS media library. This allows you to add images stored in the OrchestraCMS media library to any record from within Salesforce.

This image shows an Account record that has OrchestraCMS media library images included in two custom fields – Logo and Thumbnail:

This feature requires you to do the following:

  • Create one or more custom fields on the object where you want to be able to access the OrchestraCMS media library.
  • Create a Visualforce page for the Media Lookup component, which allows users to access the OrchestraCMS media library from the edit page of a record; this Visualforce page needs to be created for each object that you want to be able to access from the OrchestraCMS media library.
  • Create a Visualforce page for the REST Proxy; this page only needs to be created once.
  • Add the Visualforce page for the Media Lookup component to the relevant page layouts for the object.

After these steps are completed, you can add images from the OrchestraCMS media library to a Salesforce record.

Add an OrchestraCMS media library image to a Salesforce record

  1. Go to the detail page of the Salesforce record that you want to add an image to.
  2. Click Edit Images.
  3. Click Select next to the field to which you want to add an image.
  4. In the OrchestraCMS media library browser, locate the image you want to add, click to select the check box beside the image name, and then click Select.
  5. Repeat steps 3 and 4 to add images to other fields.
  6. Click Save.

You can also remove images from Salesforce records using a similar procedure.

Remove an OrchestraCMS media library image from a Salesforce record

  1. Go to the detail page of the Salesforce record that you want to add an image to.
  2. Click Edit Images.
  3. Click Clear next to the field that contains the image you want to remove.
  4. Click Save.

Create a custom field to access the OrchestraCMS media library browser

Custom fields must be created for the objects that require images to be added from the OrchestraCMS media library. Custom fields can be added to standard Salesforce objects or custom Salesforce objects. These fields must be Lookup Relationship fields that look up to the Library Content custom object included in OrchestraCMS.

To create a custom field to access the OrchestraCMS media library

  1. In Salesforce Setup, do one of the following:
    • To create a field for a standard Salesforce object, expand Customize, expand the object name, and then click Fields.
    • To create a field for a custom Salesforce object, expand Create, click Objects, and on the Custom Objects page under the Label column, click the label of the custom object.
  2. In the Custom Fields & Relationships area, click New.
  3. In Step 1. Choose the field type, select Lookup Relationship, and then click Next.
  4. In Step 2. Choose the related object, from the Related To list, select Library Content, and then click Next.
  5. In Step 3. Enter the label and name for lookup field, enter a valid label and name for the field in the Field Label and Field Name boxes, and then click Next.
  6. In Step 4. Establish field-level security for reference field, set whether you want the field to be visible, read-only or hidden (no check box selected) to users belonging to various profiles, and then click Next. Only users that belong to profiles that have Visible selected will be able to edit the field if they have edit permissions for the relevant records.
  7. In Step 5. Add reference field to Page Layouts, click to clear the Add Field check box, and then click Next; the field itself is not required on page layouts, because it will be shown through a Visualforce page.
  8. In Step 6. Add custom related lists, click to clear the Library Content Layout check box, and then click Save; it is not necessary to include a related list for the new field on the Library Content Layout, although you can choose to include it.

You can create as many of these custom fields for as many objects as required. A Visualforce page for the Media Lookup component, as described in the next section, must be created for each object that includes one of these media lookup fields.

Create a Visualforce page for the Media Lookup component

This Visualforce page uses the object’s standard controller and passes the record, custom lookup fields, and the list of OrchestraCMS sites that contain the media libraries that should be accessible.

The Visualforce page includes the following code (this example uses the Account object):

<apex:page standardController="Account" showHeader="true" sidebar="true">

<cms:MediaLookup record="{!Account}" fields="Logo__c, Thumbnail__c" sites="Documentation" useEditButton="true” />

</apex:page>

 

The object name, custom lookup field names, and site names in the Visualforce page code must be customized for the object you are using and the names of the fields and sites you have created. If you are using a custom object, the object name must be followed by __c. For example, if you have a custom object named Article, you would use Article__c to populate the values for standardController and record.

To create a Visualforce page for the Media Lookup component

  1. In Salesforce Setup, expand Develop, and then click Pages.
  2. On the Visualforce Pages page, at the top of the table, click New.
  3. In the Page Information area, enter a label and name for the Visualforce page (these must follow the standard Salesforce label and name conventions).
  4. In the Visualforce Markup area, delete the default code and enter the page code as previously described.
  5. Click Save.

 

Create a Visualforce page for the REST Proxy

This Visualforce page only has to be created once and not for every object.

 

This page must be named RESTProxy (not case sensitive).

The Visualforce page includes the following code (the code for this page does not need to be customized):

<apex:page controller="cms.RESTProxy" action="{!loadResponse}"

showHeader="false" sidebar="false"

contentType="{!mimetype}">{!response}</apex:page>

To create a Visualforce page for the REST Proxy

  1. In Salesforce Setup, expand Develop, and then click Visualforce Pages.
  2. On the Visualforce Pages page, at the top of the table, click New.
  3. In the Page Information area, enter RESTProxy for the Label and Name fields.
  4. In the Visualforce Markup area, delete the default code and enter the page code as previously described.
  5. Click Save.

Add the Visualforce page for the Media Lookup component to page layouts

When added to a page layout, the Visualforce page for the Media Lookup component renders labels for the specified fields as well as an Edit Images button that allows users to select images from the OrchestraCMS media library. After images are added, it also renders the images.

To add the Visualforce page for the Media Lookup component to page layouts

  1. In Salesforce Setup, do one of the following:
    1. To add the Visualforce page to a page layout for a standard Salesforce object, expand Customize, expand the object name, and then click Page Layouts.
    2. To add the Visualforce page to a page layout for a custom Salesforce object, expand Create, click Objects, and on the Custom Objects page under the Label column, click the label of the custom object.
  2. In the Page Layouts area under the Action column, click Edit in the row of the relevant page layout.
  3. Select Visualforce Pages from the page component type list.
  4. Drag your Media Lookup page to the area of the page layout that you want it to appear.
  5. Click Save.

Since the Visualforce page renders labels and images for the custom fields, you do not need to add the custom fields separately to the page layouts.