Wednesday 15 August 2012

Exception CICONotCheckedOut when removing items from LookupTable using Project Server CSOM API -



Exception CICONotCheckedOut when removing items from LookupTable using Project Server CSOM API -

i have project online solution , need remove items lookuptable (microsoft.projectserver.client.lookuptable), because need clear before add together new items. primary utilize unit testing create items , clear when test done.

everytime run exception code 0x80131500 (-2146233088) error message "pjclientcallableexception: ciconotcheckedout\r\nciconotcheckedout", exception thrown when executequery executed.

i can add together new items , alter existing items lookuptable without checking out. , there no checkout method on lookuptable. don't know do...

the alternative project online utilize project server csom api, psi cannot used.

exception:

microsoft.sharepoint.client.clientrequest.processresponsestream(stream responsestream) @ microsoft.sharepoint.client.clientrequest.processresponse() @ microsoft.sharepoint.client.clientrequest.executequerytoserver(chunkstringbuilder sb) @ microsoft.sharepoint.client.clientrequest.executequery() @ microsoft.sharepoint.client.clientruntimecontext.executequery() @ microsoft.sharepoint.client.clientcontext.executequery() @ <mynamespace>.lookuptablehelper.deleteallitems(guid tableguid)

code:

// create password securestring securepassword = new securestring(); foreach (char c in "qwerty") securepassword.appendchar(c); microsoft.sharepoint.client.sharepointonlinecredentials cred = new microsoft.sharepoint.client.sharepointonlinecredentials("a@b.com", securepassword); // connect projectcontext context = new projectcontext(urltoprojectonlineweb); context.credentials = cred; // entries in lookup table lookuptable lookuptable = context.lookuptables.getbyguid(tableguid); context.load(lookuptable.entries); context.executequery(); if (lookuptable.entries.count > 0) { // if there items in collection, remove first item lookupentry e = lookuptable.entries[0]; lookuptable.entries.remove(e); } // upload alter cloud context.lookuptables.update(); context.executequery(); // throw pjclientcallableexception: ciconotcheckedout\r\nciconotcheckedout

solution (at to the lowest degree best far) first add together checkout table, remove existing items. leaves me 1 item cannot removed. improve not beingness able remove anything... jogeukens!

// create password securestring securepassword = new securestring(); foreach (char c in configuration.getconfig().password.tochararray()) securepassword.appendchar(c); microsoft.sharepoint.client.sharepointonlinecredentials cred = new microsoft.sharepoint.client.sharepointonlinecredentials(configuration.getconfig().username, securepassword); // connect projectcontext context = new projectcontext(configuration.getconfig().ppm_url); context.credentials = cred; // entries in lookup table lookuptable lookuptable = context.lookuptables.getbyguid(tableguid); context.load(lookuptable.entries); context.executequery(); lookupentrycreationinformation newentry = new lookupentrycreationinformation(); newentry.id = guid.newguid(); newentry.value = new lookupentryvalue(); newentry.value.textvalue = "the 1 cannot removed..."; lookuptable.entries.add(newentry); while(lookuptable.entries.count > 1) { // if there items in collection, remove first item lookupentry e = lookuptable.entries[0]; lookuptable.entries.remove(e); } // upload alter cloud context.lookuptables.update(); context.executequery();

i don't have plenty reputation create comment, may help out of this:

i had same problem, able work around making sure every delete happens in same update add. apparently "lookuptable.entries.add()" checks lookup table out automatically, while lookuptable.entries.remove() doesn't.

so getting them both in 1 update, can utilize checkout add together remove other entries.

offcourse if don't need add together new entries, wont work. if found other solutions, work more reliably, please add together them answer.

csom project-server ms-project-server-2013

No comments:

Post a Comment