Passing value from one workflow activity to another activity

mkm1
Mega Guru

In a workflow I am using following to script to find out if an activity is started or not using GlideRecord and also find out if activity has been delayed. If it's delayed I am setting a Scratchpad variable. In next workflow activity want to find out the value in scratchpad variable to perform next set of activity. In next activity I am unable to access the value in scratchpad variable, is there way to pass value from one activity to another. Note : I don't want to run the same glide query again in next activity. Below are the script of for Activity 1 and Activity 2:

Activity 1:

  answer = ifScript();
  
  function ifScript() {
   var gr_pam=new GlideRecord('x_20949_ppt_pre_award_milestones');
   gr_pam.addQuery('action',current.sys_id);
   gr_pam.addQuery('milestone.stage','Planning');
   gr_pam.addQuery('planned_finished_date','DOES NOT CONTAIN','(empty)');
   gr_pam.query();
   var v_planStatus='Pending';
   var v_plannedFinish=new GlideDate().getDisplayValue();
   var v_beyondPlanned='No';
   while (gr_pam.next())
       {
        if (gr_pam.planned_finished_date < v_plannedFinish)
     {
     v_beyondPlanned = 'Yes';
    }
    if (gr_pam.actual_start_date=='' || gr_pam.actual_start_date==null)
     {
    }
    else
     {
     v_planStatus= 'Started';
    }
    
   }
   if (v_beyondPlanned=='Yes')
    {
    workflow.scratchpad.beyondPlanned = 'Yes';
   }
   
   if (v_planStatus == 'Started') {
    return 'Yes';
   }
   
   return 'No';
  }

 

Activity 2:

  gs.info('3 checking if planning delayed condition');
  var myValue = workflow.scratchpad.beyondPlanned;
  if (myValue == 'Yes')
   {
   return 'yes';
  }
   return 'no';
2 REPLIES 2

Nitesh Balusu
Giga Guru

Can you try and use this in both activities. replace with v_beyondPlanned.

  workflow.scratchpad.v_beyondPlanned 

mkm1
Mega Guru

Thanks Nitesh. Mistake was in Activity 2 script which was not setting the value of answer to Yes or No. Once corrected it's working perfectly.