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
amritamrit 

Urgent :Workflow is not working while creating record

Hi,

 

I have created a trigger in a custom object to update a currency field Actual CPi .I want Same field to update in another field Proposed CPi which is editable.Hence i used workflow to update Actual CPI in Proposed CPI.When i create a new record the Actaul CPI will update the value.But Proposed CPi doesnt update the Actual CPI. 

Based on execution order trigger will run first .How can i update the workflow when i create the record.

 

I used this formula for workflow :

ISCHANGED(ActualCPI)

criteria:Evaluate the rule when a record is created, and every time it’s edited

Thanks

 

 

sandeep@Salesforcesandeep@Salesforce
field update on proposed CPi right?
liron169liron169

Hello,

 

try to modify the criteria in the workflow:

 

ISCHANGED(ActualCPI) || ISNEW()

amritamrit

Hi Sandeep,

 

yes Im updating on Proposed CPI

 

amritamrit

hi,

 

Yes i tried same criteria in workflow.Not working

liron169liron169

Possible you're using the option to fire the workflow:

"created, and any time it’s edited to subsequently meet criteria"

if so try the option:

"created, and every time it’s edited"

 

 

Another advise is to try and view what is going thru the system log.

After running the process you suppose to see something like:

09:52:08.240 (240273000)|WF_RULE_EVAL_BEGIN|Assignment
09:52:08.240 (240334000)|WF_RULE_EVAL_BEGIN|Response
09:52:08.240 (240355000)|WF_RULE_EVAL_BEGIN|Workflow
09:52:08.240 (240395000)|WF_CRITERIA_BEGIN|[Case: 00001005 500L0000001w5GB]|Testing Rule|01QL00000004Xp4|ON_ALL_CHANGES
09:52:08.240 (240853000)|WF_FORMULA|Formula:ISPICKVAL( Status , 'NEW')|Values:Status=New
09:52:08.240 (240865000)|WF_CRITERIA_END|true
09:52:08.273 (273070000)|WF_SPOOL_ACTION_BEGIN|Workflow
09:52:08.290 (290148000)|WF_FIELD_UPDATE|[Case: 00001005 500L0000001w5GB]|Field:Case: Description|Value:Updated|Id=04YL00000004Pb5|CurrentRule:Testing Rule (Id=01QL00000004Xp4)
09:52:08.290 (290195000)|WF_ACTION| Field Update: 1;
09:52:08.290 (290212000)|WF_RULE_EVAL_BEGIN|Escalation
09:52:08.290 (290221000)|WF_RULE_EVAL_END
09:52:08.308 (308913000)|WF_ACTIONS_END| Field Update: 1;

This might help you to know if your workflow rule is being called at all, and if so if the condition is true/false.

amritamrit

Hi ,

 

Im using 'created, and every time it’s edited' because ISCHANGED will not support other criteria.

This is log which i got 

13:56:00.160 (160510000)|WF_CRITERIA_BEGIN|[Opportunity(C): AOL a0AN00000019zTu]|Update Proposed CPI|01QN0000000CpXd|ON_ALL_CHANGES
13:56:00.160 (160703000)|WF_FORMULA|Formula:ISCHANGED( Actual_CPI__c )|| ISNEW()|Values:Actual_CPI__c=0
13:56:00.160 (160715000)|WF_CRITERIA_END|true

 Still value is not updating.

liron169liron169

Than you can see that the workflow is called and the criteria is true.

keep looking at log if it does the update after the WF_CRITERIA_END

 

In my example it's:

 

09:52:08.273 (273070000)|WF_SPOOL_ACTION_BEGIN|Workflow
09:52:08.290 (290148000)|WF_FIELD_UPDATE|[Case: 00001005 500L0000001w5GB]|Field:Case: Description|Value:Updated|Id=04YL00000004Pb5|CurrentRule:Testing Rule (Id=01QL00000004Xp4)
09:52:08.290 (290195000)|WF_ACTION| Field Update: 1;
amritamrit

No there is no update in system log.

 

Im using a trigger to update Actual CPI.I think trigger is running always.

This is the trigger.Im uisng before insert and before update.

 

trigger CPIupdatevalues on Opportunity__c (before insert, before update) {

Set<Decimal> comp = new Set<Decimal>();
Set<Decimal> bid = new Set<Decimal>();
Set<Decimal> inc=new Set<Decimal>();
List<String> aud=new List<String>();

List<String> market=new List<String>();
List<String> ratecard =new List<String>();

for(Opportunity__c l : trigger.new){
    if(l.Completes_Required__c != null){
        comp.add(l.Completes_Required__c);
       } 
    if(l.Bid_LOI_in_minutes__c != null){ 
        bid.add(l.Bid_LOI_in_minutes__c);
        }
    if(l.Incidence_Rate__c != null)
    {
        inc.add(l.Incidence_Rate__c);
     }
    if(l.Audience_B2B_B2C__c == 'B2B' || l.Audience_B2B_B2C__c == 'Gen Pop' &&l.Audience_B2B_B2C__c != 'Niche' )
    {    
        aud.add(l.Audience_B2B_B2C__c);
    }
    if(l.Market__c != null)
    {
        market.add(l.Market__c);
    }
   if(l.Rate_Card__c != null)
   {
     ratecard.add(l.Rate_Card__c);
   }
}
//If audience is B2B or Genpop

if(aud.size()> 0)
{
Map<Decimal, CPI__c> cpi1 = new Map<Decimal, CPI__c>();


for(CPI__c obj1 : [SELECT Id, Bid_LOI_in_minutes__c,Actual_CPI__c,Actual_CPIchanged__c,Audience__c, Completes_Required__c,Name,Market__c FROM CPI__c WHERE    Bid_LOI_in_minutes__c IN :bid
                               AND  Completes_Required__c IN: comp AND Incidence_Rate__c IN:inc AND Audience__c IN:aud AND Name IN:ratecard AND Market__c IN:market  ]){
    cpi1.put(obj1.Completes_Required__c , obj1);
    system.debug('CPI'+cpi1);
}
system.debug('@@@@@@@@@@@@@@<@@@cpi @@@@@@@@'+'cpi1 ');

// We have all the reference data we need, last loop on the each Opportunity
if(cpi1.size()>0){
for(Opportunity__c l1 : trigger.new){

       
        l1.Actual_CPI__c = cpi1.get(l1.Completes_Required__c).Actual_CPIchanged__c;//Here Im updating Actual CPI .
       
    
    
}
}
else
{
for(Opportunity__c l1 : trigger.new){
    l1.Actual_CPI__c =0;
    
    }
}


}

if(aud.size()== 0)
{

// Now we have a set of unique bid names we want to verify, time to look them up.


for(Opportunity__c l : trigger.new){
    l.Actual_CPI__c =0;
    
    }


}

}

 Is this because of this trigger ?

liron169liron169

I would check the workflow field update.

 

It's sounds weird that you see and in log the criteria is met, but no additional action from the workflow there.