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
Kim AmaralKim Amaral 

Stop Aging Once Criteria is Met

I am trying to create an aging field to see how many days it takes for items to be inventoried.

I have an "Aging" field (with formula: "TODAY() -  Delivery_Date__c"),  a "Delivery Date" (date format), and a picklist "Inventory Status".  

The Aging field is counting how many days from the "Delivery Date" to today, but I need it to stop once the "Inventory Status" is switched to "Needs Pricing". 

I was trying to change my "Aging" formula to
 IF(ISPICKVAL(Inventory_Status__c,'Awaiting Inventory'), TODAY() - Delivery_Date__c)
but i get the following error "Error: Incorrect number of parameters for function 'IF()'. Expected 3, received 2"



 
an2014an2014
Try this :: IF(ISPICKVAL(Inventory_Status__c,'Awaiting Inventory'), TODAY() - Delivery_Date__c,Aging__c)
Kim AmaralKim Amaral
I received this error

"Error: Formula cannot use another formula field that directly or indirectly refers to itself. Cohort__c.Aging__c -> Cohort__c.Aging__c"

 
an2014an2014

Hi Kim

The format of If is IF(condition, what to do if true, what to do if false) 

Maybe you should try wf rules instead of formula.
Kim AmaralKim Amaral
I thought of that as well but WF rules get the field to update when the criteria is met where I want it to not update when criteria is med. Any suggestions?
an2014an2014
User-added image

Change from Criteria is met to formula evaluates to true and enter your condition
William TranWilliam Tran
The Aging field is counting how many days from the "Delivery Date" to today, but I need it to stop once the "Inventory Status" is switched to "Needs Pricing". 

I need it to stop? does that mean you want it to be 0?

I was trying to change my "Aging" formula to
 IF(ISPICKVAL(Inventory_Status__c,'Awaiting Inventory'), TODAY() - Delivery_Date__c)

Why are you comparing to "Awaiting Inventory" when you mentioned "Needs Pricing" above?

Based on what what I can surmised, your formula could be like this:
 
IF(ISPICKVAL(Inventory_Status__c,'Awaiting Inventory'), TODAY() - Delivery_Date__c,0)

Which means age is only valid for status "Awaiting Inventory", otherwise age is not valid and set to 0.

Thx.