none
Question of creating timesheets for users PSI RRS feed

  • Question

  • Can any one help if it is possible to create timesheets for other users programmatically (PSI or CSOM) ?

    Even with the admin rights I am unable to create timesheets for other users. I always get SecurityAccessDenied error.

    Is there any setting to be changed on the server ? Note I can programmatically create timesheet for myself but I need to do for other users as well.

    Thanks

    Monday, July 20, 2015 7:36 PM

All replies

  • Hey there,

       There is a good sample here to do exactly what you want to do.

    Cheers,

       James.


    James Boman BSc. MCP:EAD -

    Wednesday, July 22, 2015 9:06 AM
  • Thank you James.  The particular example is when the timesheet headers exists for the users but in my case I have to Create the timesheets as well.

    TS_IS_CONTROLLED_BY_OWNER = false ; is not going to work as the header for the timesheet does not exist. Any help is truly appreciated ! Thanks

    Wednesday, July 22, 2015 2:11 PM
  • Hi Shantala,

    You can use PSI impersonation to achieve this.

    In the Project SDK you can find a code sample of impersonation, you'll have to adapt this for your own scenario but it should get you started.

    Hope this helps

    Thursday, July 23, 2015 2:16 PM
  • Thank you. We have project server 2013 and Impersonation was part of Project Server 2007 so I am being told to make use of delegate feature to create timesheets.

    The problem I am facing with it is I can create delegates programmatically also read the delegates that are already established on the server but I am not able to start the Delegaion Session programmatically. Is there a way we can start the delegation session programmatically ??

    Any help is appreciated.

    Thanks

    Thursday, July 23, 2015 7:18 PM
  • Hi Shantala,

    Sorry for the looooooooooooooooooooooooooooong time to answer you and hope you still need help, but i didn't found your post until now.

    It's very simple to start a delegation, you just have to call to an stored procedure like this:

    using (SqlConnection con = new SqlConnection(connStr))
                    {
                        using (SqlCommand cmd = new SqlCommand("[pub].MSP_USER_DELEGATION_SetDelegate", con))
                        {
                            cmd.CommandType = CommandType.StoredProcedure;
    
                            cmd.Parameters.Add("@DelegateUid", SqlDbType.VarChar).Value = <GUID>;
                            cmd.Parameters.Add("@ResUid", SqlDbType.VarChar).Value = <GUID>;
    
                            con.Open();
                            cmd.ExecuteNonQuery();
                        }
                    }

    Hope it helps if not to you, to other people.



    Tuesday, November 8, 2016 10:00 AM
  • Is the issue fixed? can you please let me know how to start the delegate session programmatically?

    Thanks.

    Tuesday, March 28, 2017 10:19 AM