findByCompositeIdentifier() rejects default values for caseIdentifier attributes

findByCompositeIdentifier() rejects default values for caseIdentifier attributes

book

Article ID: KB0074983

calendar_today

Updated On:

Products Versions
TIBCO BPM Enterprise (formerly TIBCO ActiveMatrix BPM) 4.x

Description

Suppose a case class has multiple identifier fields  (non-identifier attributes are elided)
CustomerChatHistory::
    CustomerId : text(20), no default
    ChatNumber : integer, default = 1
    CommentNumber : integer, default = 1

    ...
It's not necessary (or productive) to set default values for case identifier attributes in the model.
Setting the initial identifying values for each new instance is an implementation detail;  the required logic or rules will be expressed in code and/or documented appropriately, as required.
Having declared default values, we cannot use findByCompositeIdentifier() API to locate a case whose identifiers include any default values!
When called, this API checks that values were provided for all caseIdentifier attributes;  it (wrongly) infers that a default-value argument means "not set", so rejects the search attempt.
Symptoms:
JavaScript function findByCompositeIdentifier() fails,with root cause:
cause: javax.script.ScriptException: com.tibco.n2.javascript.WrappedException: Wrapped com.tibco.bds.services.CaseDataAccessFault: com.tibco.bds.common.exception.BDSDAMissingCIDORSearchableAttributeException: BDS DA: Finding by CID an object with composite CIDs requires all CIDs to be specified

Issue/Introduction

Composite Identifier values provided to findByCompositeIdentifier() must not be the Default Value specified for that attribute in the Case Model.

Environment

Primary Product Name : TIBCO ActiveMatrix BPM Product Version : 4.1, 4.2, 4.3 Additional Product 1 Name : TIBCO Business Studio - BPM Edition Additional Product Version : 4.1, 4.2, 4.3

Resolution

Preferred:
1. Remove any default values specified on caseIdentifer attributes of Case Classes
  Note: this is not considered a destructive change.
2. Rebuild & deploy the case model
3. Rebuild & deploy dependent applications
Alternative:
Guard against this in javascript, use alternative API when the lookup is for an item that has any default value:
//...
/* findByCompositeIdriteria does not like model-default values */
if (searchChatNumber!=1 && searchCommentNumber!=1){
    foundRefs= CAC.findByCompositeIdentifier(customerId, searchChatNumber, searchCommentNumber);
}else{
    foundRefs= CAC.findByCriteria('CustomerId="'+customerId+'" and ChatNumber='+searchChatNumber+' and CommentNumber='+searchCommentNumber);
}
//...