HP IDOL OnDemand on Salesforce (Apex)

What is IDOL OnDemand?

IDOL OnDemand delivers a growing set of RESTful APIs to help developers build apps that tackle the explosive growth of unstructured data. We’re exposing the capabilities of HP IDOL (Intelligent Data Operating Layer), the world’s leading on-premise human information processing engine, to deliver a wide selection of web services, including sentiment analysis, face detection, entity extraction, text indexing, and more – for quick and lightweight integration into your apps.

This article assumes that you already have an existing Salesforce developer edition account. If you still don't have a developer account, you may signup here:

Here are the steps on how to sign-up to IDOL OnDemand API Key

  1. Signup for an API key via the following link: https://www.idolondemand.com/signup.html
  2. Once finished, you will receive an API Key that looks like the following: xxxxxxxx-xxxx-xxxx-xxxx-10def765b016
  3. Take note of this key as we will use this to modify the Apex Class named IDOLClient.cls to allow you o try out the application using your own key.

Install the IDOL Demo Package

  1. Click on the installation link and then log into your Salesforce instance to install the application
  2. Make sure to grant third party access to "api.idolondemand.com"
  3. Click next on the Step 1. Approve Package API Access
  4. Select "Grant access to all users" on Step 2. Choose security level then hit next
  5. Click "Install" to install the package
  6. After installation, click the following link to get to the page. https://login.salesforce.com/apex/IDOLDemo
  7. If you see any errors on the previous step, make sure to log-out of any other salesforce instance and login to your developer edition account

Start playing with the HP IDOL OnDemand Application

  1. Select the API to test using the dropdown selection provided
  2. The text to search for Wikipedia and URL to search is provided for the convenience of the user upon selection
  3. Click "Execute API" to call the IDOL API and the results will be provided to the user in the text area provided
  4. The package is an Unmanaged Package so you may view all of the contents of the code

Using your own API Key

If you would like to use your own API Key, you may go to YOUR_NAME > Setup > App Setup > Develop > Apex Classes and edit the class named IDOLClient. Replace the value of the API_KEY with your own Key.


Salesforce codes included in the application

Apex Classes:

  • IDOLClient.cls - Main wrapper class for the HP IDOL OnDemandAPI
  • IDOLDemoController.cls - Controller for the IDOL Demo allowing the user to test out the API via a VisualForce page
  • IDOLAnalyzeSentimentResponse.cls - Converts the Analyze Sentiment JSON response into an Apex Class
  • IDOLFindSimilarResponse.cls - Converts the Find Similar JSON response into an Apex Class
  • IDOLOcrDocumentResponse.cls - Converts the OCR Document JSON response into an Apex Class
  • IDOLAnalyzeSentimentResponseTest.cls - Unit Test classes for IDOLAnalyzeSentimentResponse.cls
  • IDOLClientTest.cls - Unit Test classes for IDOLClient.cls
  • IDOLDemoControllerTest.cls - Unit Test classes for IDOLDemoController.cls
  • IDOLFindSimilarResponseTest.cls - Unit Test classes for IDOLFindSimilarResponse.cls
  • IDOLOcrDocumentResponseTest.cls - Unit Test classes for IDOLOcrDocumentResponse.cls

VisualForce pages:

  • IDOLDemo.page



  • If you would like to try out the other API provided, you may use the following link to easily generate Apex Code from JSON response. http://json2apex.herokuapp.com/



Although the standard Salesforce features are helpful and efficient, it is sometimes required for you to create custom Apex codes in order to improve system performance and triggers that are currently not possible with your standard Salesforce functionality. In order to avoid  apex code error messages that could potentially impact your business, it is pertinent for you to be familiarized with these common errors and get to know how to resolve them. REQUEST_LIMIT_EXCEEDED

This is one of the most common Apex code error messages, and it often appears when your API call limit for your organization has been already exceeded due to huge number of integration with third party applications.

When integrating with third party applications, it is important to consider how would these applications affect your API call limit. It is important to plan and evaluate how these applications would be used in order to prevent the limit from being exceeded.

The best way to monitor API usage is either to run an API usage report or monitor your limit under Setup | Administration Setup | Company Profile | Company Information.


Validation Rules are helpful, but could also be painful, if not correctly used or deployed. In order to avoid this error, Validation Rule should be created based on your business needs, and make sure that it would not conflict with other triggers or rules. Rules should also be assessed periodically to make sure that they are still needed in the organization, if these rules are deemed unnecessary for the org, then the rules could be modified or deleted already.

One of the best ways to deal with this error is to make the class calls a DML operation, specially when deploying a batch class. The opt_allOrNone shouls also be set to False. This workaround would allow saving of the record even though it fails to meet the Validation Rule/s.


This error usually occurs when the length of the entered text is longer than the field length limit. The field length can be modified by going to Name | Setup | Customize | Object Name | Field | Click Edit on the field being modified | Change the length | Save.


Improving your Apex codes and modifying your current customization are necessary to properly deploy Apex codes and avoid encountering errors. If you would like to know more about custom Apex code creation and integration, you may contact us for assistance at info@cloudjedi.com.

Salesforce Spring 14 is Coming!


In order to provide customer satisfaction, Salesforce continuously provide quarterly releases in order to introduce new features and functionality depending on the needs and demands of their customers. Spring 14 release is scheduled to start on February 7, 2014. In order to maximize the new features and to prevent potential data issues, it is important to be prepared and familiarized with the latest Salesforce release.

Sandbox Preview

