cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
SamPo
Impactful Individual
Impactful Individual

Updating Task Custom Fields in Project Online

Hi All,

 

I'm building a flow to update Project Online Tasks via API.

 

I have managed to update standard fields on the task level with the help of this post https://powerusers.microsoft.com/t5/Connecting-To-Data/Update-Project-Online-Task/m-p/277934#M5274

 

Now I am trying to update custom fields at the task level but with no success.

 

My latest attempt looks something like this:

 

2019-07-17_1121_001.png

 

If anyone has any ideas would be much appreciated!

 

Thanks,

Sam

21 REPLIES 21
tfhegdbn
Helper IV
Helper IV

Hi @SamPo ,

 

Is there any error message available?

 

SamPo
Impactful Individual
Impactful Individual

Hi,

 

With the help of a Microsoft engineer, we managed to get this working using a Process Query.

Will update will a full post on how we did it later, if anyone is interested in the meantime then feel free to message me privately.

 

Sam

Anonymous
Not applicable

Hello @SamPo,

 

I am trying to update simple(without lookup value) task custom field using flow as mentioned in this post but can`t update them.

 

Please advice on this how you succeeded with it.

 

Thanks and Regards .

Parth

SamPo
Impactful Individual
Impactful Individual

I've had a few people contact me about this so adding all the info here.

 

If you want to update a custom field at the task level then you need to use a 'Process Query'

See the example below:

2019-08-27_1357.png

 

 

URL:

_vti_bin/client.svc/ProcessQuery

Headers:

{
  "Accept": "application/json;odata=verbose",
  "Content-Type": "text/xml"
}

Body:

<?xml version="1.0" ?>
    <Request ApplicationName="Javascript Library" LibraryVersion="16.0.0.0" SchemaVersion="15.0.0.0" xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009">
    <Actions>
        <Method Id="14" Name="SetCustomFieldValue" ObjectPathId="12">
            <Parameters>
                <Parameter Type="String">Custom_f8562da40598e911afb800155dd48834</Parameter>
                <Parameter Type="String">@{body('Create_a_work_item_-_feature')?['fields']?['System_Id']}</Parameter>
            </Parameters>
        </Method>
        <ObjectPath Id="16" ObjectPathId="15"/>
        <Query Id="17" ObjectPathId="15">
            <Query SelectAllProperties="true">
                <Properties/>
            </Query>
        </Query>
    </Actions>
    <ObjectPaths>
        <Constructor Id="0" TypeId="{3a609e5f-e2a1-497c-87a2-e5e8a781c096}"/>
        <Constructor Id="2" TypeId="{f256f605-bb33-4d62-b206-72a06a765075}">
            <Parameters>
                <Parameter ObjectPathId="0"/>
            </Parameters>
        </Constructor>
        <Property Id="4" Name="Projects" ParentId="0"/>
        <Method Id="6" Name="GetByGuid" ParentId="4">
            <Parameters>
                <Parameter Type="String">@{body('Parse_JSON')?['ProjectId']}</Parameter>
            </Parameters>
        </Method>
        <Property Id="8" Name="Draft" ParentId="6"/>
        <Property Id="10" Name="Tasks" ParentId="8"/>
        <Method Id="12" Name="GetByGuid" ParentId="10">
            <Parameters>
                <Parameter Type="String">@{items('Apply_to_each_-_create_and_update_features_in_TFS')?['TaskID']}</Parameter>
            </Parameters>
        </Method>
        <Method Id="15" Name="Update" ParentId="8"/>
    </ObjectPaths>
</Request>

 

Sam

 

Hello. Would you be okay with me asking a little more about how this works? I am trying to do the same thing with editing a custom task field. 

I tried using this but it doesn't work and I'm unsure as to what other fields I need to change. I have the custom field id, task id, project id, and custom field value done.

So for this part of the code I'm guessing this is where you put in the custom field id which I've already done:

<Parameter Type="String">Custom_f8562da40598e911afb800155dd48834</Parameter>

 And this part is where you put in whatever data you want to send to the custom field:

<Parameter Type="String">@{body('Create_a_work_item_-_feature')?['fields']?['System_Id']}</Parameter>

 I'm wondering if there are other things I need to change, like the "ObjectPathId", "ObjectPath Id", "Query Id" so they match up with what I need for my custom field?

<Actions>
        <Method Id="14" Name="SetCustomFieldValue" ObjectPathId="12">
            <Parameters>
                <Parameter Type="String">Custom_f8562da40598e911afb800155dd48834</Parameter>
                <Parameter Type="String">@{body('Create_a_work_item_-_feature')?['fields']?['System_Id']}</Parameter>
            </Parameters>
        </Method>
        <ObjectPath Id="16" ObjectPathId="15"/>
        <Query Id="17" ObjectPathId="15">
            <Query SelectAllProperties="true">
                <Properties/>
            </Query>
        </Query>
    </Actions>


Same here. Do I need to change the "Constructor Id"? And I can see that "TypeId" has something that looks like a guid or id of a field, so does this come from somewhere? Do I need to get some data from my custom field or anything and put that in here? As for "ParentId" do I need change that too?

<ObjectPaths>
        <Constructor Id="0" TypeId="{3a609e5f-e2a1-497c-87a2-e5e8a781c096}"/>
        <Constructor Id="2" TypeId="{f256f605-bb33-4d62-b206-72a06a765075}">
            <Parameters>
                <Parameter ObjectPathId="0"/>
            </Parameters>
        </Constructor>
        <Property Id="4" Name="Projects" ParentId="0"/>
        <Method Id="6" Name="GetByGuid" ParentId="4">
            <Parameters>
                <Parameter Type="String">@{body('Parse_JSON')?['ProjectId']}</Parameter>
            </Parameters>
        </Method>
        <Property Id="8" Name="Draft" ParentId="6"/>
        <Property Id="10" Name="Tasks" ParentId="8"/>
        <Method Id="12" Name="GetByGuid" ParentId="10">
            <Parameters>
                <Parameter Type="String">@{items('Apply_to_each_-_create_and_update_features_in_TFS')?['TaskID']}</Parameter>
            </Parameters>
        </Method>
        <Method Id="15" Name="Update" ParentId="8"/>
    </ObjectPaths>

 Overall I'm just wondering if I need to change things like "ParentId", "ObjectPathId", "Method Id", "Contructor Id" and "Type Id"? 

 

Thank you.

SamPo
Impactful Individual
Impactful Individual

@Mgodby 

The only things you need to update are:

1) Custom field ID

2) Custom field value

3) Project ID

4) Task ID

 

I would suggest trying to hardcode all your values just to see if it's working.

All the other values should remain the same.

 

In general the way to get this code is to use the project desktop app and run a program like fiddler or wireshark to capture network traffic. Then make changes to a custom field and save and publish your project. You should then be able to find the process query in your network logs as this is actually how the app makes the changes back to the server.

 

Hope this helps

Thank you so for the help. Yeah I noticed that the id I put might've been wrong so I'll try to hardcode it and see what happens. 

I am trying too achieve similar thing.

 

Updating Project Custom Field (Text). I have just removed the "Task" section and followed the rest the same as suggested.

 

the flow is executed successfully, but the value is not updated in "Project Online Project Custom Field"

 

Can you advise me.

 

Thanks in advance

Hi @jacobsome I'm trying to do the exact same thing and seeing the same issue, did you ever work out how to update project custom fields?

Could not achieve using flow. So changed the approach.

Simple CSOM in azure function to incorporate business requirements.

@SamPo your method seems logical, but does not work at all.

Maybe Microsoft does not allow ProcessQuery anymore. 

I've tried many things to update task custom fields but nothing works.

And It's sad that Microsoft does not provide proper documentation.

MPowered
Frequent Visitor

Thank you! This worked for me very well once I realized that Custom Fields need to be called with their internal name "Custom_"... instead of "Custom_x005f_"... like in the REST API.

Hi Mpowered! Did you have to put any values in quotes? with teh Internal name? My flow runs successfully but does not update.  Also are you updating any Custom fields with Lookup table values? Or just Text?  Let me know if you can, thanks!

Hi.

 

I am updating only single line text. In my case a status text: "Ready".

Please see my http request body below.

c_ECF_estatus holds the internal name of the enterprise custom field. In my case "Custom_524c..." without quotes.

 

<?xml version="1.0" ?>
    <Request ApplicationName="Javascript Library" LibraryVersion="16.0.0.0" SchemaVersion="15.0.0.0" xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009">
    <Actions>
        <Method Id="14" Name="SetCustomFieldValue" ObjectPathId="12">
            <Parameters>
                <Parameter Type="String">@{variables('c_ECF_EStatus')}</Parameter>
                <Parameter Type="String">Ready</Parameter>
            </Parameters>
        </Method>
        <ObjectPath Id="16" ObjectPathId="15"/>
        <Query Id="17" ObjectPathId="15">
            <Query SelectAllProperties="true">
                <Properties/>
            </Query>
        </Query>
    </Actions>
    <ObjectPaths>
        <Constructor Id="0" TypeId="{3a609e5f-e2a1-497c-87a2-e5e8a781c096}"/>
        <Constructor Id="2" TypeId="{f256f605-bb33-4d62-b206-72a06a765075}">
            <Parameters>
                <Parameter ObjectPathId="0"/>
            </Parameters>
        </Constructor>
        <Property Id="4" Name="Projects" ParentId="0"/>
        <Method Id="6" Name="GetByGuid" ParentId="4">
            <Parameters>
                <Parameter Type="String">@{variables('c_ProjectID')}</Parameter>
            </Parameters>
        </Method>
        <Property Id="8" Name="Draft" ParentId="6"/>
        <Property Id="10" Name="Tasks" ParentId="8"/>
        <Method Id="12" Name="GetByGuid" ParentId="10">
            <Parameters>
                <Parameter Type="String">@{items('Apply_to_each')?['taskID']}</Parameter>
            </Parameters>
        </Method>
        <Method Id="15" Name="Update" ParentId="8"/>
    </ObjectPaths>
</Request>

 

Fantastic!  I was actually about to try updating one of my simple "Text" fields and it does now work.  I'll have to figure out the syntax for picking a lookup table value using this method. If anyone has a note about that I'd appreciate it!  Thanks again for helping me out!

PhaniKiran
Regular Visitor

We tried this approach however was able to update one task at a time, Is there a way to bulk update as this is increasing the process time.

 

rohanw24
New Member

Hi,

 

I tried to use this approach in a C# application. I'm making POST request to my PWA site with XML body mentioned in this discussion. But when I execute, server returns "Invalid request". 

 

[
{
"SchemaVersion":"15.0.0.0","LibraryVersion":"16.0.21409.12004","ErrorInfo":{
"ErrorMessage":"Invalid request.","ErrorValue":null,"TraceCorrelationId":"44a9d49f-101e-2000-e0f4-8d6f478bd705","ErrorCode":-1,"ErrorTypeName":"Microsoft.SharePoint.Client.ClientServiceException"
},"TraceCorrelationId":"44a9d49f-101e-2000-e0f4-8d6f478bd705"
}
]

 

Does anyone knows what could be the reason or how to do it in C#?

 

Update: Issue has been resolved. I forgot to correctly escape double quotes in the XML body.

 

Thanks & Regards,

Rohan

use "CSOM" in C# to do this. it is simple and straight forward.

rohanw24
New Member

Hi,

 

Do you have XML body for updating task custom field with lookup table entry?

 

Thanks & Regards,

Rohan

Helpful resources

Announcements
MPA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Kudoed Authors
Users online (1,060)