Project Online: Workflow error when reading flag field

2018-02-11 | Barbara.Henhapl

In November 2017, a support article was published how to Troubleshoot Project Online workflows. One described error is “Custom field CUSTOM_FIELD_GUID does not have a value set for project PROJECT_GUID”. There is a special case when reading an Enterprise Custom Field of type Flag, as mentioned in a Note.
Flag fields have one special behavior: You can’t set a default value for this type of fields. The value is blank, until you changed it manually at least one time – even if it is displayed as No on Project Detail Page or in Project client. Therefore, you can’t access this value from within a SharePoint Designer workflow until the first change.

In this case, a workflow will display the following error:
image

Error text:

Retrying last request. Next attempt scheduled in less than one minute. Details of last request: HTTP BadRequest to https://…...sharepoint.com/sites/pwa/_api/ProjectServer/WorkflowActivities/ReadBooleanProperty(projectId=……….',propertyId='….') Correlation Id: ….Instance Id: ….
Custom field …. does not have a value set for project….

On my request, a workaround was added as a note, what I see a option 1:

Option 1:

image

There is one drawback with this option: If you are working in multi language environments, a lookup table with yes/no, true/false, … will not satisfy your non-English users.

Option 2:

There is another option, however it requires some more effort within your workflow. The main part is to use REST API to evaluate, if a value is set for a specific field.

  1. Step 1 – Set Parameters/Variables
  2. Step 2 – Get internal name for Enterprise Custom Flag field
  3. Step 3 - Get ECF value for Project using REST and initialize if necessary

Step 1 – Set Parameters/Variables

We need two variables in this case:

  1. We need a variable to parameterize the name of the ECF of type Flag
    Use Action – Core Actions – Set Workflow Variable to set a new variable to your flag field name.In my sample, I named this variable v_ECFFlagName.
    image
  2. We need the second variable as dictionary as Request Header for our REST call. I named my dictionary I want to use as Request Header v_RequestHeaderStandard (in future posts, you will see some different Request Headers and I want to be able to identify them)
    Use Action – Core Actions – Build Dictionary to build v_RequestHeaderStandard.
    image

    To get the the response in a JSON format we will have to update the Accept and Content-Type http headers of our REST http call:
    Accept : application/json;odata=verbose
    Content-Type : application/json;odata=verbose
    Click on this to add Accept  and Content-Type and set value to application/json;odata=verbose for both names.
    image

    Click on Variable: dictionary to define a variable with a meaningful name.
    SNAGHTMLb64a2c0

    In this sample, I use v_RequestHeaderStandard as mentioned above.
    image

Afterwards, it will look like this:

image

Step 2 – Get internal name for Enterprise Custom Flag field

To get the internal name for your field, you can use https://<YourTenant>.sharepoint.com/sites/pwa/_api/ProjectServer/CustomFields()?$Filter=Name eq '<YourFlagFieldName>'&$SELECT=InternalName.

After above steps, v_InternalName will be the internal name as required in the next step and it will look like this:

image

Step 3 - Get ECF value for Project using REST and initialize if necessary

To get the value of all available fields including custom fields, we have to use following URL: https://<YourTenant>.sharepoint.com/sites/pwa/_api/ProjectServer/Projects('<ProjectId>')/IncludeCustomFields/IncludeCustomFields. To retrieve the value within the workflow, we will need another HTTP Call. For this call, we need a different URL and re-use the variable v_RestURL.

With the above actions, Step 3 will look like this:

image


Just a note at the end: The same applies for Project Server 2016 (and presumably for Project Server 2013 – but I have not tested with this version).

Categories: Project, SharePoint Designer Workflow

Source: https://blog.atwork.at/post/Project-Online-Workflow-error-when-reading-flag-field