robot
2021.10
false
UiPath logo, featuring letters U and I in white
OUT OF SUPPORT
Robot User Guide
Last updated Nov 11, 2024

SDK Specifications

The following methods and properties can be included in your custom application or web page:

SDK Specifications

Init

The init method is optional. It returns the IRobotSDK instance, which enables you to store it as a variable for later use.
UiPathRobot.init()UiPathRobot.init()

Get Process

The Get Process method retrieves and displays the list of available processes. If the Robot is connected to Orchestrator, it retrieves the processes from the environment and folder the Robot is a part of. If it's not connected to Orchestrator, local processes are displayed.
const robot = UiPathRobot.init();
robot.getProcesses()
.then(result => {
  for(let i=0; i<result.length;i++){
    console.log(result[i].name);
  }
}, err => {
  console.log(err);
});const robot = UiPathRobot.init();
robot.getProcesses()
.then(result => {
  for(let i=0; i<result.length;i++){
    console.log(result[i].name);
  }
}, err => {
  console.log(err);
});

Start Job

The Start Job method starts a process by its ID and input arguments, if any.
let arguments = {
  "input1" : 23,
  "input2" " 42,
  "operation" : "add"
};
const robot = UiPathRobot.init();
robot.getProcesses()
.then(process => {
  let calculatorProcess = processes.find(p => p.name.includes('Calculator'));
  let job = new job(calculatorProcess.id, arguments);
  robot.startJob(job).then(result => {
    console.log(result.Sum);
  }, err => {
    console.log(err);
  })
}, err => {
  console.log(err);
});let arguments = {
  "input1" : 23,
  "input2" " 42,
  "operation" : "add"
};
const robot = UiPathRobot.init();
robot.getProcesses()
.then(process => {
  let calculatorProcess = processes.find(p => p.name.includes('Calculator'));
  let job = new job(calculatorProcess.id, arguments);
  robot.startJob(job).then(result => {
    console.log(result.Sum);
  }, err => {
    console.log(err);
  })
}, err => {
  console.log(err);
});
The On method is used to attach event handlers on the SDK. The UiPath JavaScript SDK comes with a built-in consent overlay displayed every time your custom application or web page needs to connect to the Robot. This consent overlay can be overridden with a custom handler.
const robot = UiPathRobot.init();
robot.on('consent-prompt', (consentCode) => {console.log(consentCode)});
robot.on('mising-components', () => {console.log('Missing Components')});const robot = UiPathRobot.init();
robot.on('consent-prompt', (consentCode) => {console.log(consentCode)});
robot.on('mising-components', () => {console.log('Missing Components')});

Process Start

The Process Start method is used to start a process by passing it input arguments, if available.
let arguments = {
  "input1" : 23,
  "input2" " 42,
  "operation" : "add"
};
const robot = UiPathRobot.init();
robot.getProcesses()
.then(process => {
  let process = processes.find(p => p.name.includes('Calculator'));
  process.start(arguments).then(result => {
    console.log(result.Sum);
  }, err => {
    console.log(err);
  })
}, err => {
  console.log(err);
});let arguments = {
  "input1" : 23,
  "input2" " 42,
  "operation" : "add"
};
const robot = UiPathRobot.init();
robot.getProcesses()
.then(process => {
  let process = processes.find(p => p.name.includes('Calculator'));
  process.start(arguments).then(result => {
    console.log(result.Sum);
  }, err => {
    console.log(err);
  })
}, err => {
  console.log(err);
});

Process Start On Status

The Process Start On Status method is used to start a process and attach the status callback by passing the callback handler.
let arguments = {
  "input1" : 23,
  "input2" " 42,
  "operation" : "add"
};
let globalHandler = (status) => {console.log(status)};
const robot = UiPathRobot.init();
robot.getProcesses()
.then(processes => {
  let statusHandler = (status) => {console.log('Calculator Process Status -' + status)};
  let process = processes.find(p => p.name.includes('Calculator'));
  process.start(arguments)
  .onStatus(globalHandler)
  .onStatus(statusHandler)
  .then(result => {
    console.log(result.Sum);
  }, err => {
    console.log(err);
  })
}, err => {
  console.log(err);
});let arguments = {
  "input1" : 23,
  "input2" " 42,
  "operation" : "add"
};
let globalHandler = (status) => {console.log(status)};
const robot = UiPathRobot.init();
robot.getProcesses()
.then(processes => {
  let statusHandler = (status) => {console.log('Calculator Process Status -' + status)};
  let process = processes.find(p => p.name.includes('Calculator'));
  process.start(arguments)
  .onStatus(globalHandler)
  .onStatus(statusHandler)
  .then(result => {
    console.log(result.Sum);
  }, err => {
    console.log(err);
  })
}, err => {
  console.log(err);
});

