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
TsvetyTsvety 

Help with a workflow using ISCHANGED

I have a custom object Offers that pulls data from the Opportunity. I have a field, Expenses covered, on Opportunity and I want to have a field on the Offer that will be updated every time the Expenses covered on the Opportunity is changed.
The problem is that the workflow doesn't trigger even though the value of the formula field is changed.

What I did so far:
Created a text field (Expenses covered new) and a formula field (Expenses covered f) on Offer.

Created a Workflow rule on Offer. 
Entry Criteria (ISCHANGED( Expenses_Covered_f__c ))
Field Update for Expenses covered new = Expenses_Covered_f__c 
Evaluation Criteria; Evaluate the rule when a record is created, and every time it’s edited

Where is the problem?
SarfarajSarfaraj
Change in value for a formula does not triggers workflow rules. You have design the problem in some other manner.
  1. If you are comfortable in apex, you may write a trigger on Opportunity update on after update event and update all related Offer records if value for expenses is changer.
  2. Use visual workflow. This one is my favorite. You do not need any custom code. Go to 'Process Builder' from setup and create one visual workflow on opportunity with criteria is changed on expense field. Add one update action on related Offers to update the expense field.
Let me know if you need any help on implementing either one of these.

--Akram
 
TsvetyTsvety
Hi Akram,

I am trying with the Process Builder, but the field still doesn't get updated.

Here is my entry criteria:
User-added image

Here is the Field update (I will later update it to the actual formula)

User-added image
 
K_McRaeK_McRae
Tsvety,

I have just run a sandbox test and managed to get child objects updated when a change was made to the parent record.

Can I suggest that you strip your process back to the bare bones and verify whether the problem is in the criteria or the action.

My criteria:
User-added image

My Action:
User-added image

cheers,
Keith
SarfarajSarfaraj
@Keith yes you are absolutely correct. Just identified that ISCHANGED function does not work in visual workflow. I am a bit confused about the reason of it being in the pulldown menu, if it does not work. Maybe SF is working on making it available shortly.


Tsvety,

I didn't know this fact. So you have to go with the trigger. Here is one sample trigger I wrote for you. This is not tested, but hopefully it will work. Let me know if this works,
Tsvetytrigger UpdateOfferFromOpportunity on Opportunity (after update) {
	List<Offer__c> offerList = new List<Offer__c>();
    for (Opportunity o : [Select Id, Expenses_Covered_f__c , (Select Id From Offers__r) From Opportunity Where Id in :Trigger.new])
	{
        if(Trigger.oldMap.get(o.Id).Expenses_Covered_f__c != o.Expenses_Covered_f__c)
		{
			for(Offer__c offer : o.Offers__r)
			{
				offer.Expenses_covered_new__c = o.Expenses_Covered_f__c;
				offerList.add(offer);
			}
		}
    }
	update offerList;
}
--Akram
K_McRaeK_McRae
Akram,

Statting that the "ISCHANGED function does not work in visual workflow" is a pretty bold statement!

You can see from the images that I posted above use the Is changed.

I have a number of processes making use of the function.

Keith 
SarfarajSarfaraj
Keith,

Thanks for the pointer. I am not saying that "ISCHANGED" does not work with visual workflow. I am saying that it didn't work for me. Maybe I am doing something wrong. But I have checked the documents,
http://help.salesforce.com/help/pdfs/en/salesforce_vpm_implementation_guide.pdf  (Page no 13)

And this,
https://help.salesforce.com/HTViewHelpDoc?id=vpm_designer_about_formulas.htm&language=en_US

It says,
These functions aren’t supported in a flow formula.
  • GETRECORDIDS
  • IMAGE
  • INCLUDE
  • ISCHANGED
  • ISNEW
  • PARENTGROUPVAL
  • PREVGROUPVAL
  • PRIORVALUE
  • REQUIRE SCRIPT
  • VLOOKUP
--Akram
K_McRaeK_McRae
Akram,

Yes, but the drop down selection of "Is changed" is not a formula, it's a "Conditions are met" criteria... you can't use ISCHANGED in a formula when using the "Formula evaluates to true" criteria:

User-added image

Having said that, you will be in the Summer 15 release:

User-added image

cheers,
Keith
SarfarajSarfaraj
Keith,

Thanks a lot for the update. 

--Akram