How to add Previous revision item and remove current from relationship

Hi Experts,

I am trying to remove Document which is attached to Part with revision 001 and attach Document with revision 000(old revision).

I have created an action on Part Document relationship.

I'm getting the old revision item id i.e Document id, after getting this ID I'm trying to create a relationship between Part and Document with below code.

var newPartDocRelItem = inn.newItem("Part Document", "add");

newPartDocRelItem.setProperty("source_id",parentPartID);

newPartDocRelItem.setProperty("sort_order", sort_order);

newPartDocRelItem.setProperty("related_id",oldItemID);

newPartDocRelItem = newPartDocRelItem.apply();

But, above code will add the same item i.e item with revision 000

I have also tried this code

var newPartDocRelItem = inn.newItem("Part Document", "add");

newPartDocRelItem.setProperty("source_id", parentPartID);

newDocItem = inn.newItem("Document", "get");

newDocItem.setProperty("id", oldItem);

newPartDocRelItem.setRelatedItem(newDocItem);

newPartDocRelItem = newPartDocRelItem.apply();

Still I'm not able to add the relationship with previous revision, Document with 001 revision gets added