PhoneGap build processIn this post, we will modify several Java and HTML files to correctly map for the Product object in your Salesforce account. If you haven’t done so, yet, now would be a good time to review my previous post, where that’s explained in detailed.

First we need to modify the Activity file , on my example It is called:

  1. Change the code to contain the next structure and save it:
  1. Before changing the HTML code, it is important to verify that you have your free Salesforce development account. You have to make sure you have the Product custom object already created to be able to continue with this tutorial. The Product custom object should have at least the Price field in it.
  2. You should have something pretty similar to this in your Salesforce account.
  3. PhoneGap build process

  4. If you have that object like that, then you are ready to keep going. If not, follow the tutorial.
  5. Inside Salesforce we have to prepare a Remote Site which will provide the way to get communicated using oAuth. Follow the next simple steps
    1. Go to Remote Access
    2. Create a new remote access. Specify the next required fields.
    3. After clicking on Save, you will get a very important string code.
    4. That Consumer Key will be used in our PhoneGap application to get authenticated using Salesforce.

Modifying the HTML and JS Files

Now it is time to modify the HTML file called Index.html. It includes the code from metadaddy-sfdc, but we are going to modify it to be able to run on Android and to use our own Salesforce account by mapping the Product custom object.

  1. Open the Index.html and edit the tag with the next code:

Note: I have modified the original source file to use the correct method names that work with Android versions.

  1. It is very important that you change the clientIdwith the consumer key you got from Saleforce while creating the remote Access.
    var clientId =    ‘3MVG9yZ.WNe6byQDOtUfpo5TK.XDRz4.G9p3O3QytKIJraSlaz8ix4Yqm6VRmzDW3csPF_vQ9oSBQq82hHFRs’;
  2. Save the file.
  3. Now modify the tag with this code and save the file
  1. Open the mobileapp.js SPAN. We are going to modify some methods that will provide the product list, we won