Weather Underground Integration with Salesforce

Recently at Cloudjedi, we did a Weather Underground integration with Salesforce to regularly forecast temperatures for every city to enable our customer to predict demand for their popsicle business. The idea was to query Weather Underground API using a scheduled Apex batch and save the temperature forecast to the database pertaining to each city.  

You can browse the Weather Underground API from their website. But here's a developer guide on how we did the Weather Underground integration.

The Salesforce schema contained a Climate custom object. Each Climate object pertains to a city, and saves the weather forecast for the next 10 days.


1. Create a new Climate object and save the correct Weather Underground query string in the Climate record. Use an object field Weather_Underground_Query__c to save this query string. The following is an example of a well-formed HTTP request that queries Weather Underground for the weather condition of today and the next nine days:<API_Key>/forecast10day/q/CA/San_Francisco.json

The query string can come in many formats:

- StateName/CityName - CountryName/CityName - CityName - CountryISOCode/CityName

The desired response format should be appended at the end: “.json” is what we used. The Weather Underground API also provides unique city codes that can be used for querying. For example, to query a forecast for New York, the HTTP request should include the New York zmw code "zmw:31003.1.99999":<API_Key>/forecast/q/zmw:31003.1.99999.json

Ambigous queries return an array of possible cities from which the correct query can be selected. If a city is ambiguous, manually make sure that the query works before running the Apex job. For example if "Argentina/BuenosAires.json" doesn’t return the correct JSON response, try requesting for "BuenosAires.json" or "AR/BuenosAires" Save the working query in Weather_Underground_Query__c


2. Create an API class that interacts with Weather Underground and parses the HTTP Response data. We named it WundergroundAPI. It has the following methods:

