abapero
abapero

Reputation: 133

Tridion - Move component to another folder

I want to move one component from one folder to another folder already created.

while (textReader.Read())
{
    textReader.MoveToElement();
    Component comp = tdse.GetComponent(textReader.GetAttribute("ID"), constant_Publication, true, -1);
}

I try looking for comp.Move but it doesn't exits. Also, i saw that in comp.Info.Path there is the path, but if i try to modify it i have the following error :

Error 7 Property or indexer 'Tridion.ContentManager.Interop.TDS._Info.Path' cannot be assigned to -- it is read only.

What can i do to move the component?

Upvotes: 2

Views: 286

Answers (2)

Chris Summers
Chris Summers

Reputation: 10163

It looks like you are using TOM rather than TOM.NET

You need to perform a paste action with the folder you want to get the new item into

Something like

objFolder.PasteItem(comp, 1, false)

The first parameter is the item you want to paste, the second is an enumerator (EnumTDSCutCopyAction - 1 is cut (move), 0 is copy ) to say if you want to Copy and Paste or Cut and Paste, and the final one is whether you want to assert a unique name.

In TOM.NET there is a RepositoryLocalObject.Move() method.

Upvotes: 4

Nickoli Roussakov
Nickoli Roussakov

Reputation: 3409

It appears that your GetObject() method call has some missing arguments. The templating manual states the folloowing:

Public Function GetObject( ByVal URI As String, ByVal mode As TDSDefines.EnumOpenMode, Optional ByVal contextPublication As Variant = TDSDefines.URINULL, Optional ByVal filter As TDSDefines.XMLReadFilter = XMLReadNull ) As Object

However it appears that the second argument you're passing in is a publication ID, not the EnumOpenMode. Pass "OpenModeEditWithFallback" as the second argument to the function to get the component in write mode and you should be able to use the Move function on it afterwards.

Also, please consider posting further Tridion questions on our new Tridion side http://tridion.stackexchange.com

Upvotes: 1

Related Questions