Update Application Code

With our new mobilecaddy1__Expense_Type__c field available on SFDC we now want to update our client code to make use of this field. We will make changes to 2 areas of code;

  1. The UI Template – To display an input for this new field on the Create New Expense screen of our application.
  2. The associated angular controller that handles the submission of a new expense.

Firstly we want to run make sure that we are running our application with the mobilecaddy serve command, if you are not then move to the directory root of your project and run the following command.

Not only will this start our application but it will also start a grunt watch task on our working files. This means that any change to our code will result in JS task manager running a useful set of tasks. These include the following if they are needed;

  • JS Hinting on our JS
  • SASS processing
  • File copying
  • Application bundle creation

Updating the UI Template

Add the highlighted lines below to the www/templates/projectTimeExpNew.html template file. The additional lines are just adding markup to show an HTML label and an input element that are associated to the expenseType angular value.

Updating our Controller

The controller for new expenses (NewExpenseCtrl) includes a submitForm function that creates a new varNewExp object and calls our ProjectService’s newExpense function, passing this object in. Add a single line (as highlighted below) to the www/js/controllers/newExpense.controller.js file to use this new value from the HTML form and pass it into the object that would end up being inserted into the SmartStore.