Stop Process

The Stop Process method is used to stop an executing or running robot process. Returns a promise which is resolved on successful cancellation of running robot process.
try {
  const robot = UiPathRobot.init();
  const robotProcessId = 'MyRunningRobot';
  const processes = await robot.getProcesses();
  const myProcess = processes.find(function(process){return process.name.includes(robotProcessId)});
  await robot.stopProcess(myProcess);
  console.log(robotProcessId +' cancelled successfully');
} catch (e) {
  console.log(robotProcessId +' cancellation failed -'+ e);
}try {
  const robot = UiPathRobot.init();
  const robotProcessId = 'MyRunningRobot';
  const processes = await robot.getProcesses();
  const myProcess = processes.find(function(process){return process.name.includes(robotProcessId)});
  await robot.stopProcess(myProcess);
  console.log(robotProcessId +' cancelled successfully');
} catch (e) {
  console.log(robotProcessId +' cancellation failed -'+ e);
}

Job On

The Job On method is used to attach an event handler to retrieve on going process statuses.
let arguments = {
  "input1" : 23,
  "input2" " 42,
  "operation" : "add"
};
const robot = UiPathRobot.init();
robot.getProcesses().then(processes => {
  let calculatorProcess = processes.find(p => p.name.includes('Calculator'));
  let job =new job(calculatorProcess.id, arguments);
  job.on('status', (robotStatus) => {console.log(robotStatus)});
  robot.startJob(job).then(result => {
    console.log(result.Sum);
  }, err => {
    console.log(err);
  })
}, err => {
  console.log(err);
});let arguments = {
  "input1" : 23,
  "input2" " 42,
  "operation" : "add"
};
const robot = UiPathRobot.init();
robot.getProcesses().then(processes => {
  let calculatorProcess = processes.find(p => p.name.includes('Calculator'));
  let job =new job(calculatorProcess.id, arguments);
  job.on('status', (robotStatus) => {console.log(robotStatus)});
  robot.startJob(job).then(result => {
    console.log(result.Sum);
  }, err => {
    console.log(err);
  })
}, err => {
  console.log(err);
});

Settings

The Settings method allows you to edit the default port number and poll interval time in milliseconds.
const robot = UiPathRobot.init();
robot.settings.portNumber = 1234;
robot.settings.pollTimeInterval = 1000const robot = UiPathRobot.init();
robot.settings.portNumber = 1234;
robot.settings.pollTimeInterval = 1000

Model Definitions

Settings

class Settings {
    portNumber: number;
    pollTimeInterval: number;
}class Settings {
    portNumber: number;
    pollTimeInterval: number;
}

RobotProcess

class RobotProcess {
    id: string;
    name: string;
    constructor(id: string, name: string);
    start: (inArguments?: any) => JobPromise;
}class RobotProcess {
    id: string;
    name: string;
    constructor(id: string, name: string);
    start: (inArguments?: any) => JobPromise;
}

IRobotSDK

interface IRobotSDK {
    settings: Settings;
    getProcesses(): Promise<Array<RobotProcess>>;
    init(): IRobotSDK;
    on(eventName: string, callback: (argument?: any) => void): void;
    startJob(job: Job): Promise<JobResult>;
}interface IRobotSDK {
    settings: Settings;
    getProcesses(): Promise<Array<RobotProcess>>;
    init(): IRobotSDK;
    on(eventName: string, callback: (argument?: any) => void): void;
    startJob(job: Job): Promise<JobResult>;
}

JobResult

/**
 * Job result model containing all output arguments from the process.
 * Empty if there are no out arguments.
 */
class JobResult {
    [Key: string]: any;
}/**
 * Job result model containing all output arguments from the process.
 * Empty if there are no out arguments.
 */
class JobResult {
    [Key: string]: any;
}

Job

class Job {
    processId: string;
    argument?: any;
    jobId: string;
    constructor(processId: string, argument?: any);
    on(eventName: string, eventHanlder: (argument?: any) => void): void;
}class Job {
    processId: string;
    argument?: any;
    jobId: string;
    constructor(processId: string, argument?: any);
    on(eventName: string, eventHanlder: (argument?: any) => void): void;
}

Was this page helpful?

Get The Help You Need
Learning RPA - Automation Courses
UiPath Community Forum
Uipath Logo White
Trust and Security
© 2005-2024 UiPath. All rights reserved.