Skip to content

Assignment Manager Bookshelf App

Developing and Deploying Siebel Business Applications > Assigning Objects and Automating Business Processes >

Customizing How Siebel CRM Assigns Objects

This task is a step in Roadmap for Developing a Siebel Application.

In this topic, you create an assignment rule that assigns opportunities to agents depending on the ZIP code. When a user creates a new opportunity, NREC requires Siebel CRM to automatically assign the opportunity to an NREC agent or a partner agent according to the ZIP code. Siebel CRM must assign the opportunity to the real estate agent whose sales region includes the ZIP code that is specified in the Zip Code field.

Siebel Assignment Manager is a Siebel CRM feature that allows you to assign the most qualified person to a specific task. To accomplish this, Assignment Manager matches candidates to assignment objects. To assign the most qualified candidate to each object, Assignment Manager applies assignment rules that you define. You can specify how Siebel CRM uses Assignment Manager to evaluate a record. You can configure Assignment Manager to make assignments in the following ways:

  • Interactively in real time
  • Dynamically when the user makes a database change
  • Periodically in batches

For more information, see Siebel Assignment Manager Administration Guide.

To customize how Siebel CRM assigns objects

  1. Create an assignment rule:
    1. Log in to the Siebel client as an administrator, navigate to the Administration - Assignment screen, and then the Assignment Rules List view.

      For more information, see Logging In as the Siebel Administrator.

    2. In the Assignment Rules List, click Menu, and then choose the Columns Displayed menu item.
    3. In the Columns Displayed dialog box, make sure the Assignee Filter column is included in the Selected Columns window, and then click Save.
    4. In the Assignment Rules List, click New.
    5. Enter a new record using values from the following table.





      San Francisco

      Enter a unique name for the rule.



      To choose the object Siebel CRM must assign, do the following:

      • In the Objects to be Assigned field, click the select button.
      • In the Assignment Object dialog box, click New.
      • In the Name window, choose Opportunity and then click Save.
      • Click OK.

      Rule Group

      Default Rule Group

      Not applicable.

      Minimum Score


      Although NREC does not require scoring, you must enter a value.

      Assignee Filter

      All Above Minimum

      Choose the filter from the list. This filter causes Siebel CRM to assign all assignees who possess an assignment score that is greater than or equal to the minimum score of the assignment rule.

      For more information, see Siebel Assignment Manager Administration Guide.

  2. Specify assignment criteria and values:
    1. In the Assignment Rules List, in the Name field, click San Francisco.

      This is the rule you created in Step d.

    2. In the Criteria list, click New, and then define fields values from the following table.

      Siebel CRM uses the criteria to determine which candidates qualify to receive the assignment. In the NREC example, the criteria compares the ZIP code of an opportunity to the ZIP codes that constitute the region that the agent covers.




      Rule Criterion

      Prospect ZIP code

      Choose the type of criteria.

      Comparison Method

      Compare to Object

      Choose the method that Siebel CRM uses to match objects to candidates. For example, Compare to Object compares the criteria value to an object attribute.



      Choose the method that Siebel CRM uses to match criteria values and candidates.



      Determines whether the criteria is required.



      If the candidate satisfies this criteria, then Siebel CRM adds this score to the total score for the candidate.

    3. In the Values list, add a new record for each ZIP code included in this assignment rule using values from the following table.

      Siebel CRM displays the Values list below the Criteria list. In this list you specify values or a range of values for a given criterion. Siebel CRM uses these criteria values for comparison. In the NREC example, the ZIP codes that are in a particular territory are the values for the assignment criteria.


      Zip Code

      Leave empty


      Leave empty


      Leave empty


  3. Add positions to the assignment rule:
    1. Click the Position Candidates view tab.
    2. In the Position Candidates list, click New.
    3. In the Add Positions dialog box, in the Find window, choose Position.
    4. In the Starting With window, enter click Go, and then click OK.
    5. Repeat Step c for the NREC Partner Agent position.

      Each rule must include a list of positions, employees, or organizations that specifies the candidates for the assignment. In the NREC example, the position determines the assignment. Each assignment rule is associated with a position at NREC or at the partner real estate agency. For example, the positions at the San Francisco Real Estate Agency are associated to the assignment rule for the Peninsula and East Bay territories.

  4. To add rules for the Peninsula and East Bay territories, repeat Step 1 through Step 3 for each of the following assignment rules.

    Assignment Rule Name

    Zip Code


    Add the following ZIP codes:

    East Bay

    Add the following ZIP codes:

  5. Navigate to the Assignment Rules List, and then click Release.

    This step instructs Assignment Manager to use these rules.

    NOTE:  This step releases all assignment rules. Do not release assignment rules while associated server tasks are running.

  6. Activate Assignment Manager rules.


Bookshelf is a JavaScript ORM for Node.js, built on the Knex SQL query builder. Featuring both promise based and traditional callback interfaces, providing transaction support, eager/nested-eager relation loading, polymorphic associations, and support for one-to-one, one-to-many, and many-to-many relations.

It is designed to work well with PostgreSQL, MySQL, and SQLite3.

Website and documentation. The project is hosted on GitHub, and has a comprehensive test suite.


This project is currently undergoing some changes. You may want to read the discussion about the future of bookshelf.js on GitHub.


