Portal Engine Questions on portal engine and web parts.
Version 7.x > Portal Engine > Bulk Check In View modes: 
User avatar
Member
Member
hannahs-attunix - 8/20/2013 3:07:51 PM
   
Bulk Check In
Hello,

We are having an issue on our site with bulk import of items directly to the published state (we can import as unpublished).

Is there a way to bulk check in and bulk publish multiple documents at once?

Thanks,
Hannah

User avatar
Member
Member
kentico_sandroj - 8/20/2013 3:26:49 PM
   
RE:Bulk Check In
Hi Hannah,

Could you please clarify how you are importing the documents? Import Toolkit, API, etc.

If you are using the API, you can follow these examples to check in and publish documents:

private bool CheckIn()
{
TreeProvider tree = new TreeProvider(CMSContext.CurrentUser);

// Prepare parameters
string siteName = CMSContext.CurrentSiteName;
string aliasPath = "/API-Example";
string culture = "en-us";
bool combineWithDefaultCulture = false;
string classNames = TreeProvider.ALL_CLASSNAMES;
string where = null;
string orderBy = null;
int maxRelativeLevel = -1;
bool selectOnlyPublished = false;
string columns = null;

// Get the document
TreeNode node = DocumentHelper.GetDocument(siteName, aliasPath, culture, combineWithDefaultCulture, classNames, where, orderBy, maxRelativeLevel, selectOnlyPublished, columns, tree);

if (node != null)
{
WorkflowManager workflowmanager = WorkflowManager.GetInstance(tree);

// Make sure the document uses workflow
WorkflowInfo workflow = workflowmanager.GetNodeWorkflow(node);

if (workflow != null)
{
if (node.IsCheckedOut)
{
VersionManager versionmanager = VersionManager.GetInstance(tree);

// Check in the document
versionmanager.CheckIn(node, null, null);

return true;
}
else
{
apiCheckIn.ErrorMessage = "The document hasn't been checked out.";
}
}
else
{
apiCheckIn.ErrorMessage = "The document doesn't use workflow.";
}
}

return false;
}

private bool PublishDocument()
{
TreeProvider tree = new TreeProvider(CMSContext.CurrentUser);

// Prepare parameters
string siteName = CMSContext.CurrentSiteName;
string aliasPath = "/API-Example";
string culture = "en-us";
bool combineWithDefaultCulture = false;
string classNames = TreeProvider.ALL_CLASSNAMES;
string where = null;
string orderBy = null;
int maxRelativeLevel = -1;
bool selectOnlyPublished = false;
string columns = null;

// Get the document
TreeNode node = DocumentHelper.GetDocument(siteName, aliasPath, culture, combineWithDefaultCulture, classNames, where, orderBy, maxRelativeLevel, selectOnlyPublished, columns, tree);

if (node != null)
{
WorkflowManager workflowManager = WorkflowManager.GetInstance(tree);

WorkflowInfo workflow = workflowManager.GetNodeWorkflow(node);

// Check if the document uses workflow
if (workflow != null)
{
// Publish the document
workflowManager.PublishDocument(node, null);

return true;
}
else
{
apiArchiveDocument.ErrorMessage = "The document doesn't use workflow.";
}
}

return false;
}

User avatar
Member
Member
hannahs-attunix - 8/20/2013 3:51:56 PM
   
RE:Bulk Check In
Thanks for the speedy response! We are using the import toolkit. It works if we import as non-published, but if we try to import and publish it fails.

Outside of our issues with the import toolkit, we would like to know if there is a way to bulk check-in/publish documents?

User avatar
Member
Member
kentico_sandroj - 8/21/2013 5:33:56 PM
   
RE:Bulk Check In
Hello,

Unfortunately it looks like you are unable to import and publish documents due to a bug in the current version. We have filed the bug so our development team will try to get a fix in the next hotfix version. I apologize for the inconvenience.

Other than the Import Toolkit, you could use the API to mass publish documents:

private bool PublishDocument()
{
TreeProvider tree = new TreeProvider(CMSContext.CurrentUser);

// Prepare parameters
string siteName = CMSContext.CurrentSiteName;
string aliasPath = "/API-Example";
string culture = "en-us";
bool combineWithDefaultCulture = false;
string classNames = TreeProvider.ALL_CLASSNAMES;
string where = null;
string orderBy = null;
int maxRelativeLevel = -1;
bool selectOnlyPublished = false;
string columns = null;

// Get the document
TreeNode node = DocumentHelper.GetDocument(siteName, aliasPath, culture, combineWithDefaultCulture, classNames, where, orderBy, maxRelativeLevel, selectOnlyPublished, columns, tree);

if (node != null)
{
WorkflowManager workflowManager = WorkflowManager.GetInstance(tree);

WorkflowInfo workflow = workflowManager.GetNodeWorkflow(node);

// Check if the document uses workflow
if (workflow != null)
{
// Publish the document
workflowManager.PublishDocument(node, null);

return true;
}
else
{
apiArchiveDocument.ErrorMessage = "The document doesn't use workflow.";
}
}

return false;
}

User avatar
Member
Member
hannahs-attunix - 8/26/2013 2:56:14 PM
   
RE:Bulk Check In
Thanks very much for the response. Any idea when this might be fixed?

User avatar
Kentico Customer Success
Kentico Customer Success
kentico_martind2 - 8/26/2013 6:23:33 PM
   
RE:Bulk Check In
Hello,

depends on how complicated it will be to fix this bug but it should be fixed under standard 7-Day Bug Fixing Policy.

Best Regards,
Martin Danko