< Previous | Next >

Create Ajax services

In this lesson, you create Ajax services that create the data that the process uses. You then configure coach views to call these services.

Before you begin

The following coach views use an Ajax service to populate one or more of its controls:
  • Person CV
  • Position CV
  • Requisition CV

About this task

The coach views in My Hiring Sample display data to the hiring manager and to the general manager (GM). This lesson describes how to create the data and configure the coach view controls to display it.
This lesson uses the following concepts:
Concept Description
Ajax services A service that asynchronously sends or retrieves data from a data source, such as a database.

Procedure

Create an Ajax service:

  1. Make sure that the My Hiring Sample process application is open in Process Designer.
  2. In the Designer library, click the plus sign next to User Interface and select Ajax Service.
    Shows the Ajax Service option in the New User Interface menu.
  3. Type Populate DepartmentList and then click Finish. You can now edit the Ajax service that you created.
  4. Set the input and output of the service:
    1. Select the Variables tab.
    2. Click Add Input. In the Name field, type text. For the type, use the default type, which is String.
    3. Click Add Output. In the Name field, type results.
    4. For the variable type of the output, click Select and then select the ANY type from the list. By selecting ANY, you are setting the output to be of any type.
    5. Select Is List so that service returns a list of items.
    The Populate DepartmentList service input and output variables with the results variable selected.
  5. Create the service flow:
    1. Click the Diagram tab and then, from the palette, add a server script to the process diagram and rename it to populateDepartmentList.
    2. In the Properties tab, select Implementation and add the following code:
      tw.local.results = new tw.object.listOf.String();
      tw.local.results[0] = "Finance";
      tw.local.results[1] = "Marketing";
      tw.local.results[2] = "Product Development";
      tw.local.results[3] = "Human Resources";
      tw.local.results[4] = "Sales";
      tw.local.results[5] = "Customer Service";
      tw.local.results[6] = "Business Partner Service";
      tw.local.results[7] = "Business Strategies";
      tw.local.results.listAddSelected(0);
    3. In the palette, select the Sequence Flow tool icon Sequence flow tool. Make the following connections:
      • Start event to the populateDepartmentList server script
      • populateDepartmentList server script to the End event
  6. Save your work.
  7. Configure the Department stock control so that it uses the Ajax service to get its contents.
    1. Open the Requisition CV coach view and select the Department control.
    2. In the Configuration properties, click Select for the selection service. Select the Populate DepartmentList Ajax service.
      Configuration properties of the Department control with its selection service set to the Populate DepartmentList service
  8. Create the other Ajax services with the information in the following table:
    Service name Script in the service Script code
    Populate EmploymentTypeList populateStatusList
    tw.local.results = new tw.object.listOf.String();
    tw.local.results[0] = "Full-time";
    tw.local.results[1] = "Part-time";
    tw.local.results[2] = "Contract";
    tw.local.results.listAddSelected(0);
    Populate LocationList populateLocationList
    tw.local.results = new tw.object.listOf.String();
    tw.local.results[0] = "Atlanta";
    tw.local.results[1] = "Boston";
    tw.local.results[2] = "Chicago";
    tw.local.results[3] = "Cincinatti";
    tw.local.results[4] = "Dallas";
    tw.local.results[5] = "Denver";
    tw.local.results[6] = "Des Moines";
    tw.local.results.listAddSelected(2);
    Populate PositiontypeList populatePositionTypeList
    tw.local.results = new tw.object.listOf.String();
    tw.local.results[0] = "New";
    tw.local.results[1] = "Existing";
    tw.local.results.listAddSelected(0);
  9. Configure the stock controls that use a service to get their content. The following table lists these stock controls and the Ajax service that you select for the Selection Service configuration option:
    Coach view Stock control Service name
    Position CV Position type Populate PositiontypeList
    Requisition CV Location Populate LocationList
    Requisition CV Employment status Populate EmploymentTypeList

Lesson checkpoint

You created Ajax services and configured the select controls to use the services to get data.

In this lesson, you learned
  • How to create an Ajax service
  • How to configure a coach view to use that Ajax service

In the next lesson, you add validation to the Create Requisition Coach.

Related Links

< Previous | Next >