Bookshelf aims to provide a simple library for common tasks when querying databases in JavaScript, and forming relations between these objects, taking a lot of ideas from the the Data Mapper Pattern.

With a concise, literate codebase, Bookshelf is simple to read, understand, and extend. It doesn't force you to use any specific validation scheme, provides flexible and efficient relation/nested-relation loading, and first class transaction support.

It's a lean Object Relational Mapper, allowing you to drop down to the raw knex interface whenever you need a custom query that doesn't quite fit with the stock conventions.


You'll need to install a copy of knex.js, and either mysql, pg, or sqlite3 from npm.

The Bookshelf library is initialized by passing an initialized Knex client instance. The knex documentation provides a number of examples for different databases.

This initialization should likely only ever happen once in your application. As it creates a connection pool for the current database, you should use the instance returned throughout your library. You'll need to store this instance created by the initialize somewhere in the application so you can reference it. A common pattern to follow is to initialize the client in a module so you can easily reference it later:


Here is an example to get you started:


  • Registry: Register models in a central location so that you can refer to them using a string in relations instead of having to require it every time. Helps deal with the challenges of circular module dependencies in Node.
  • Virtuals: Define virtual properties on your model to compute new values.
  • Visibility: Specify a whitelist/blacklist of model attributes when serialized toJSON.
  • Pagination: Adds methods to use for pagination in place of and .
  • bookshelf-cascade-delete - Cascade delete related models on destroy.
  • bookshelf-json-columns - Parse and stringify JSON columns on save and fetch instead of manually define hooks for each model (PostgreSQL and SQLite).
  • bookshelf-mask - Similar to Visibility but supporting multiple scopes, masking models and collections using the json-mask API.
  • bookshelf-schema - A plugin for handling fields, relations, scopes and more.
  • bookshelf-signals - A plugin that translates Bookshelf events to a central hub.
  • bookshelf-paranoia - Protect your database from data loss by soft deleting your rows.
  • bookshelf-uuid - Automatically generates UUIDs for your models.
  • bookshelf-modelbase - An alternative to extend , adding timestamps, attribute validation and some native CRUD methods.
  • bookshelf-advanced-serialization - A more powerful visibility plugin, supporting serializing models and collections according to access permissions, application context, and after ensuring relations have been loaded.
  • bookshelf-plugin-mode - Plugin inspired by Visibility plugin, providing functionality to specify different modes with corresponding visible/hidden fields of model.
  • bookshelf-secure-password - A plugin for easily securing passwords using bcrypt.
  • bookshelf-default-select - Enables default column selection for models. Inspired by Visibility, but operates on the database level.
  • bookshelf-ez-fetch - Convenient fetching methods which allow for compact filtering, relation selection and error handling.


Have questions about the library? Come join us in the #bookshelf freenode IRC channel for support on knex.js and bookshelf.js, or post an issue on Stack Overflow or in the GitHub issue tracker.


Can I use standard node.js style callbacks?

Yes - you can call on any "sync" method and use the standard style callback interface if you prefer.

My relations don't seem to be loading, what's up?

Make sure you check that the type is correct for the initial parameters passed to the initial model being fetched. For example will not return the same as - notice that the id is a string in one case and a number in the other. This can be a common mistake if retrieving the id from a url parameter.

This is only an issue if you're eager loading data with load without first fetching the original model. should work just fine.

My process won't exit after my script is finished, why?

The issue here is that Knex, the database abstraction layer used by Bookshelf, uses connection pooling and thus keeps the database connection open. If you want your process to exit after your script has finished, you will have to call on the property of your instance or on the instance passed during initialization. More information about connection pooling can be found over at the Knex docs.

How do I debug?

If you pass as one of the options in your initialize settings, you can see all of the query calls being made. Sometimes you need to dive a bit further into the various calls and see what all is going on behind the scenes. I'd recommend node-inspector, which allows you to debug code with statements like you would in the browser.

Bookshelf uses its own copy of the "bluebird" promise library, you can read up here for more on debugging these promises... but in short, adding:

At the start of your application code will catch any errors not otherwise caught in the normal promise chain handlers, which is very helpful in debugging.

How do I run the test suite?

The test suite looks for an environment variable called for the path to the database configuration. If you run the following command: , replacing with the path to your config file, and the config file is valid, the test suite should run with npm test.

Also note that you will have to create the appropriate database(s) for the test suite to run. For example, with MySQL, you'll need to run the command in addition to exporting the correct test settings prior to running the test suite.

While it primarily targets Node.js, all dependencies are browser compatible, and it could be adapted to work with other javascript environments supporting a sqlite3 database, by providing a custom Knex adapter.

Which open-source projects are using Bookshelf?

We found the following projects using Bookshelf, but there can be more:

  • Ghost (A blogging platform) uses bookshelf. [Link]
  • Soapee (Soap Making Community and Resources) uses bookshelf. [Link]
  • NodeZA (Node.js social platform for developers in South Africa) uses bookshelf. [Link]
  • Sunday Cook (A social cooking event platform) uses bookshelf. [Link]
  • FlyptoX (Open-source Node.js cryptocurrency exchange) uses bookshelf. [Link]
  • And of course, everything on here use bookshelf too.