The CreatorCon Call for Content is officially open! Get started here.

Trying to get the value of wait_for variable off of a wf_activity for an Approval - Group activity

treycarroll
Giga Guru

I'm trying to find the value of wait_for variable off of a wf_activity (for Approval - Group activity).

Screenshot 2015-02-23 at 10-2.png

I figured out that the wf_activity_variable table references the Approval - Group activity definition, but I still can't figure out how to grab the value of the variable.   I can see that the default value of the wait_for variable.

I have been playing around with the code to try to get this:

//Grab the Approval record

var gr = new GlideRecord('sysapproval_approver');

gr.setLimit(1);

gr.addQuery('sysapproval.number', 'RITM0023610');

gr.query();

while(gr.next()) {

  // Grab the Activity Variable record that

  //   references the Approval - Group activity definition

  var gr2 = new GlideRecord('wf_activity_variable');

  gr2.addQuery('model', gr.wf_activity.activity_definition);

  gr2.query();

  while (gr2.next()) {

      //Show Keys in the wf_activity_variable

      gs.log('***********************************************');

      for (var k in gr2) {

          gs.log(k + ':' + gr2[k]);

      }

      gs.log('***********************************************');

  }

}

This shows me that the field that want is available from the model property.

Screenshot 2015-02-23 at 1.png

I see properties for a wait_for element and I can see a name property of var__m_... property.   So now I feel that I must be very close.   I have confirmed that the var__m_ table exists, but, unfortunately, I cannot query that table.


I don't know much about these var__m_... tables, but I can see that the normal table level entry (that doesn't have a column name) doesn't seem to exist on these tables.

When I try this:

var g   = new GlideRecord('var__m_354e911f0a0a029a00e6a0e6ad74206f');

g.setLimit(1);

g.query();

while(g.next()){

    gs.log(g.wait_for);

}

This causes an error:

JoinQuery invalid field name: .end_split

JoinQuery invalid field name: .split

FAILED TRYING TO EXECUTE ON CONNECTION 14: SELECT 354e911f0a0a029a00e6a0e6ad7420.`approval_script`, 354e911f0a0a029a00e6a0e6ad7420.`relative_duration`, 354e911f0a0a029a00e6a0e6ad7420.`condition`, 354e911f0a0a029a00e6a0e6ad7420.`user_specified_schedule`, 354e911f0a0a029a00e6a0e6ad7420.`.end_split`, 354e911f0a0a029a00e6a0e6ad7420.`timezone_type`, 354e911f0a0a029a00e6a0e6ad7420.`script`, 354e911f0a0a029a00e6a0e6ad7420.`timezone_field`, 354e911f0a0a029a00e6a0e6ad7420.`schedule_field`, 354e911f0a0a029a00e6a0e6ad7420.`field`, 354e911f0a0a029a00e6a0e6ad7420.`reject_handling`, 354e911f0a0a029a00e6a0e6ad7420.`duration`, 354e911f0a0a029a00e6a0e6ad7420.`advanced`, 354e911f0a0a029a00e6a0e6ad7420.`wait_for`, 354e911f0a0a029a00e6a0e6ad7420.`schedule_type`, 354e911f0a0a029a00e6a0e6ad7420.`timer_type`, 354e911f0a0a029a00e6a0e6ad7420.`approver_script`, 354e911f0a0a029a00e6a0e6ad7420.`user_specified_timezone`, 354e911f0a0a029a00e6a0e6ad7420.`.split`, 354e911f0a0a029a00e6a0e6ad7420.`groups` FROM 354e911f0a0a029a00e6a0e6ad7420 354e911f0a0a029a00e6a0e6ad7420 limit 0,1

General Data Exception detected by database (Data truncation: Illegal double '354e911' value found during parsing)

So the wait_for value is still eluding me!

To sum up: There is a wait_for variable for this particular "Approval - Group" wf_activity, but I do not understand how to retrieve the value.

1 ACCEPTED SOLUTION

treycarroll
Giga Guru

I figured it out.     This code logs the value of the variable



var gr = new GlideRecord('sysapproval_group');


gr.addQuery('parent.number','RITM0023610');


gr.query();



while(gr.next()){


    var gr2 =   new GlideRecord('sys_variable_value');


    gr2.addQuery('document_key',gr.wf_activity);


    gr2.addQuery('document','wf_activity');


    //sys_id of wait_for variable is 0698d53c0a0a0b2627f7cf654de211b6.   This is from wf_activity_variable


    gr2.addQuery('variable','0698d53c0a0a0b2627f7cf654de211b6');


    gr2.query();



  while(gr2.next()){


          gs.log(gr2.value);


    }


}



Getting the sys_choice choices for this variable was also an important piece of the puzzle:



Screenshot 2015-02-24 at 12.png


The table name came from the model from the wf_activity_variable (specifically the name property on the model where the element was wait_for).


View solution in original post

1 REPLY 1

treycarroll
Giga Guru

I figured it out.     This code logs the value of the variable



var gr = new GlideRecord('sysapproval_group');


gr.addQuery('parent.number','RITM0023610');


gr.query();



while(gr.next()){


    var gr2 =   new GlideRecord('sys_variable_value');


    gr2.addQuery('document_key',gr.wf_activity);


    gr2.addQuery('document','wf_activity');


    //sys_id of wait_for variable is 0698d53c0a0a0b2627f7cf654de211b6.   This is from wf_activity_variable


    gr2.addQuery('variable','0698d53c0a0a0b2627f7cf654de211b6');


    gr2.query();



  while(gr2.next()){


          gs.log(gr2.value);


    }


}



Getting the sys_choice choices for this variable was also an important piece of the puzzle:



Screenshot 2015-02-24 at 12.png


The table name came from the model from the wf_activity_variable (specifically the name property on the model where the element was wait_for).