MicrosoftPremier / VstsExtensions

Documentation and issue tracking for Microsoft Premier Services Visual Studio Team Services Extensions
MIT License
56 stars 14 forks source link

Create Work Iem: Cannot Read Property Type in Duplicate Key Field when Description=$(System.DefinitionName) #212

Closed DataGeek09 closed 11 months ago

DataGeek09 commented 1 year ago

I get a "Cannot read property ‘referenceName’" error when trying to add a key field in the Duplicates parameter. The criteria under key fields checks for any “description” that contains $(System.DefinitionName).

Example: Description=$(System.DefinitionName)

I’ve also tried $(SYSTEM_DEFINITIONNAME), System.DefinitionName

ReneSchumacher commented 1 year ago

Hi @DataGeek09,

could you please run your pipeline again with the variable System.Debug set to true and send the task log to PSGerExtSupport@Microsoft.com? I will then take a look at the debug data to figure out what's going on.

ReneSchumacher commented 1 year ago

Oh, after rereading your description, I believe I know where the issue is coming from. Did you put Description=$(System.DefinitionName) into the keyFields parameter? That would probably provoke this error (even though we should have caught that and given a nicer error message).

Key fields must be a list of field names. The task cannot compare key fields to arbitrary values. The task simply creates the work item in memory with all fields populated and then creates a query that looks similar to SELECT * FROM WorkItems WHERE [key field name] = [value of the in-memory work item]. I.e., we compare the values of the newly created items with existing items, and if we find existing items we assume these are duplicates.

DataGeek09 commented 1 year ago

I appreciate the quick response! So there's no way to utilize the duplicate parameter to check if the work item description contains certain variables or contain certain words? I'm essentially trying to reference a constant variable (Source Name) in the description or Title to avoid a duplicate work item when a job fails with the same error as the previous run.

Additional context: I want to be able to have the initial release date/time the pipeline ran in the Title of the initial work item, however, if the scheduled release runs 4 hours later with the same failure, the current logic looks at the Title, compares the date/time variable, and won't consider it a duplicate since the most recent release has a different run time. To avoid the duplication, I need to reference a Constant variable unique to that source without creating a duplicate when the only variance is the release date/time.

ReneSchumacher commented 1 year ago

Hi @DataGeek09,

sorry for the slow response, I have been out of office for a couple weeks. Unfortunately, there is no way to check for an arbitrary value to search for duplicates. In the end, the idea was to prevent the exact same item (except for ID) to be created. Thus, the search logic is mostly defined by the task itself and we only allow users to specify fields of interested for them (otherwise, fields like CreatedDate and other internal fields would always differ).

We could probably build something more elaborate. However, the task is not meant to be used to update any given work item. This would better be put in a separate task. Could you put the source name in a different field in the work item and check based on that?

ReneSchumacher commented 11 months ago

Hi again,

we have now implemented more complex update rules, which also allow checking for specific values. Since we have also introduced a couple breaking changes, the new feature is only available in v2.x of the task.