Currently, im building a script to search the config item based on Warranty Expiration Data
Based on /opt/otrs/Kernel/System?ITSMConfigItem.pm ( ConfigItemSearchExtended()), here my code..
However, it returns nothing..perhaps some code error under 'What' param.
If i remove the 'What' param which i believe looking a value in XMLDATA, yeah it return the config item ID
Code: Select all
my $ConfigItemIDs = $ConfigItemObject->ConfigItemSearchExtended(
#Number => 'The ConfigItem Number', # (optional)
#Name => 'The Name', # (optional)
ClassIDs => [22], # (optional)
#DeplStateIDs => [1, 2, 3, 4], # (optional)
#InciStateIDs => [1, 2, 3, 4], # (optional)
What => [ # (optional)
# each array element is a and condition
{
# or condition in hash
"[%]{'Version'}[%]{'WarrantyExpirationDate'}[%]{'Content'}" => '%18/09/2019%',
},
],
);
Below is the original code snippet taken from ITSMConfigItem.pm
Code: Select all
my $ConfigItemIDs = $ConfigItemObject->ConfigItemSearchExtended(
Number => 'The ConfigItem Number', # (optional)
Name => 'The Name', # (optional)
ClassIDs => [9, 8, 7, 6], # (optional)
DeplStateIDs => [1, 2, 3, 4], # (optional)
InciStateIDs => [1, 2, 3, 4], # (optional)
# config items with created time after ...
ConfigItemCreateTimeNewerDate => '2006-01-09 00:00:01', # (optional)
# config items with created time before then ....
ConfigItemCreateTimeOlderDate => '2006-01-19 23:59:59', # (optional)
# config items with changed time after ...
ConfigItemChangeTimeNewerDate => '2006-01-09 00:00:01', # (optional)
# config items with changed time before then ....
ConfigItemChangeTimeOlderDate => '2006-01-19 23:59:59', # (optional)
What => [ # (optional)
# each array element is a and condition
{
# or condition in hash
"[%]{'ElementA'}[%]{'ElementB'}[%]{'Content'}" => '%contentA%',
"[%]{'ElementA'}[%]{'ElementC'}[%]{'Content'}" => '%contentA%',
},
{
"[%]{'ElementA'}[%]{'ElementB'}[%]{'Content'}" => '%contentB%',
"[%]{'ElementA'}[%]{'ElementC'}[%]{'Content'}" => '%contentB%',
},
{
# use array reference if different content with same key was searched
"[%]{'ElementA'}[%]{'ElementB'}[%]{'Content'}" => ['%contentC%', '%contentD%', '%contentE%'],
"[%]{'ElementA'}[%]{'ElementC'}[%]{'Content'}" => ['%contentC%', '%contentD%', '%contentE%'],
},
],
PreviousVersionSearch => 1, # (optional) default 0 (0|1)
OrderBy => [ 'ConfigItemID', 'Number' ], # (optional)
# default: [ 'ConfigItemID' ]
# (ConfigItemID, Number, Name, ClassID, DeplStateID, InciStateID,
# CreateTime, CreateBy, ChangeTime, ChangeBy)
# Additional information for OrderBy:
# The OrderByDirection can be specified for each OrderBy attribute.
# The pairing is made by the array indices.
OrderByDirection => [ 'Down', 'Up' ], # (optional)
# default: [ 'Down' ]
# (Down | Up)
Limit => 122, # (optional)
UsingWildcards => 0, # (optional) default 1
);