Programmatically add a reference between two content items

I have a workitem schema and a riskassessment schema with a bidirectional reference association. I’ve written a custom command handler that will detect that a user has added an instance of the risk assessment to the work item, and will add a reference from the risk assessment back to the work item. The code gets executed and no exceptions are being thrown, but the reference does not seem to be added when I open up the risk assessment content item in the UI. Am I doing something wrong?


I have to debug through it. It looks okay, but I would not change the data, it is not thread safe. It is better to create a clone first.

I’ll try cloning the Data properties when building a new command.


I simplified the example a little bit for my test and this works:

Awesome. I’ll try that after the weekend and let you know whether I managed to get it to work as well.

1 Like

I have it working now. Thanks for all your work. I’ve also refactored it significantly to demonstrate to my colleagues how you can encapsulate the content into something that looks a bit more like a domain. See

1 Like