Abonnieren

UiPath Robot

Anleitung für UiPath Robot

SDK-Spezifikationen

Die folgenden Methoden und Eigenschaften können in Ihrer benutzerdefinierten Anwendung oder Webseite enthalten sein:

SDK-Spezifikationen

Init

Der/die/das init method is optional. It returns the IRobotSDK instance, which enables you to store it as a variable for later use.

UiPathRobot.init()

Get Process

Der/die/das 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(processList => {
  for(let i=0; i<processList .length;i++){
    console.log(processList[i].name);
  }
}, err => {
  console.log(err);
});

Prozessdetails abrufen

The description of the process can be retrieved directly after getting the process list as the description property of every process in the processList.

const robot = UiPathRobot.init();
robot.getProcesses()
.then(processList => {
  for(let i=0; i<processList.length;i++){
    console.log(processList[i].description);
  }
}, err => {
  console.log(err);
});

Schema für Eingabeargumente abrufen

Die Eingabeargumente eines Prozesses können mit der Eigenschaft inputArgumentsSchema eines installierten Prozesses abgerufen werden.

Bevor Sie die Eigenschaft inputArgumentsSchema verwenden, müssen Sie zuerst den Prozess installieren.

Die Eingabeargumentliste ist eine Liste von Entitäten, die die folgenden Eigenschaften haben:

  • installedProcess.inputArgumentsSchema[0].name – String – Der Name des Eingabearguments
  • installedProcess.inputArgumentsSchema[0].type - String - Der .Net- Typ des Eingabearguments
  • installedProcess.inputArgumentsSchema[0].isRequired – Bool
  • installedProcess.inputArgumentsSchema[0].hasDefault – Bool
const robot = UiPathRobot.init();
robot.getProcesses()
.then(processList => {
  installedProcess = await (processList[0].install)
  for(let i=0; i<installedProcess.inputArgumentSchema.length;i++){
    console.log("Argument" + i + "name: " + installedProcess.inputArgumentsSchema[i].name)
    console.log("Argument" + i + "type: " + installedProcess.inputArgumentsSchema[i].type)
    console.log("Argument" + i + "isRequired: " + installedProcess.inputArgumentsSchema[i].isRequired)
    console.log("Argument" + i + "hasDefault: " + installedProcess.inputArgumentsSchema[i].hasDefault)
  }
}, err => {
  console.log(err);
});

Start Job

Der/die/das 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);
});

Auf

Der/die/das 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')});

Prozessstart

Der/die/das 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);
});

Prozessstart bei Status

Der/die/das 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);
});

Stop Process

Der/die/das 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);
}

Auftrag auf

Der/die/das 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);
});

Einstellungen

Der/die/das 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 = 1000

Modelldefinitionen

Einstellungen

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

RobotProcess

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>;
}

JobResult

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

Auftrag

class Job {
    processId: string;
    argument?: any;
    jobId: string;

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

Aktualisiert vor 4 Monaten


SDK-Spezifikationen


Auf API-Referenzseiten sind Änderungsvorschläge beschränkt

Sie können nur Änderungen an dem Textkörperinhalt von Markdown, aber nicht an der API-Spezifikation vorschlagen.