Service selection policy script example

This section includes examples of Service Selection policy scripts.

Service selection based on family name

The following script returns a service instance based on the family name of the account owner. Other person attributes such as job title and location can be used to select service, as in this example.

function selectService() { 
  var sn = subject.getProperty("sn")[0]; 
  var serviceInstance = null; 
  if(sn=="Jones") { 
    serviceInstanceArr = ServiceSearch.searchByFilter(
      "(erservicename=NT40X)", 1); 

    if (serviceInstanceArr != null && serviceInstanceArr.length > 0) 
      serviceInstance = serviceInstanceArr[0]; 
  } else { 
    serviceInstanceArr = ServiceSearch.searchByFilter(
      "(erservicename=NT40Y)", 1); 

    if (serviceInstanceArr != null && serviceInstanceArr.length > 0) 
      serviceInstance = serviceInstanceArr[0]; 
  }
  return serviceInstance; 
} 
return selectService();

Searching for the closest service to the person

The following example searches for the service closest to the level of the person, based on the organization tree structure.

function selectService() {
  var services = ServiceSearch.searchForClosestToPerson(subject);
  
  if (services != null && services.length > 0) {
     return services[0];
  }
}
return selectService();