Is there a way to programatically create a Staging task

Sean Fleming asked on September 3, 2020 15:01

I would like to create staging tasks programmatically. Sometimes staging tasks are deleted, and we have to find a page/webpart then save it to create an staging task. I can programmatically save an item to create that task, but I would like to create the task directly. Is there anything in the API to do that?

Correct Answer

Liam Goldfinch answered on September 3, 2020 23:30

Hi Sean,

Would something like this help?

    // To log a staging task for updating a document:
    var document = DocumentHelper.GetDocuments()
        .WhereEquals(nameof(TreeNode.DocumentID), 8)
    DocumentSynchronizationHelper.LogDocumentChange(document, TaskTypeEnum.UpdateDocument, Tree);

    // To log a staging task for updating an object:
    var formInfo = BizFormInfoProvider.GetBizForms()
    SynchronizationHelper.LogObjectChange(formInfo, TaskTypeEnum.UpdateObject);

I've tested this locally and it creates the correct staging task - I don't have a target server setup so I can't test actually staging the tasks.

1 votesVote for this answer Unmark Correct answer

Recent Answers

Sean Fleming answered on September 3, 2020 23:35

Thanks! I glanced right over that in the docs, because "Log" didn't equal "Create" in my head.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.