0

I have a quite specific requirement from company management to set 'antedates' ("Started" and "Last run" dates) for some documents on the workflow status page of OOTB Approval Workflow (see picture).

E.g. shift these dates 3 months back. Are there any methods to do this, except on DB level? SPWorkflow class, unfortunately, doesn't have any Update methods, so I can't use this class to change Created and Modified properties. Maybe someone knows an internal method which I can use for it? By the way, how does SharePoint set these dates under the hood?

Workflow Status

0

There won't be any way to do this unless directly modify DB(which is not at all recommended). We have to understand that workflow start date and end date is not data of document which we should be able to edit. Start date and end date of workflow is internal data for workflow functionality. There would be complication involved in changing these dates, what if these dates are used within workflow to handle some logic based on when workflow is triggered. As workflow instance is already completed it won't run again and data corresponding to it would be corrupted.

Coming to your question "how does SharePoint set these dates under the hood?" Simple, it assign value to start date to now when workflow is triggered. This property would be for each workflow instances. Last run date is updated once workflow is started. workflow can be triggered more than once...so these property is at workflow level and not at workflow instance level.

2
  • Thanks for the answer. I understand, where SharePoint takes these dates. But I can't understand, if SharePoint can sets these dates, why we can't to do the same thing? – DiscoveryX Feb 1 '18 at 10:07
  • :) :) That is how SharePoint is designed....Every product will have its internal logic to handle its product requirement and functionality..... – Siddharth Vaghasia Feb 1 '18 at 10:18
0

Although it's an quite old question, I want to share a solution I've finally found. It's simple enough, without the need of a direct DB modification. We just need to add some code into WrkStat.aspx page in LAYOUTS directory. The code below we have to add inside <asp:Content ContentPlaceHolderId="PlaceHolderMain" runat="server"></asp:Content> tag, before bool showItem = (List != null && ListItem != null); line of code.

DateTime started = Convert.ToDateTime(Literal_Started.Text);
DateTime lastRun = Convert.ToDateTime(Literal_LastRun.Text);

switch (ListItem.ID)
{
    case 105:
        Literal_Started.Text = started.AddDays(-90).ToString("g");
        Literal_LastRun.Text = lastRun.AddDays(-90).ToString("g");            
        break;
    default:
        break;
}

You just need to change list item ID in the case statement and assign an appropriate number of days into AddDays() method. Of course, you can add additional case switches, if needed.

Probably, there isn't the best solution, but a good workaround for my problem, I think.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.