See below. The trigger fires when either resolve date or close date are set.
OBJECT cr {
TRIGGERS {
PRE_VALIDATE zcrHasNoUnclosedCR(id) 199
FILTER( resolve_date { -> NOT_NULL } || close_date { -> NOT_NULL } );
} ;
} ;
OBJECT cr {
FACTORY {
METHODS {
zcrHasNoUnclosedCR(int) ;
} ;
} ;
} ;
////////////////////////////////////////////////////////////////////////////
//
// Before accepting a resolve_date update, check that the CR has no unresolved CRs as children.
////////////////////////////////////////////////////////////////////////////
#define ZDEBUG 1
//
cr::zcrHasNoUnclosedCR(...)
{
string method;
method = "cr::zcrHasNoUnclosedCR";
string zError;
// Args: id
int in_id;
in_id = (int)argv[3];
zError = "";
if (ZDEBUG > 0) logf(INFO, "%s entered, CR id %d", method, in_id);
//
//Get unresolved cr's having this CR's persid as 'parent'.
//
string wc1;
wc1 = "parent like '" + format("cr:%d", in_id) + "' AND (status.active = 1 and status.resolved != 1)";
logf(INFO, "%s, wc1: %s", method, wc1);
send_wait(0, top_object(), "call_attr", "cr", "sync_fetch", "STATIC", wc1, -1, 0);
if (msg_error())
{
logf(ERROR, format("%s:ERROR sync_fetch 'cr' '%s'", method, msg[0]));
set_return_data(FALSE);
}
int iCount1;
object domset1;
domset1 = msg[0];
iCount1 = msg[1];
if (iCount1 == 0) logf(INFO, "%s: domset 'cr' is empty", method);
logf(INFO, "%s: iCount1=%d", method, iCount1);
if (iCount1 <= 0 )
{
logf(INFO, "%s: cr has NO unclosed CRs, condition is TRUE", method);
return;
}
else
{
logf(INFO, "%s: cr has at least one unclosed CR, condition is FALSE", method);
zError = "Cannot resolve or close a Request/Incident/Problem while a linked Req/Inc/Prb is unresolved";
set_error(1);
set_return_data(zError);
return;
}
return;
}
Hope that helps.