Where a new case should be created, do NOT select a category. Click the Script browse button and use the script below.
dim IxDataCaseHeader
dim CreateParams(0)
CreateParams(0) = "IndexData" ' we want an index data object - currently that's the only one supported
dim CreateParamsVar
CreateParamsVar = CreateParams
' Create an index data object
set IxDataCaseHeader = CreateThereforeObject(CreateParamsVar)
' Set which case definition we want to use. Either the CaseDefNo or the CaseDefName.
' Please note: if the Case definition name is not unique (can be with TF2014) it will take the first case definition found.
IxDataCaseHeader.SetCaseDef("TestCase")
' set the case header fields - this can only be done with the SetField function.
' Change this to your fields
'IxDataCaseHeader.SetField "<the column name>", "<the value to set>"
IxDataCaseHeader.SetField "CaseHeaderData1", "My case header data 1"
IxDataCaseHeader.SetField "CaseHeaderData2", "My case header data 2"
IxDataCaseHeader.SetField "CaseNumberData1", 9001
' SearchCase(true) - Will return either 0 for no case found or the CaseNo if a case was found, when multiple cases are found, will return the CaseNo of the first case.
' SearchCase(false) - The same as above, but will return -1 when multiple cases are found instead of the CaseNo of the first case found.
nCaseNo = IxDataCaseHeader.SearchCase(true)
if nCaseNo > 0 then
' A case with this index data exists already
' Don't create a new case - use existing
SetCaseNo(nCaseNo)
elseif nCase = 0 then
' No case was found with this index data
' Create a new case
nCreatedCaseNo = IxDataCaseHeader.CreateCase
SetCaseNo(nCreatedCaseNo)
elseif nCase = -1 then
' This can only happen if you use SearchCase(false) instead of SearchCase(true)
' This means that multiple cases with this index data were found.
' You could throw an error in this case for example
ScriptError("Multiple cases found.")
end if
|