I just discovered a strange quirk in the way the AE handles tasks like this.
When a job that use an agent group with mode all starts, the task will initially be added to the EH/AH table with the type JOBS. But then, when the AE resolves the agent group, it changes the type to C_HOSTG. Because of this, you may get different results depending on when you read the information, and depending on how busy the AE system is.
Inserting a :WAIT statement increases the likelihood that the resolution of the agent group will have been completed. Adding the WAIT parameter to the ACTIVATE_UC_OBJECT function guarantees it.
With :WAIT statement
Script:
:SET &JobName# = "UC4.AGENT_GROUP_TEST.JOBS"
:SET &RunID# = ACTIVATE_UC_OBJECT(&JobName#)
:PRINT "Started task run ID : &RunID#"
:SET &Task_Type# = GET_STATISTIC_DETAIL(&RunID#,OBJECT_TYPE)
:PRINT "Started task type : &Task_Type#"
:WAIT 5
:SET &Task_Type# = GET_STATISTIC_DETAIL(&RunID#,OBJECT_TYPE)
:PRINT "Started task type : &Task_Type#"
Output:
U00007000 'UC4.AGENT_GROUP_TEST.JOBS' activated with RunID '0160570099'.
U00020408 Started task run ID : 0160570099
U00020408 Started task type : JOBS
U00020408 Started task type : C_HOSTG
With WAIT parameter in ACTIVATE_UC_OBJECT function
Script:
:SET &JobName# = "UC4.AGENT_GROUP_TEST.JOBS"
:SET &RunID# = ACTIVATE_UC_OBJECT(&JobName#,WAIT)
:PRINT "Started task run ID : &RunID#"
:SET &Task_Type# = GET_STATISTIC_DETAIL(&RunID#,OBJECT_TYPE)
:PRINT "Started task type : &Task_Type#"
Output:
U00007000 'UC4.AGENT_GROUP_TEST.JOBS' activated with RunID '0160570099'.
U00020408 Started task run ID : 0160542884
U00020408 Started task type : C_HOSTG