identify newest baseline in an array | Community
Skip to main content
KristenS_WF
Level 6
February 14, 2024
Solved

identify newest baseline in an array

  • February 14, 2024
  • 1 reply
  • 647 views

I'm currently building a scenario in which a change to the project planned completion date triggers the creation of a new baseline for that project.  In cases where the project has existing baselines, I'd like to set the most recently entered baseline as the default baseline before creating the new one.

I have 3 baselines in my sample project:

  • Original [created by WF when the project was marked Current]
  • Baseline02
  • Baseline03

I was playing around, and I've been able to (1) sort the baseline array by name; (2) get the ID for Baseline03 based upon the sort; and (3) use the ID in a Custom API module to set Baseline03 as the default baseline.

Although this works, I thought it might be cleaner if I could sort the baseline array by the baseline entry date (rather than worry about our naming conventions for baselines).  entryDate is listed as a field in the Baseline object in the API, but I can't seem to sort the array using it as a key.

Is this even possible?  Is there a better way to identify the newest baseline?

Thanks.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by dale_whitchurch

Hello,

 

I assume you are using a custom API call to get the collection of baselines.  If you only want the latest one, here is how I would setup that query: 

Then, in the resulting array with one item, the ID will be in the first index of the data[] array.  Hope that helps

1 reply

dale_whitchurchAccepted solution
February 14, 2024

Hello,

 

I assume you are using a custom API call to get the collection of baselines.  If you only want the latest one, here is how I would setup that query: 

Then, in the resulting array with one item, the ID will be in the first index of the data[] array.  Hope that helps

KristenS_WF
Level 6
February 14, 2024

I had been using the Read a record module for the project and selecting Baselines under Collections to pull in the array.

I'm new to working with custom APIs, but your method is much easier and cleaner and works in my scenario.  Thank you!