How to determine whether a process was run from an Orchestrator

Hello.

I would like to understand whether there’s a possibility to determine if a process was started from an Orchestrator or manually from Studio. Is it possible?

It should be that I have a stage in my program where I check if it’s launched from the Orchestrator or from the Studio (maybe from the Robot tray too)

Hey Georgiy,

Go to the jobs page and check the source column

regards
Aditya

@aditya.prakash
How do I do it in program, inside a xaml file?

go to the Orchestrator page under jobs page and check the source column

@aditya.prakash Thank you, I mean that I want my robot to be able to check whether the job has been started via the Orchestrator or from the UiPath Studio directly. I need to check it in the workflow, not manually by visiting the Orchestrator page.

This won’t show jobs that were run from Studio and not executed using either schedule, robot tray, or manually from Orchestrator.

In order to see all those processes plus those run from Studio you’d have to access the Robot Logs from the Robot page in Orchestrator.

You could also use the Orchestrator API to return these robot logs to a robot at run time but there is not clear indicator of the source in the records. Theoretically you could check the end of the process name for an Environment from Orchestrator and if it included one at the end that would tell you it was run from orchestrator (schedule/robot tray/manually) and any without an environment name should be from Studio. There may be better methods though.

@Tyler_Williams

see the image below, I have run a process with scheduler(the name of scheduler is first schedule) and manually.

if you have attended academy training of Orchestrator then this is a question also…

@MGMKLML it is for your Reference, Happy Automation :wink:

Regards
Aditya

1 Like

Hi Georgiy,

if you need to check by your workflow, then create a workflow to login to orchestrator, navigate to jobs page and check the source of the running process.

it would be the steps to determine the same

regards
Aditya

Is there any way to do the same using API/Orchestrator activities. For a job running, the robot should fetch the Job name, the user id who configured/started the job(as well as the email id of the user), the environment etc. How can this be implemented.

1 Like

Hareeshks,

did you ever work this out ?

regards
Phil

I needed something similar.

To determine whether the current job is running on orchestrator, I use Split(Environment.CurrentDirectory,"\") to get the nodes in the current directory. In my case if there are .nuget, packages, lib, or net45 nodes, then I know the job is running from orchestrator. This may or may not work for you, depending on your local and published paths.

For notifications, I use a job config table or spreadsheet with columns to control paths, databases, queues, environment setup details, retry strategies, text and email notifications, etc. I include an input parameter to jobs that is the Id for a row in this table. This way job config is set as a batch of values at the beginning of each job. The person notified can be different than the agent who started the job (api, queue ended, scheduled, a different operator).

In terms of getting the Job name using the API, there’s not a Name but there’s a ReleaseName, which is the process on Orchestrator.

  1. To get job values for the current running job, I 1st need to know the robot’s Id number. You can get this by building a lookup table based on query results of the UiPath.dbo.Robots table where IsDeleted=0, or based on a full retrieval through the API of all (undeleted) Robots.
    The Robots API data includes Name, Username, and Id. At runtime you can get the Environment.UserName for the current job. This equals the Name (not the Username) for the database or the API:

    Use this value to filter the endpoint you’re using, like this:
    GetRobotIdWithApi_01
    From the results, get the Id of your robot.
  2. After you have the robot’s Id, use that to limit the Jobs endpoint for the API. For instance, if my Robot Id is 123, and I’m on premise, and I want the actively-running job for robot 123, then my endpoint will be something like this:

    (When you copy the endpoint from a browser, URL encoding will automatically carry over to Studio.)
    From these API results, you can get the ReleaseName or any other job-related values: Key,StartTime,EndTime,State,Source,SourceType,BatchExecutionKey,Info,CreationTime,StartingScheduleId,ReleaseName,Type,InputArguments,OutputArguments,HostMachineName,HasMediaRecorded,PersistenceId,ResumeVersion,StopStrategy,ReleaseVersionId,Id.

It would be easier to get related job information with fewer steps if the RobotId was returned from the API for Jobs-related endpoints. This would match the design of the UiPath.dbo.Jobs table, which includes columns for both RobotId and also CreatorUserId. CreatorUserId relates to the Users table, which has an EmailAddress field. There might be a better way to do these types of lookups (within a running job, at runtime, a way to ask directly, what is my robot Id?, what is my creator Id?), but I haven’t found it. However, using the steps above, I get the information that I want. I’m able to automatically schedule a new job using the API, when some jobs end without finishing their queue, under certain circumstances - which is my goal.

1 Like