none
csom to force check-in... RRS feed

  • Question

  • Hi 

    Can csom be used to force check-in a project as I can't seem to find the right commands to do so?

    Many thanks 

    James 


    • Edited by JamesP435 Tuesday, August 28, 2018 4:55 AM
    Tuesday, August 28, 2018 4:55 AM

Answers

  • Hi James,

    I don’t think there is an admin level / bulk force check-in method and I think that is by design / a good thing. I would never programmatically force check-in a project unless you have programmatically checked out that project first. This should really be a conversation with the user who has it checked out to ask them to check it in or failing that a human makes the call to go a force check in that project knowing the potential impact. If programmatically updating a project that you have programmatically checked out to update etc., you could check in that project: https://msdn.microsoft.com/en-us/office/project/api/draftproject#CheckIn_Boolean_force_

    Paul


    Paul Mather | Twitter | http://pwmather.wordpress.com | CPS | MVP | Downloads

    Friday, August 31, 2018 8:55 AM
    Moderator
  • Yes, there is a way to programmatically check-in a project using CSOM:

    // Step 1) Read the project from the server
    PublishedProject project = context.Projects.GetByGuid( projectUID );
    context.Load( project );
    context.ExecuteQuery();
    
    // Step 2) If Checked out, force a CheckIn
    if( project.IsCheckedOut ) {
       var checkInJob = project.Draft.CheckIn( true );
       context.Load( checkInJob );
       context.ExecuteQuery();
    }

    • Marked as answer by JamesP435 Saturday, June 27, 2020 7:23 AM
    Thursday, February 6, 2020 3:51 AM

All replies

  • Hi James,

    I don’t think there is an admin level / bulk force check-in method and I think that is by design / a good thing. I would never programmatically force check-in a project unless you have programmatically checked out that project first. This should really be a conversation with the user who has it checked out to ask them to check it in or failing that a human makes the call to go a force check in that project knowing the potential impact. If programmatically updating a project that you have programmatically checked out to update etc., you could check in that project: https://msdn.microsoft.com/en-us/office/project/api/draftproject#CheckIn_Boolean_force_

    Paul


    Paul Mather | Twitter | http://pwmather.wordpress.com | CPS | MVP | Downloads

    Friday, August 31, 2018 8:55 AM
    Moderator
  • Yes, there is a way to programmatically check-in a project using CSOM:

    // Step 1) Read the project from the server
    PublishedProject project = context.Projects.GetByGuid( projectUID );
    context.Load( project );
    context.ExecuteQuery();
    
    // Step 2) If Checked out, force a CheckIn
    if( project.IsCheckedOut ) {
       var checkInJob = project.Draft.CheckIn( true );
       context.Load( checkInJob );
       context.ExecuteQuery();
    }

    • Marked as answer by JamesP435 Saturday, June 27, 2020 7:23 AM
    Thursday, February 6, 2020 3:51 AM
  • Thanks for this Paul.  Very useful

    James 




    • Edited by JamesP435 Saturday, June 27, 2020 7:24 AM
    Saturday, June 27, 2020 7:24 AM