Post

2 followers Follow
0
Avatar

Use custom field in WHERE condition

Is it possible to use a custom field in a WHERE condition? I'd like dictionary elements to be listed with my use case and I tried the following where $SourceSystem is a value I set in my use case:

$repeatUseCases

$repeatDictionarySortName where Name = $SourceSystem

$SourceSysem would match the name of my dictionary item.
Any help would be appreciated.

Thanks

Derrick Bell

Please sign in to leave a comment.

4 comments

0
Avatar

This can certainly be done, Derrick, though there's a slight problem with the context here. As you've written this, the where clause is trying to match the name of your dictionary term to $SourceSystem, which doesn't quite work out since $SourceSystem is a custom field on the use case. The contexts aren't the same, so there's a disconnect and the comparison never matches up.

In order to use a value from a different context ($SourceSystem on your use case) in the where clause for definitions, we've got to set up a variable. Doing this within the context of your use case, you can then carry that over to the new context and use it in the where clause.

Details are in section 5.10 of the custom reports guide, but something like this should work:

$repeatUseCases
$set $$DictName $SourceSystem
$repeatDictionarySortName where Name = $$DictName

Permanently deleted user 0 votes
Comment actions Permalink
0
Avatar

I'm still having a little trouble here and I think is because of the context issue you mentioned. I wanted to insert the dictionary element associated with my use case as I was listing all of my use cases. Here is an example that doesn't work:
$repeatUseCases
$Name($ID)
$set $$DictName $SourceSystem
$repeatDictionarySortName where Name = $SourceSystem
$repeatFields
$Name
$endrepeatFields
$endrepeatDictionarySortName
$endrepeatUseCases

Derrick Bell 0 votes
Comment actions Permalink
0
Avatar

You're almost there, Derrick. If you'll notice my sample, the where clause is testing for the variable that was assigned the $SourceSystem value in the context of your use case, but yours is still looking at $SourceSystem itself. i.e., "where Name = $SourceSystem" instead of "where Name = $$DictName".

Also, $endrepeatDictionarySortName is too much - take off the SortName, or you'll wind up with some extra, funny-looking text in your report.

And finally, I'm so sorry - I gave the wrong keyword to you yesterday. $Dictionary doesn't work in the context of a use case - use $DomainObjects instead. So, with your example, that would be as so:

$repeatUseCases
$Name($ID)
$set $$DictName $SourceSystem
$repeatDomainObjectsSortName where Name = $$DictName
$repeatFields
$Name
$endrepeatFields
$endrepeatDomainObjects
$endrepeatUseCases

Permanently deleted user 0 votes
Comment actions Permalink