How can we remove NULL relationships when versioning an Item via Method?

Hi community,

has somebody a solution for a following use case? I want to version an Item by Method (either Javascript or CSharp). In the new item version some NULL relationships shall be automatically removed.

I use something similar like this. In my case I don´t use Part, so I am not sure if this one would work in reality. But I hope somebody can help me to find the missing piece:

var myItem = aras.IomInnovator.getItemById("Part",this.getProperty("id"));
myItem.fetchRelationships("Part Goal");
myItem.setProperty("description","i am new");

var relCosts = myItem.getRelationships("Part Goal");

for (var i = 0; i < relCosts.getItemCount(); i++)
  var singleGoal = relCosts.getItemByIndex(i);
myItem = myItem.apply();

Thanks already for every ideas!