c# - Sharepoint Online Workflow restart error (Console Application) -
i requests restart workflow of list items. have written application takes library name , list item name input. when try start workflow (startworkflow method) error exception hresult: 0x8102009b , no inner exception. below code.
sometimes workflow may have been started. in case need cancel workflow , restart.
i did lot of search on issue. of resolution sp 2010. using sp online
clientcontext.credentials = new sharepointonlinecredentials(userid, password); var web = clientcontext.web; list list = web.lists.getbytitle("listname"); clientcontext.load(list); camlquery camlquery = new camlquery(); camlquery.viewxml = "<view><query><orderby><fieldref name='fileleafref' descending='true'/></orderby><where><eq><fieldref name='fileleafref'/><value type='file'>" + listitemname + ".xml</value></eq></where></query><rowlimit>1</rowlimit></view>"; listitemcollection items = list.getitems(camlquery); clientcontext.load(items); clientcontext.executequery(); var id = items.where(a => a.fieldvalues["fileleafref"].tostring() == listitemname + ".xml").select(a => a.id).firstordefault(); guid listitemid = (guid)items.where(a => a.fieldvalues["fileleafref"].tostring() == listitemname + ".xml").select(a => a.fieldvalues["guid"]).firstordefault(); workflowassociationcollection wfacollection = items.where(a => a.fieldvalues["fileleafref"].tostring() == listitemname + ".xml") .select(a => a.parentlist.workflowassociations).firstordefault(); clientcontext.load(wfacollection); var workflowservicemanager = new workflowservicesmanager(clientcontext, web); clientcontext.load(workflowservicemanager); clientcontext.executequery(); interopservice workflowinteropservice = workflowservicemanager.getworkflowinteropservice(); clientcontext.load(workflowinteropservice); var wfaname = wfacollection.where(a => a.enabled == true).select(a => a.name).firstordefault(); guid wfaid = wfacollection.where(a => a.enabled == true).select(a => a.id).firstordefault(); var initiationdata = new dictionary<string, object>(); clientresult<guid> resultguid = workflowinteropservice.startworkflow(wfaname, new guid(), list.id, listitemid, initiationdata); clientcontext.executequery();
Comments
Post a Comment