none
How to delete the content in the custom field in PDP status page in Project Online RRS feed

  • Question

  • Hi All,

    Can any one please help me how to delete the content in the custom field in PDP status page in Project Online every month starting.

    is there any work flow or flow we can use.

    Please find the below screen short.

    

    

    Thank you,

    Sowjanya.

    Monday, April 22, 2019 9:16 PM

All replies

  • Currently, Flow doesn’t have a way to update custom fields using the Project Online Connector. It is possible with Project Online Reset API using Flow but you will be better off using PowerShell or a C# program to do so.
    Although SharePoint Designer Workflow can set project field, the way they work will make it tricky to achieve the desired result. 

    The best way to achieve this is by programmatically updating the field on all Projects (or a set of Projects) using the Project Online Client-Side Object Model .Net Library (CSOM):
     - Create a console application or PowerShell Script. 
     - Retrieve a list of projects (you can filter by some criteria i.e. active projects).
     - Ensure projects are checked-in or force check-in programmatically.
     - Schedule the app or the script to run each month to empty the field value then check-in the project after updating the field. 

    Here is an example from Paul Mather's Blog to give you an idea on how to update custom field via PowerShell. You will still need to adjust this to work for your case.

    https://pwmather.wordpress.com/2016/11/06/update-projectonline-project-custom-field-values-using-powershell-with-data-from-a-csv-file-ppm-projectserver-csom/

    I hope this helps.


    Ali Al . Consultant & Development Manager.

    www.epmainc.com www.projectserver.com www.ppmxinc.com
    FB TW IN

    Tuesday, April 23, 2019 1:58 PM
  • Hi Ali,

    Thank you for you reply.

    i am able to get update for single project custom filed by using below CSOM CODE.

    may i know how to update for all of the projects 

    this code is working for single project .

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Security.Principal;
    using System.Data;
    using System.ServiceModel;
    using Microsoft.ProjectServer.Client;
    using Microsoft.SharePoint.Client;
    using System.Security;

    namespace Project_Online_CSOM
    {
        class Program
        {
            static string UserName = "Username";
            static string Passwords = "Password";
            public static string OnlinePWA = "https://                         ";

            static void Main(string[] args)
            {
                UpdateCustomField();
            }

            private static void UpdateCustomField()
            {
                using (ProjectContext ProjectCont = new ProjectContext(Credentials.OnlinePWA))//PWA Url

                {
                    SecureString passWord2 = new SecureString();
                    foreach (char c in Passwords.ToCharArray()) passWord2.AppendChar(c);
                    ProjectCont.Credentials = new SharePointOnlineCredentials(UserName, passWord2);
                     ProjectCont.Load(ProjectCont.Projects);

                    //ProjectCont.Load(ProjectCont.Projects,
                    //c => c.IncludeWithDefaultProperties(pr => pr.StartDate, pr => pr.Name, pr => pr.CustomFields, pr => pr.Assignments, pr => pr.FinishDate, pr => pr.Owner.LoginName, pr => pr.Tasks, pr => pr.ProjectSiteUrl, pr => pr.PercentComplete, pr => pr.ProjectResources, pr => pr.CustomFields, pr => pr.EnterpriseProjectType));
                                    
                    //c => c.IncludeWithDefaultProperties(pr => pr.Name));
                  var projectColl = ProjectCont.LoadQuery(ProjectCont.Projects.Where(p => p.Name == "test"));
                                                  

                        ProjectCont.ExecuteQuery();

                       PublishedProject pubProj = projectColl.FirstOrDefault();
                       DraftProject draft = pubProj.Draft;
                       JobState job1 = ProjectCont.WaitForQueue(draft.CheckIn(true), 20);
                       DraftProject projCheckedOut = pubProj.CheckOut();
                        projCheckedOut.Name = "test";
                        projCheckedOut.Description = "test​";
                        projCheckedOut.SetCustomFieldValue("Custom_898808572356e911afb000155d606e16", "test2");
                        //Note:Custom_b50f29a9881de61180d700155d1c581a=Custom_(Your Custom Field GUID without hyphen)
                       projCheckedOut.Update();
                       ProjectCont.Load(projCheckedOut);
                       projCheckedOut.Publish(true);
                       ProjectCont.ExecuteQuery();
                        ProjectCont.Projects.Update();
                        ProjectCont.ExecuteQuery();
                        projCheckedOut.Publish(true);
                       JobState jobState = ProjectCont.WaitForQueue(ProjectCont.Projects.Update(), 10);
                    }
                }

            }
        }

    Thank you,

    Sowjanya.

    Tuesday, May 7, 2019 2:41 PM