public static WundergroundAPI callout(String path){
  HttpRequest req = new HttpRequest();
  req.setEndpoint('' + wundergroundAPIKey + path);
  Http http = new Http();
  HttpResponse res = new HttpResponse();
  res = http.send(req);
  return WundergroundAPI.parse(res.getBody());

Since we used JSON, one of the benefits is that we can easily generate using JSON2Apex the corresponding Apex class components needed to parse the response using System.JSON.deserialize().

public static WundergroundAPI parse(String jsonString) {
  return (WundergroundAPI) System.JSON.deserialize(jsonString, WundergroundAPI.class); }


3. Create a Schedulable Batchable Apex class that schedules its own batch job daily.

In implementing the execute method of the Batchable interface, use the WundergroundAPI.callout() method to generate a response class. In this case the JSON2Apex deserialization created a WundergroundAPI object that has the JSON data in its attributes. Use this WundergroundAPI object to navigate through the response class properties to get the max temperatures for each day of the forecast period.

public void execute(Database.BatchableContext BC, List<Climates__c> climates){
  for (Climate__c climate : climates) {
    String cityAPICode = clima.Weather_Underground_Query__c;
    String fullRequestPath = formatURLPath('forecast10day',cityAPICode);
    WundergroundAPI calloutResponse = WundergroundAPI.callout(fullRequestPath);
    List<WundergroundAPI.Forecastday_Z> forecasts = calloutResponse.forecast.simpleforecast.forecastday;
    climate.TEMP_max_today__c = forecasts[0].high.celsius;
    climate.TEMP_max_tomorrow__c = forecasts[1].high.celsius;
    climate.TEMP_max_in_2_days__c = forecasts[2].high.celsius;
    climate.TEMP_max_in_3_days__c = forecasts[3].high.celsius;
    climate.TEMP_max_in_4_days__c = forecasts[4].high.celsius;
    climate.TEMP_max_in_5_days__c = forecasts[5].high.celsius;
    climate.TEMP_max_in_6_days__c = forecasts[6].high.celsius;
    climate.TEMP_max_in_7_days__c = forecasts[7].high.celsius;
    climate.TEMP_max_in_8_days__c = forecasts[8].high.celsius;
private static String formatURLPath(String feature, String query){
  return '/' + feature + '/q/' + query + '.json';

Do not forget to schedule the execute method for the Schedulable interface. public void execute(SchedulableContext sc){
  String actualQuery = 'SELECT Id, Name, Weather_Underground_Query__c FROM Climate__c)';
  WeatherForecastBatch batch = new WeatherForecastBatch  (actualQuery);
  Database.executeBatch(batch, 200);

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:
  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 ""
  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.
  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:




  • 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.


Scheduled jobs on Salesforce using Heroku and Beatbox Part 1

Here at Cloudjedi, we often have clients who require external data to be imported into salesforce at regular intervals. In most cases, the data is in another database, behind a REST API, or a file in an ftp server and thus, we needed to interface with them and make the necessary queries in order to obtain the desired data. There are times also that the job requires the script to ping hourly or every X minutes. In both of these cases, it's almost impossible to make use of vanilla apex. For this technical problem, we decided to make use of a python-based interface to Salesforce's SOAP API named beatbox to import our salesforce data for us and heroku as our platform to run the script on. For the first part of this series, I'll be talking about how to communicate with salesforce using beatbox:


  • Python 2.7.* and pip installed. You may want to use virtualenv for isolated environments also
  • Salesforce DevOrg Credentials - username, password and security token

Let's get started.

Initial Setup:

1. Setup your python environment and install beatbox by running in the command-line:

pip install beatbox

2. Let's create a folder for our project "bb2sf" and our file where we will put our code

mkdir bb2sf

cd bb2f && touch

3. Edit and copy paste the code below:

import beatbox CONFIG = { 'SF_HOST': '', 'SF_USER': <'USERNAME>', # Salesforce username 'SF_PASS': '<PASSWORD>', # Salesforce password 'SF_KEY' : '<SECURITY_TOKEN>', # Salesforce security token } sf = beatbox._tPartnerNS svc = beatbox.Client() svc.serverUrl = CONFIG['SF_HOST'] svc.login(CONFIG['SF_USER'], CONFIG['SF_PASS'] + CONFIG['SF_KEY'])

--what the this code simply does is login to your salesforce instance. Ideally, you should be storing the your salesforce credentials in an environment variable but we we'll store in a constant for the purposes of this post.

Inserting a Contact Object

1. Next, we will attempt to create a Contact object. Append this snippet to the code above:

obj = { 'type': 'Contact', 'FirstName': 'Johnabhelle', 'LastName': 'Maroney' 'Phone': '634-1892', 'Salutation': 'Prof' } result = svc.create(obj) if str(result[sf.success]) != 'true': print(result) else: print('Success!')

2. Run the script in the terminal using this command:


If everything went well, you should see our newly added contact in your Salesforce DevOrg: --as you can see, inserting a salesforce object is as simple as creating a python object and running the beatbox 'create' method on it.

Updating a Contact Object

1. Next, let's try updating our inserted contact object. Grab the the Id of  our newly created contact and replace our create snippet with this one:

obj = { 'type': 'Contact', 'Id': '003900000102muQ', #Replace this with your contact Id 'FirstName': 'Jony', 'Title': 'His Majesty', 'Salutation': 'Dr' } result = svc.update(obj) if str(result[sf.success]) != 'true': print(result) else: print('Success!')

2. Again, run our script in the terminal:


This should be the result:

That concludes this post for now. As you can see, it's quite easy to manipulate salesforce data using beatbox. It also has a lot of other useful methods such as Query, Upsert and Delete. You can check it's docs for more details.

In the next post, we will try to import data from a rest service into salesforce while the script runs on a schedule job. Stay tuned!

New Sales Cloud Features for Salesforce Spring 14

As a continuation in the previous post about Salesforce Spring 14, we will highlight the new sales cloud features that will surely help in improving the profit of the company. Spring 14 offers new and exciting Sales cloud features that will help you easily manage your users and leads. 1. With Salesforce Spring 14, you can now link your Leads, Accounts, and Contacts to their Twitter profiles using Salesforce1. This will give you the ability to have more information about your customers and prospects, and will enable you to easily contact them. Moreover, Spring 14 can now give you the ability to call, log calls, and send emails to your Leads.

2. Multi-monitor components allow you to drag any portion of a console, and move it to any location. This allows multi-view of a user's interface, which allows you to easily edit a user's information.

3. Salesforce Spring 14 also gives you task flexibility as it offers repeating tasks feature. Once a task is completed or marked, it will recur depending on the number of days specified.

4. Salesforce for Outlook side panel can now give you the ability to create cases.

5. New custom object has been introduced, which is Orders. The object can be either added to a Contract or an Account. With this custom object, you can now process order management in Salesforce.

6. The forecasting feature has also been improved as it enables you to view up to four types of forecasts; namely, Opportunity splits based on revenue, Opportunities based on revenue, quantity, or both, and Product families based on revenue, quantity, or both.



Common Data Loader Errors


Data Loader helps in mass updating, inserting, upserting, deleting, and exporting your data. It is ideal for any organization that manages more than 50,000 records. As compared to Import Wizard, Data Loader supports more objects and can process more records. However, Data Loader is only available for Enterprise editions and above.

One of the most common cases being submitted to support pertains to common data loader errors. It is important to be familiarized with these common data loader errors in order to prevent it from impacting your business. For data that require immediate processing, it is pertinent to know the initial steps needed to be done.

Here are some of the common data loader errors:

1. Error: Row is larger than header - this means that there is a data in a field that has no header to be mapped. To resolve the issue, please make sure that your import file has a header, and map it to appropriate field upon doing the import.

2. Error: System.Exception: Too many SOQL queries - the error means that there is a trigger on the object and it is currently exceeding the governor limits. To resolve the issue, you can either modify the trigger or have support increase your API calls.

3. Error: Duplicate value found - this means that you are attempting to update a unique field. To resolve the issue, please ensure that the field/s you're attempting to update is/are not unique field/s. If they are unique fields, then you must enter a unique or different value. You can also consider temporary removal of a field's uniqueness while doing the update by clicking: Name | Setup | Customize | Object | Field | Click Edit on the field | Un-check "Do not allow duplicate values" | Save

4. Error: Owner ID: ID value of incorrect type - unlike Import Wizard, Data Loader requires Owner ID and not the record name to map the record owner.

5. Error: [INVALID_CROSS_REFERENCE_KEY].Messae [Customer Record Type: id value not valid for the users profile: xxxxxxxxxxxxx] - this error message usually appears when you are the record type being assigned to a user is not yet active on his profile. To resolve the issue, the following steps should be done: Click on Setup | Manage Users | Click on the profile that the record type needs to be added to | Scroll down to the Record Type Settings section | Click Edit on the Object | Select the specific record type in the list "Available Record Types" and add it to "Selected Record Types | Save

These are just one of the most common data loader errors. If you have other error messages to report, please feel free to comment on this website or contact us at

How to Enter Quotas in Salesforce?

forecast quota is the sales goal assigned to a user on a monthly or quarterly basis. Most of the common issues being received by Salesforce support is how to enter quotas in Salesforce CRM. Inputting quotas is sometimes confusing because it depends on the type of Forecasting that you are using. Collaborative Forecasting or F3 is the current recommended platform of for forecasting. It provides different features and functionality that are not present with Customizable Forecasting. Here are the features that Collaborative Forecasting offers:

> Custom Fiscal Year

>Opportunity - Level Adjustments

>Snapshots and Forecast History

>Territory Management

>Forecasting on Opportunity Splits

>Rename forecast categories

>Expandable Forecast Tables

In terms of how to enter quotas in Salesforce, there is also a big difference between using Customizable and Collaborative Forecasting.

If you are using Customizable Forecasting, then the Quotas can be manually inputted via User Detail page. Once the forecasting and quota are enabled, a "Quota" related list will appear in the User Detail page.

On the other hand, Collaborative Forecasting requires Data Loader to input the Quotas into the system. An excel file needs to be created every time quotas need to be inputted.

Although Customizable forecasting provides easy input of Quotas, you can should also consider the other features being offered by Collaborative Forecasting. To know more about the best type of Forecasting to be used for your organization, you may contact us at for assistance.


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

Local Name Fields - What Are They?

“Local Name field” is one of the least commonly used functionality in Salesforce. Some of the users might not be aware of it and its functionality. Although it is not commonly used, it could be considered in your organization for efficiency purposes. Here are some of the advantages of the feature:

  1. Local Name fields are additional standard fields that allow a translated version of text fields to be manually defined. These fields will remain unchanged even after changing your language. For example, when you changed your organization’s language from English to Spanish, these fields will remain in English.
  2. It helps in categorizing records in order to properly pull them up either via Search or Report. These fields could be used to filter the records for reporting purposes.
  3. It allows records to have two names. For example: Record A has local name field value of Record B. Whether you search for Record A or Record B, it will still pull up the same record.

Local Name fields are only available under Accounts, Contacts, and Leads; specifically, Account Name, Contact First Name, Contact Last Name, Lead Company Name, Lead First Name, and Lead Last Name.

These fields need to be enabled by Support. If you’re interested in maximizing the feature, then feel free to get in touch with Support. Once the feature is enabled, these fields are not visible by default, and needs to be manually added to the Page Layout and be visible by Field Level Security.

If you have further questions on how to maximize Local Name fields for your organization, feel free to contact us at

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:

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 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. 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 -

Spring 14 release notes -

Major Release Schedule -

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

Web-To-Lead Forms to Match Business and Personal Needs

web to lead image
web to lead image

How important it is for you to communicate with your friends and colleagues? How important it is for you to closely interact with your customers and prospects?

Technology has made lots of advancement these past few decades and one of which is the introduction of social media and social marketing. Getting in touch with your friends and interacting with your customers have been so easy, since they could easily be reached on-line.

Unlike before, there’s no need for you to print out fliers to promote your business. Unlike before, you no longer need a postman to deliver and receive your mails. Since most of the people are updated with the current trends, it is important to maximize the opportunity to interact with them closely through the channels where they are, most of the time, available.

It is not surprising that Salesforce would be able to help you achieve this goal. As an online CRM tool, Salesforce offers wide variety of functionality and features that could help you interact and collaborate with your customers; easily promote your products; and easily create a portal where your friends could easily contact and get in touch with you.

Web-to-Lead could help you maximize your online marketing strategy. Web-to-Lead is a Salesforcefunctionality that would allow you to generate HTML codes that you could integrate with your website in order to create an online form where your customers or viewers could fill-out to easily get in touch with you. Each submitted form will automatically create new Salesforce record and a notification email would also be sent to you.

Here are the easy steps needed to get started with the Web-to-Lead functionality:

1. Determine your Default Lead Owner. Your Default Lead Owner will automatically own newly created Leads from your online form and would be notified every time a Lead is created. To assign a Default Lead Owner: Name | Setup | Customize | Lead | Settings | Edit.

2. Generate a Web-to-Lead form: Name | Setup | Customize | Lead | Web-to-Lead | Create Web-to-Lead Form | Determine the fields that would be available in the form | Specify the return URL | Click Generate

3. You could also create an Assignment Rule to automatically route the newly created Leads on specific queues depending on your criteria.

4. Integrate Web-to-Lead form into your website.

For business purposes, your Web-to-Lead form would make it easy for your customers to get in touch with you because they don’t have to manually send you an email; they could easily contact you by just filling out the form. You could also easily determine which of your prospects or customers need to be contacted immediately because they could be sorted by queues. A report could also be generated to know how effective your ad is; how many prospects are inquiring; and how many customers do you currently have.

For personal purposes, these web-to-lead forms could be integrated into your blogs (Tumblr, Blogspot, WordPress, etc.). This would allow your followers to easily get in touch with you. If you’re a site administrator, it would be easy for you to respond to each visitor, because again, all submitted forms could be assigned to a specific queue depending on your assignment rule.

If you would like to know more about Web-to-Lead forms; specifically, customizing your HTMLcodes and integrating it into your website, please feel free to get in touch with us by emailing us at or fill out our online form at