function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Nuevo9763Nuevo9763 

Is process builder the solution for this situation?

First of all I am a newbiew and have not used process builder. Is using process builder the right approach for the follwong?
I have a collection of custom object named 'Song', which goes through the following
stages in the same order.
written --> Composed --> Recorded --> Released
For each of these stages I have:
Song Written Date
Song Composed Date 
Song Recorded Date
Song Released Date

I have to display the current status in a new field. IF song is recorded on 9/2/2017
and released 9/24/2017 the status would display the latest status 'Released on
9/24/2017' and would disregard any earlier stages.
Now when I have a collection of songs and I need to dispaly the status which shows the
earliest date.For example in the collection,
Song One has:
Song Written Date - 8/2/2017
Song Composed Date - 9/1/2017
Song Recorded Date - 
Song Released Date

Song two has:
Song Written Date - 8/2/2017
Song Composed Date - 9/1/2017
Song Recorded Date - 9/18/2017
Song Released Date

Then in the above example the status should disply 'Composed on 9/1/2017'
Which is the earliest date between two songs and the latest for song one.

Is this possible to implement using process builder or workflow rule field update? Or
the only way is apex trigger? We want to avoid apex code if possible.


 
Neha AggrawalNeha Aggrawal
Hi MK7,

If I understand correctly, Song one should dispaly current status as 'Composed on 9/1/2017' and Song two should display current status as 'Recorded on 9/18/2017. Is my understanding correct ?
Thanks.
Sachin P Sam 1Sachin P Sam 1
@MK7
There is no need of process builder to achieve this.This can be done using the formula fields .
I tried out this and achieved using the two formula fields,this can be done in one field also.
1. Create a  formula field name 'Current Status Date' as follows,
TODAY()- min(
if(isnull(TODAY()-Song_Written_Date__c),365, TODAY()-Song_Written_Date__c),
if(isnull(TODAY()-Song_Recorded_Date__c),365,TODAY()-Song_Recorded_Date__c),
if(isnull(TODAY()-Song_Composed_Date__c),365,TODAY()-Song_Composed_Date__c),if(isnull(TODAY()- Song_Released_Date__c ),365,TODAY()-Song_Released_Date__c))

This field is not visible in page layout.
2. Create another formula field Which displays the current (latest) status with date .Criteria as,
IF( Current_Status_Date__c == Song_Written_Date__c , "Song Written on"&Text(Current_Status_Date__c),  IF(Current_Status_Date__c == Song_Composed_Date__c , "Song Composed  on"&Text(Song_Composed_Date__c),  IF( Current_Status_Date__c == Song_Recorded_Date__c , "Song Recorded on"&Text(Song_Recorded_Date__c),  IF(Current_Status_Date__c == Song_Released_Date__c ,"Song Released on"&Text(Song_Released_Date__c), "No Current Actions ") ) ) )
This which gives your  targeted output as
User-added image
Formula field is better,since it reevaluates every time.So we get updated status,in less effort.

If you have any queries ,please free to ask.

Mark as the best answer, if this helped you.,it can be useful to others also.

Regards,
Sachin P Sam
 
Nuevo9763Nuevo9763
@Neha, the requirement is when there are multiple songs the status will show only one date and that  will the earliest date between the songs. In other words there is no status per song when there are multiple songs. In my example where there are 2 songs, in the collection,
Song One has:
Song Written Date - 8/2/2017
Song Composed Date - 9/1/2017 - should be the status, which is the earliest date between two songs and the latest for song one.
Song Recorded Date - 
Song Released Date

Song two has:
Song Written Date - 8/2/2017
Song Composed Date - 9/1/2017
Song Recorded Date - 9/18/2017
Song Released Date

Then in the above example the status should disply 'Composed on 9/1/2017'. I think the only way to work on a collection is adding apex code in trigger. Do you think there is any other way?
 
Nuevo9763Nuevo9763
@Sachin, 
your answer is good, but not applicable in this case as when there is a collection of songs, I need to show the status of the song which is at the earliest stage. Please see the example above my reply to Neha. I think the only way to work on a collection is adding apex code in trigger. Do you think there is any other way?
Sachin P Sam 1Sachin P Sam 1
@MK7
If you need to  perform action based on  collection of songs,you need to use apex code.

Regards,
Sachin P Sam 
jordan royjordan roy
Yes i think the solution you gave would be right for this solution. I don't seem to know of any other solution in this situation. Thanks for sharing with us.