Set agent group of a job programmatically

Discussion created by Michael_Lowry on Feb 9, 2016
Latest reply on Feb 22, 2018 by Michael_Lowry

The following JOBI, UC4.RESOLVE_AGENT_GROUP.JOBI, allows one to set an agent group programmatically/dynamically.


See the updated version of this JOBI in the comment below.
To use the JOBI, just include a few lines in the process tab of the parent workflow of the jobs that will use this agent group:

This JOBI acts like a function:

  •  Input: &AGENT_OR_AGENTGROUP# — the name of anagent or an agent group.
  • Output: &AGENT# —
    • If &AGENT_OR_AGENTGROUP# contains the name of anagent, then this agent name (if it is active);
    • If &AGENT_OR_AGENTGROUP# contains the name of anagent group, then the next active agent in that agent group.
Then simply insert :PUT_ATT HOST = &ACTUAL_TARGET_AGENT# into the pre-process of any job that should run on the agent or agent group. (If the job is a file transfer job, put the attribute FT_SRC_HOST or FT_DST_HOST instead.) And again, this approach works whether &AGENT_OR_AGENTGROUP# is set to the name of an agent or an agent group.  

Update: for an updated version, see this comment, below.

For an alternative, check out the clever approach by 
joel_wiesmann_automic that uses nested workflows and a VARA object reference.