Announcement
Collapse
No announcement yet.
workflow help on relations Many-to-One and One-to-Many.
Collapse
X
-
Hi Maximus ,
In this interface I wanted to update "Stock" field with the related stock record which is created on current month.
Example-
if current month January
Stock = Pack, January 2021
if current month February
Stock = Pack, February 2021
Every month Stock field should change with the current month stock record. Only one record will create for every month for each item.
Cheers!
Nishan.
- Likes 1
Comment
-
This makes sense.
Well, I see it with this way.
1. Create a Workflow for the target record:
- Trigger type: After record creation
- Action: Update target record -> you will need to write a huge formula here
2. How I see it:
Code:// Determine the month of the createdAt field and convert it to a raw format. E.g.: $month = ''; $year = datetime\year(createdAt); $stockName = '' ifThen( datetime\month(createdAt) == 1, $month = 'January'; $stockName = string\concatenate("Pack, ", $month, " ", $year) ); ifThen( datetime\month(createdAt) == 2, $month = 'February'; $stockName = string\concatenate("Pack, ", $month, " ", $year) ); //Other condition to determine the rest months. .... // Fetch ID of the Stock record with this formula https://docs.espocrm.com/administration/formula/#recordfindone. E.g.: $id = record\findOne('Stock', 'createdAt', 'desc', 'name=', $stockName); // Link the target record with to a Stock. stockId = $id;
Comment
Comment