none
How to update task/assignment %complete using JSON - code RRS feed

  • Question

  • Hi,

    i working on custom task update app, in which i want to update task/assignment complete using my app. i have tried using JSON but getting error while trying to update task/ assignment complete. pls guide me what is an issue and how to achieve this. thx.

    Link
    ------------
    https://msdn.microsoft.com/en-us/library/office/mt787167.aspx

    Code
    ------------
    function GetMyTasks() {
        projContext = PS.ProjectContext.get_current();
        assignments = PS.EnterpriseResource.getSelf(projContext).get_assignments();
        projContext.load(assignments);
        projContext.executeQueryAsync(GetTaskToUpdate, onQueryFailed);
    }

    function GetTaskToUpdate() {
        assignment = assignments.getByGuid('e5787b82-e04e-4ce2-8631-09ce14f6277e');
        projContext.load(assignment);
        projContext.executeQueryAsync(UpdateTask, onQueryFailed);
    }

    function UpdateTask() {
        assignment.set_percentComplete(20);
        assignment.submitStatusUpdates('');
        projContext.executeQueryAsync(DailyWorkSheetItem, onQueryFailed);
    }


    Error - when call execute method.
    ----------
    Original error: System.NullReferenceException: Object reference not set to an instance of an object.     at Microsoft.ProjectServer.StatusAssignmentObjectFactory.GetAssignmentById(String objectId)     at Microsoft.ProjectServer.StatusAssignmentObjectFactory.GetObjectById(String objectId)     at Microsoft.SharePoint.Client.ClientCallableObjectFactory.GetObjectByIdWithMonitoredScope(String objectId, ProxyContext proxyContext)     at Microsoft.SharePoint.Client.ClientMethodsProcessor.GetObjectFromObjectPath(XmlElement xe)     at Microsoft.SharePoint.Client.ClientMethodsProcessor.GetObjectFromObjectPathId(String objectPathId)     at Microsoft.SharePoint.Client.ClientMethodsProcessor.ProcessSetProperty(XmlElement xe)     at Microsoft.SharePoint.Client.ClientMethodsProcessor.ProcessOne(XmlElemen... 99e1029e-9a70-d0dd-0300-bf0c40104df2
    ...t xe)     at Microsoft.SharePoint.Client.ClientMethodsProcessor.ProcessStatements(XmlNode xe)     at Microsoft.SharePoint.Client.ClientMethodsProcessor.Process() 99e1029e-9a70-d0dd-0300-bf0c40104df2
    System.NullReferenceException: Object reference not set to an instance of an object.     at Microsoft.ProjectServer.StatusAssignmentObjectFactory.GetAssignmentById(String objectId)     at Microsoft.ProjectServer.StatusAssignmentObjectFactory.GetObjectById(String objectId)     at Microsoft.SharePoint.Client.ClientCallableObjectFactory.GetObjectByIdWithMonitoredScope(String objectId, ProxyContext proxyContext)     at Microsoft.SharePoint.Client.ClientMethodsProcessor.GetObjectFromObjectPath(XmlElement xe)     at Microsoft.SharePoint.Client.ClientMethodsProcessor.GetObjectFromObjectPathId(String objectPathId)     at Microsoft.SharePoint.Client.ClientMethodsProcessor.ProcessSetProperty(XmlElement xe)     at Microsoft.SharePoint.Client.ClientMethodsProcessor.ProcessOne(XmlElement xe)     at Mic... 99e1029e-9a70-d0dd-0300-bf0c40104df2
    ...rosoft.SharePoint.Client.ClientMethodsProcessor.ProcessStatements(XmlNode xe)     at Microsoft.SharePoint.Client.ClientMethodsProcessor.Process() 99e1029e-9a70-d0dd-0300-bf0c40104df2
    RequestMessage: <Request xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009" SchemaVersion="15.0.0.0" LibraryVersion="15.0.0.0" ApplicationName="Javascript Library"><Actions><SetProperty Id="80" ObjectPathId="65" Name="PercentComplete"><Parameter Type="Number">20</Parameter></SetProperty><Method Name="Update" Id="81" ObjectPathId="24" /><Method Name="SubmitAllStatusUpdates" Id="82" ObjectPathId="24"><Parameters><Parameter Type="Null" /></Parameters></Method></Actions><ObjectPaths><Property Id="24" ParentId="22" Name="Assignments" /><Identity Id="65" Name="ed60d25d-1efd-4337-8c98-5123b227f97e:d35fcee1-a9fd-e611-947e-00155d164100:19dc2f0a-86fd-e611-9be7-08d40c42a3be" /><StaticProperty Id="22" TypeId="{f6167b82-e04e-4ce2-8631-09ce14f6277e}" Name="Self" /></ObjectPaths></Request> 99e1029e-9a70-d0dd-0300-bf0c40104df2
    Original error: System.NullReferenceException: Object reference not set to an instance of an object.     at Microsoft.ProjectServer.StatusAssignmentObjectFactory.GetAssignmentById(String objectId)     at Microsoft.ProjectServer.StatusAssignmentObjectFactory.GetObjectById(String objectId)     at Microsoft.SharePoint.Client.ClientCallableObjectFactory.GetObjectByIdWithMonitoredScope(String objectId, ProxyContext proxyContext)     at Microsoft.SharePoint.Client.ClientMethodsProcessor.GetObjectFromObjectPath(XmlElement xe)     at Microsoft.SharePoint.Client.ClientMethodsProcessor.GetObjectFromObjectPathId(String objectPathId)     at Microsoft.SharePoint.Client.ClientMethodsProcessor.ProcessSetProperty(XmlElement xe)     at Microsoft.SharePoint.Client.ClientMethodsProcessor.ProcessOne(XmlElemen... 99e1029e-9a70-d0dd-0300-bf0c40104df2
    ...t xe)     at Microsoft.SharePoint.Client.ClientMethodsProcessor.ProcessStatements(XmlNode xe)     at Microsoft.SharePoint.Client.ClientMethodsProcessor.Process() 99e1029e-9a70-d0dd-0300-bf0c40104df2
    End CSOM Request.

     thx


    iffi

    Friday, July 7, 2017 12:47 PM

All replies

  • when i run code while logged with project manager it execute and update task 

    but when run code while logged using team member could not run and give me error "unexpected error found". 

    pls guide is there any further permission required to update task using CSOM.

    Thx


    iffi

    Tuesday, July 11, 2017 7:27 AM
  • hi 

    Did you find any resolution of this? I am getting same error. When i run same code using CSOM. The code works for Project Manager/Administrator role but fr Team member i get 'Unknown error' at SubmitStatusUpdate method.

    Would appreciate a response on this.


    Wednesday, January 17, 2018 9:30 AM
  • Hi,

    provide following permission when u assign rights/role to user and select My Task and assign following permissions:


    iffi

    Wednesday, January 17, 2018 11:21 AM