0

I have a document library that uses major and minor versioning in library settings. I want to start a custom SharePoint Designer 2013 workflow as soon as an item gets published, inside this library. Am using Sharepoint 2013 on premises. How can I achieve this? I cant find a way of starting the workflow on publish, it starts on the first save of the item, when the item is not even checked in.

Thank you in advance

0

You could add en item event receiver and check if the item has been approved and published. If so, launch the workflow manually, but you must be sure that it's the first publishing (version number = 1) because it can be published more than one time.

You could use this code :

public override void ItemUpdated(SPItemEventProperties properties)
{
    if (properties != null &&
        properties.ListItem != null &&
        properties.ListItem.ModerationInformation != null &&
        properties.ListItem.ModerationInformation.Status == 
            SPModerationStatusType.Approved &&
        properties.ListItem.Level == SPFileLevel.Published &&
        "Check if version = 1" )
    {
        // Item was just approved and published, launch the workflow programmatically
    }
}
  • Thanks. I am looking for a non-code solution, but I will try this if Submits answer below does not work. Thanks! – George Mar 9 '15 at 5:51
  • This is the block of code that does it, based on your guidlines: 'code' Public Overrides Sub ItemUpdating(properties As SPItemEventProperties) If properties.AfterProperties("vti_level") = 2 Then 'code here End If MyBase.ItemUpdating(properties) End Sub 'code' – George Mar 10 '15 at 7:10
  • I don't understand, did you try this code ? – KhalilG Mar 10 '15 at 8:54
0

You could start the workflow when the item is saved. Then in your workflow check the version number. If the version number is an integer, i.e. 1, 2, 3, etc., then you can assume it's a published version and the workflow can continue to do other steps. If the version number is not an integer, e.g. 1.1, then the workflow completes without carrying out any further steps.

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.