You are not logged in. Click here to log in.

codebeamer Application Lifecycle Management (ALM)

Search In Project

Search inClear

Tags:  not added yet

Example custom script to find tracker items having a specific field value

package config.scripts.workflow

import com.intland.codebeamer.event.util.VetoException
import com.intland.codebeamer.manager.*

if (!beforeEvent) {
   return; // do NOTHING on after-event, everything is handled in the before-event
}

// Acquiring the cbQL Manager from codeBeamer
cbQLManager = applicationContext.getBean(CbQLManager.class)

// Parameters of a custom field
def projectId = 280
def trackerId = 35774
def fieldProperty = "customField[1]"

// Desired value of the custom field
def fieldValue = 3

// Query string to find all tracker items having the desired value on the field
def cbQL = "project.id IN (${projectId}) AND tracker.id IN (${trackerId}) AND '${trackerId}.${fieldProperty}' = ${fieldValue}"

// Extracting the tracker item list
trackerItemQueryResult = cbQLManager.runQuery(event.getRequest(), cbQL, new CbQLManager.PagingParams(5, 0));
trackerItemsPage = trackerItemQueryResult.getTrackerItems();
trackerItems = trackerItemsPage.getList();

// Some action
throw new VetoException(trackerItems.get(0).toString())