Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
IManExt.CopyNewVersionCmd displays "The parameter is incorrect" error
seanm
Hi
I am try to get the CopyNewVersionCmd command working, but keep getting the ever helpful "The parameter is incorrect" error. Below is my code, i'd guess that i'm missing a context item or one of them is wrong.
Anybody out there over come this little error before, if so i'd appreciate your help.
Thanks in advance.
ManDMS dms = new ManDMS();
IManSession ses = dms.Sessions.Add("BOB");
ses.TrustedLogin();
NRTDocument[] dox = new NRTDocument[1];
dox[0] = (NRTDocument)ses.Databases.ItemByName("BOB").GetDocument(272252, 1);
ContextItems ctx = new ContextItems();
ctx.Add("ParentWindow", this.Handle.ToInt32());
ctx.Add("SelectedNRTDocuments", dox);
CopyNewVersionCmd copyCmd = new CopyNewVersionCmd();
copyCmd.Initialize(ctx);
copyCmd.Update();
if ((CommandStatus)copyCmd.Status == CommandStatus.nrActiveCommand)
copyCmd.Execute();
Find more posts tagged with
Comments
seanm
FYI I've fixed this issue, here is a working code sample:
NB: This also makes the CopyNewVerOpenCmd command spring into life.
ManDMS dms = new ManDMS();
IManSession ses = dms.Sessions.Add("BOB");
ses.TrustedLogin();
NRTSession[] snx = new NRTSession[1];
snx[0] = (NRTSession)ses;
NRTDocument[] dox = new NRTDocument[1];
IManDatabase mdb = ses.Databases.ItemByName("BOB");
dox[0] = (NRTDocument)mdb.GetDocument(272252, 1).LatestVersion;
ContextItems ctx = new ContextItems();
ctx.Add("ParentWindow", this.Handle.ToInt32());
ctx.Add("DestinationObject", mdb);
ctx.Add("SelectedNRTDocuments", dox);
ctx.Add("SelectedNRTSessions", snx);
CopyNewVersionCmd copyCmd = new CopyNewVersionCmd();
copyCmd.Initialize(ctx);
copyCmd.Update();
if ((CommandStatus)copyCmd.Status == CommandStatus.nrActiveCommand)
copyCmd.Execute();
then clear up the interwoven objects using:
System.Runtime.InteropServices.Marshal.ReleaseComObject(obj);
etc, etc.
Hope this is useful to someone.
Cheers.