If you have refreshed your Sandbox before January 3, 2014, then you would have the chance to maximize the Sandbox Preview instance in order for you to test new Salesforce features. It would also prevent your organization from potential data loss. Moreover, this will aid in familiarizing yourself with the latest features without the worry of having your records and customization affected.

To know more about the Sandbox Preview instruction, please refer to this link: http://blogs.salesforce.com/company/2013/11/spring-14-sandbox-preview-instructions.html.

Plan Accordingly

It is the time to determine how the end users would be trained regarding the newest features. You may also need to figure out which of the new features would give more benefits to your organization. You may also need to export your records in order to prevent potential record deletion upon rolling out the latest release. You could also consider reading the release notes at https://help.salesforce.com/help/pdfs/en/salesforce_spring14_release_notes.pdf in order to prevent worries if ever you would see some changes on your Salesforce account.

Highlights of the Release

Here are some of the features that would be introduced on Salesforce's Spring 14 release:

1. Skills and Endorsements (Pilot) – Skills reference data (ProfileSkill) can now be added and associated with People (ProfileSkillUser). Chatter profile will display the skills profile of the user. These skills can also be "endorsed" by other users. Chatter and Setup Pages are the places where the skills can be managed.

2. Feed-Based Page Layouts – This feature would provide convenience and efficiency as it makes Case Feed available also for Account, Contact, Opportunity, Lead, and Custom Objects.

3. API Limit App Quotas (Pilot) - Standard, bulk, and streaming API consumption now have 24 hour API quotas for Connected Apps.

4. Force.com Canvas apps can now be placed into the Salesforce1 navigation menu.

5. Spring 14 also introduces a useful administrator feature that would let you view and manage user sessions.

6. Permission Sets can now be massively assigned.

7. Sharing Sets Enhancements (Pilots) - this would allow indirect lookups from one object to another. This would allow you to access second level of related records.

8. A New User Interface is also introduced to allow you to view and cancel running deployments.

The Future of Salesforce

As Salesforce continuously improve their features, it is no doubt that it would be the next leading CRM tool in the future. Managing your database would be easier as it adapts to the changes and releases. It is always best to be updated with the current trends in order for you to maximize your business and to closely interact with your employees, clients, and customers.

To know more about Spring 14 release, you may check these links:

Spring 14 release video - http://www.salesforce.com/newfeatures/

Spring 14 release notes - https://help.salesforce.com/help/pdfs/en/salesforce_spring14_release_notes.pdf

Major Release Schedule - https://trust.salesforce.com/trust/maintenance/

If you need assistance with preparing your organization for the Spring 14 release, please feel free to contact us at info@cloudjedi.com.

List size based message Visualforce

If you're developing in VisualForce for a while, most likely you've encountered the scenario where you would have to show a list of records. In order to make the page user friendly, we would add a text of "No records found." if there aren't any records to show. Before v27 of VisualForce, we could easily just use the following code to display the text if there aren't any records found.

<apex:outputText value=”No records to display” rendered=”{!myObjectList.size==0}”/>

Starting VisualForce v27, Salesforce will throw out an error if there aren't any records. Issue is because the myObjectList.size is null and it is being compared with a number.

One quick solution for this scenario is the use of the NULLVALUE or the BLANKVALUE to substitute the null value with zero.

<apex:outputText value="No records to display" rendered="{!NULLVALUE(myObjectList.size, 0) == 0}"/>


Hiding the Salesforce Logout Branding in Force.com Sites

In the Salesforce Summer 2011 release, a new Salesforce branded page was introduced that shows up whenever the user logs out or when redirected to /secur/logout.jsp. Some companies that use the Force.com Sites doesn't necessarily want to show that they are using Salseforce so here is a trick that you can implement to hide the branding while still being able to logout properly. 1. Build a new page called myLogOut and add the following VisualForce code into the page:

    Logging out...

The code loads the branded logout page hidden in the background for 5 seconds before being redirected to the login page. This ensures that the page has been loaded properly and

2. Change all references to the logout URL from redirecting to /secur/logout.jsp into $Page.myLogOut

This should fix any branding issues that you might encounter

Formatting numbers or dates with VisualForce

In most cases we can rely on inputField component to do the Currency or Number formatting for us. The problem comes in when we use of wrapper classes that contain primitives where we need to format the data ourselves. Here are some tips that you can use to format numbers/currencies/dates in VisualForce.


With two decimal points - (Ex. $10,000.00)

<apex:outputText value="{0, number,$###,###,##0}"><apex:param value="{!mycurrency}" /></apex:outputText>Without decimal points - (Ex. $10,000)

<apex:outputText value="{0, number,$###,###,##0}"><apex:param value="{!mycurrency}" /></apex:outputText>Numbers

With two decimal points - (Ex. 10,000.00)

<apex:outputText value="{0, number,###,###,##0.00}"><apex:param value="{!mynumber}" /></apex:outputText>

Without decimal points - (Ex. 10,000)

<apex:outputText value="{0, number,###,###,##0}"><apex:param value="{!mynumber}" /></apex:outputText> [/sourcecode]

Date in MM/DD/YYYY format (Ex. 01/01/2011)

<apex:outputText value="{0,date,MM'/'dd'/'yyyy}"> <apex:param value="{!mybirthday}" /> </apex:outputText>Date in YYYY-MM-DD format (Ex. 2011-01-01)

<apex:outputText value="{0,date,yyyy-MM-dd}"> <apex:param value="{!mybirthday}" /> </apex:outputText>


More information:

The only problem I have with this approach is when dealing with multiple locales and currencies. Feel free to comment for any suggestions or requests for format so that I can add it in.