Skip to main content
Question

Pipeline to create record and populate a date field

  • September 27, 2024
  • 0 replies
  • 418 views

Forum|alt.badge.img+6

I created a pipeline to create a record in a table (Statuses) after a record in another table (Masters) is created. For each Master record created I need 4 Status records created - each with a due date at 3,6,9, and 12 months after the expected start date noted in the Master. I have tried several formulas but am unable to get the right formula. The Expected Start Date in the Masters table is FID 13. If that date is 11-1-2024, how do I write the Status Due Date pipeline formula(s) to create a record with the due date of 2-1-2025 (and subsequently 5-1-2025, 8-1-2025 and 11-1-2025)?  Dates will be different for each Master so I can't plug in hard dates.

Can i create all 4 records in the same pipeline by adding additional 'create' steps? Or do I need 4 separate pipelines?

This topic has been closed for replies.

Forum|alt.badge.img+6
  • Author
  • Registered
  • September 27, 2024

I did find the answer with QB Junkie. Here is the formula and it worked.

{{ a.expected_implementation_date.replace(day=1) + time.delta(months=3) }} with 3 being the variable for each month needed. This also makes the date the 1st of each of those months specified.

I was also able to do all 4 record creation steps within the same pipeline.


Forum|alt.badge.img+15
  • Registered
  • September 27, 2024

Amy,

I would suggest target it this way.

Step A is when a Master Record is Created

Step  B is to Search the Status Table

Step C is inside the loop from the Search

This will let you add statuses or change the duration for any status with out changing your Pipeline

{{ a.start_date.replace(day=1) + time.delta(months='b.duration') }}


Forum|alt.badge.img+15
  • Registered
  • September 30, 2024

Amy,

Since this is linear, I would use two Pipelines and this architecture

 

Pipeline One will fire when the Master Timeline record is created.

It creates one Time Status record where Due Date =

{{ a.start_date.replace(day=1) + time.delta(months=3) }} 

Pipeline Two will fire when a Timeline Status record is created

Step B is to Search for the Master Timeline record

Now you need some If Conditions

If # of Status Records  < # Required

Then Create another Timeline Status Record

where Due Date =

{{ a.max_due_date.replace(day=1) + time.delta(months=3) }}

If # of Status Records  = # Required

Then Create another Timeline Status Record

where Due Date =

{{ a.completion_date + time.delta(days=1) }}

If # of Status Records  > # Required

Then END

Creating that final Timeline Status record will fire Pipeline #2 again but it ENDS and nothing else happens.

 


MarkShnierYou
Forum|alt.badge.img+24

AmyGosz 

In the past I have use this technique to create a variable number of child records.  

I create an Admin Record in a table with just 1 record to record the Record ID# of the Focus Masters.  I create a relationship where One Masters has many Admins  and I look up any fields which will be required to determine how many Child record will need to be created from Masters down to the admin record.

Then I create a helper table say with 100 records in it.  Using a formula based on the the native Record ID field or another field that I populate I make sure that there is a field numbered 0 to 100. Call this [Month#].

Then make a formula field to calculate the first day of the month based on a starting date plus the number of Months in [Month#].

I then create a formula field with a value of 1, to link to the Admin record and lookup any fields I need to determine if the month is valid to be imported into Statuses. 

Then you will have to use your formula skills to come up with a checkbox formula Field to determine which of those 100 future months are valid to be created a a status record.

So then the last step would be to have a button which initiates a pipeline which would set the admin record on the focus master thus causing the helper table records to auto check box if they are valid to be created as a status record and then have the pipeline look for those valid records and create status children. 

 


Forum|alt.badge.img+6
  • Author
  • Registered
  • October 7, 2024

After further discussion with the requesters, it was determined that only one record at a time needs to be created. The first record will be created based on a particular field being populated. Subsequent records will be created based on the first (or previous) record's progress status being updated. However, if that status is 'completed', then no additional records will be created. This allows for the ability  to create unlimited records until no longer needed.

Thank you for all the suggestions as those still may come in handy with a different use case.