Methoden und Eigenschaften
Sie können die folgenden Methoden und Eigenschaften in Ihre benutzerdefinierte Anwendung oder Webseite aufnehmen.
Init
Die Methode initist optional.Es gibt die IRobotSDK-Instanz zurück, sodass Sie sie als Variable zur späteren Verwendung speichern können.
const robot = UiPathRobot.init();
const robot = UiPathRobot.init();
Einstellungen
Mit der Eigenschaft settings vom Typ Einstellungen können Sie die Standardportnummer und das Abfrageintervall in Millisekunden ändern oder das Senden von Telemetriedaten deaktivieren.
const robot = UiPathRobot.init();
robot.settings.portNumber = 1234;
robot.settings.pollTimeInterval = 1000;
robot.settings.disableTelemetry = true;
const robot = UiPathRobot.init();
robot.settings.portNumber = 1234;
robot.settings.pollTimeInterval = 1000;
robot.settings.disableTelemetry = true;
Auf
Die Methode on wird verwendet, um Ereignishandler an das SDK anzufügen.
Die verfügbaren SDK-Ereignisse sind consent-prompt, missing-components und open-uipath-protocol.
Zustimmungsaufforderung
Das UiPath JavaScript SDK verfügt über ein integriertes Zustimmungs-Overlay, das jedes Mal angezeigt wird, wenn Ihre benutzerdefinierte Anwendung oder Webseite eine Verbindung mit dem Roboter herstellen muss.
Dieses Zustimmungs-Overlay kann mit einem benutzerdefinierten Handler überschrieben werden.
const robot = UiPathRobot.init();
robot.on('consent-prompt', consentCode => console.log(consentCode));
const robot = UiPathRobot.init();
robot.on('consent-prompt', consentCode => console.log(consentCode));
fehlende-Komponenten
Das Ereignis missing-components wird ausgelöst, wenn der Robot JS-Dienst nicht ausgeführt wird. In diesem Fall zeigt das SDK einen Fehler an, der mit einem benutzerdefinierten Handler überschrieben werden kann.
const robot = UiPathRobot.init();
robot.on('missing-components', () => console.log('Missing Components'));
const robot = UiPathRobot.init();
robot.on('missing-components', () => console.log('Missing Components'));
open-uipath-protocol
Bevor die Zustimmungsmeldung angezeigt wird, werden Sie möglicherweise aufgefordert, dem Browser zu erlauben, eine uipath-web-URL in der zugehörigen Anwendung zu öffnen.
Standardmäßig versucht RobotJS automatisch, diese URL zu öffnen. Benutzer können dieses Verhalten jedoch überschreiben, indem sie einen benutzerdefinierten Ereignishandler bereitstellen.
const robot = UiPathRobot.init();
robot.on('open-uipath-protocol', (protocolUrl) => console.log('RobotJS protocol URL: ' + protocolUrl));
const robot = UiPathRobot.init();
robot.on('open-uipath-protocol', (protocolUrl) => console.log('RobotJS protocol URL: ' + protocolUrl));
Prozesse erhalten (Get Processes)
The getProcesses method retrieves the list of available processes. Returns a Promise to an array of RobotProcess objects. If the Robot is connected to Orchestrator, it retrieves the processes from the environment and folder the Robot is a part of. Otherwise, local processes are retrieved.
const robot = UiPathRobot.init();
const processes = await robot.getProcesses();
for(let i=0; i<processes.length; i++){
console.log(processes[i].name + " (" + processes[i].description + ") - Id=" + processes[i].id);
}
const robot = UiPathRobot.init();
const processes = await robot.getProcesses();
for(let i=0; i<processes.length; i++){
console.log(processes[i].name + " (" + processes[i].description + ") - Id=" + processes[i].id);
}
Schema für Eingabeargumente abrufen
Mit der Eigenschaft inputArgumentsSchema eines installierten Prozesses können Sie die Eingabeargumente eines Prozesses abrufen. Bevor Sie die Eigenschaft inputArgumentsSchema verwenden, müssen Sie zuerst den Prozess installieren.
The installProcess method installs a process and returns a Promise to an object of type InstallProcessResult, which contains an array of InputArgumentSchema objects.
const robot = UiPathRobot.init();
const processes = await robot.getProcesses();
const installedProcess = await robot.installProcess(processes[0].id);
for(let i=0; i<installedProcess.inputArgumentsSchema.length; i++){
console.log("Argument " + i + ":");
console.log(" name: " + installedProcess.inputArgumentsSchema[i].name)
console.log(" type: " + installedProcess.inputArgumentsSchema[i].type)
console.log(" isRequired: " + installedProcess.inputArgumentsSchema[i].isRequired)
console.log(" hasDefault: " + installedProcess.inputArgumentsSchema[i].hasDefault)
}
const robot = UiPathRobot.init();
const processes = await robot.getProcesses();
const installedProcess = await robot.installProcess(processes[0].id);
for(let i=0; i<installedProcess.inputArgumentsSchema.length; i++){
console.log("Argument " + i + ":");
console.log(" name: " + installedProcess.inputArgumentsSchema[i].name)
console.log(" type: " + installedProcess.inputArgumentsSchema[i].type)
console.log(" isRequired: " + installedProcess.inputArgumentsSchema[i].isRequired)
console.log(" hasDefault: " + installedProcess.inputArgumentsSchema[i].hasDefault)
}
In TypeScript, the method install of a RobotProcess object can be used to install a process.
const robot = UiPathRobot.init();
const processes = await robot.getProcesses();
const myProcess = processes.find(p => p.name === "MyProcess");
const installedProcess = await myProcess.install();
const robot = UiPathRobot.init();
const processes = await robot.getProcesses();
const myProcess = processes.find(p => p.name === "MyProcess");
const installedProcess = await myProcess.install();
Job starten (Start Job)
The startJob method receives an already created Job and starts it. It returns a Promise to an object of type JobResult, which contains the output arguments.
The createJob method creates a robot Job using the Process Id. It can optionally receive the job input arguments. It returns a Job object.
Ab v2022.10 wird die Prozessliste parallel zur Prozessausführung aktualisiert, davor wurde die Prozessliste aktualisiert, bevor der Prozess gestartet wurde. Das bedeutet, dass beim Ausführen eines Prozesses, für den ein Update verfügbar ist, der Auftrag möglicherweise mit der älteren Version des Prozesses ausgeführt wird.
robot = UiPathRobot.init();
processes = await robot.getProcesses();
const calculatorProcess = processes.find(p => p.name.includes('Calculator'));
const arguments = {
"input1" : 23,
"input2" : 42,
"operation" : "add"
};
const job = robot.createJob(calculatorProcess.id, arguments);
const result = await robot.startJob(job);
console.log(result.Sum);
robot = UiPathRobot.init();
processes = await robot.getProcesses();
const calculatorProcess = processes.find(p => p.name.includes('Calculator'));
const arguments = {
"input1" : 23,
"input2" : 42,
"operation" : "add"
};
const job = robot.createJob(calculatorProcess.id, arguments);
const result = await robot.startJob(job);
console.log(result.Sum);
In TypeScript, a Job can be created by using the Job class constructor.
robot = UiPathRobot.init();
processes = await robot.getProcesses();
const calculatorProcess = processes.find(p => p.name.includes('Calculator'));
const arguments = {
"input1" : 23,
"input2" : 42,
"operation" : "add"
};
const job = new Job(calculatorProcess.id, arguments);
const result = await robot.startJob(job);
console.log(result.Sum);
robot = UiPathRobot.init();
processes = await robot.getProcesses();
const calculatorProcess = processes.find(p => p.name.includes('Calculator'));
const arguments = {
"input1" : 23,
"input2" : 42,
"operation" : "add"
};
const job = new Job(calculatorProcess.id, arguments);
const result = await robot.startJob(job);
console.log(result.Sum);
Auftrag auf
Die Methode on des Job -Objekts wird verwendet, um Ereignishandler an den Auftrag anzufügen. Die verfügbaren Ereignisse sind status und workflow-event .
Status
Das Ereignis status wird während der Auftragsausführung jedes Mal ausgelöst, wenn sich der Status des Auftrags geändert hat.
Dieses Ereignis wird auch jedes Mal ausgelöst, wenn die Aktivität ReportStatus ausgeführt wird.
const robot = UiPathRobot.init();
const job = robot.createJob('processId');
job.on('status', robotStatus => console.log(robotStatus));
await robot.startJob(job);
const robot = UiPathRobot.init();
const job = robot.createJob('processId');
job.on('status', robotStatus => console.log(robotStatus));
await robot.startJob(job);
Workflow-Ereignis
The workflow-event event is raised during the job execution each time an activity that sends a workflow event is executed. It is the support for implementing partial results with the help of send interim results activity. The event handler has an argument of type WorkflowEventData.
const robot = UiPathRobot.init();
const job = robot.createJob('processId');
job.on('workflow-event', e => console.log(e.name));
await robot.startJob(job);
const robot = UiPathRobot.init();
const job = robot.createJob('processId');
job.on('workflow-event', e => console.log(e.name));
await robot.startJob(job);
Prozess starten (Start Process)
The method start of the object RobotProcess is used to start a process by passing it input arguments, if available.
It returns an object of type JobPromise.
const robot = UiPathRobot.init();
const processes = await robot.getProcesses();
const myProcess = processes.find(p => p.name === "MyProcess");
const arguments = {
"a" : 41,
"b" " 27
};
const result = await myProcess.start(arguments);
const robot = UiPathRobot.init();
const processes = await robot.getProcesses();
const myProcess = processes.find(p => p.name === "MyProcess");
const arguments = {
"a" : 41,
"b" " 27
};
const result = await myProcess.start(arguments);
Status „Prozess ein“
Die Methode onStatus wird verwendet, um einen Ereignishandler an das Statusereignis des Auftrags anzufügen.
const robot = UiPathRobot.init();
const processes = await robot.getProcesses();
const myProcess = processes.find(p => p.name === "MyProcess");
const result = await myProcess.start().onStatus(status => console.log(status));
const robot = UiPathRobot.init();
const processes = await robot.getProcesses();
const myProcess = processes.find(p => p.name === "MyProcess");
const result = await myProcess.start().onStatus(status => console.log(status));
Prozess bei Workflowereignis
Die Methode onWorkflowEvent wird verwendet, um einen Ereignishandler an das Ereignis „workflow-event“ des Auftrags anzufügen.
const robot = UiPathRobot.init();
const processes = await robot.getProcesses();
const myProcess = processes.find(p => p.name === "MyProcess");
const result = await myProcess.start().onWorkflowEvent(e => console.log(e.name));
const robot = UiPathRobot.init();
const processes = await robot.getProcesses();
const myProcess = processes.find(p => p.name === "MyProcess");
const result = await myProcess.start().onWorkflowEvent(e => console.log(e.name));
Prozess anhalten (Stop Process)
Die Methode stopProcess wird verwendet, um einen ausgeführten Roboterprozess zu stoppen.
Sie gibt eine Zusage zurück, die bei erfolgreichem Abbruch des laufenden Roboterprozesses aufgelöst wird.
const robot = UiPathRobot.init();
const processes = await robot.getProcesses();
const myProcess = processes.find(p => p.name === "MyProcess");
const result = await myProcess.start();
await robot.stopProcess(myProcess);
const robot = UiPathRobot.init();
const processes = await robot.getProcesses();
const myProcess = processes.find(p => p.name === "MyProcess");
const result = await myProcess.start();
await robot.stopProcess(myProcess);
Modelldefinitionen
IRobotSDK
interface IRobotSDK {
settings: Settings;
getProcesses(): Promise<Array<RobotProcess>>;
init(): IRobotSDK;
on(eventName: string, callback: (argument?: any) => void): void;
startJob(job: Job): Promise<JobResult>;
stopProcess(process: RobotProcess): Promise<void>;
installProcess(processId: string): Promise<InstallProcessResult>;
}
interface IRobotSDK {
settings: Settings;
getProcesses(): Promise<Array<RobotProcess>>;
init(): IRobotSDK;
on(eventName: string, callback: (argument?: any) => void): void;
startJob(job: Job): Promise<JobResult>;
stopProcess(process: RobotProcess): Promise<void>;
installProcess(processId: string): Promise<InstallProcessResult>;
}
Einstellungen
class Settings {
portNumber: number;
pollTimeInterval: number;
disableTelemetry: boolean;
}
class Settings {
portNumber: number;
pollTimeInterval: number;
disableTelemetry: boolean;
}
RobotProcess
class RobotProcess {
id: string;
name: string;
description?: string;
start: (inArguments?: any) => JobPromise;
install: () => Promise<InstallProcessResult>;
}
class RobotProcess {
id: string;
name: string;
description?: string;
start: (inArguments?: any) => JobPromise;
install: () => Promise<InstallProcessResult>;
}
InstallProcessResult
class InstallProcessResult {
inputArgumentsSchema: InputArgumentSchema[]
}
class InstallProcessResult {
inputArgumentsSchema: InputArgumentSchema[]
}
EingabeArgumentSchema
class InputArgumentSchema {
name: string;
type: string;
isRequired: boolean;
hasDefault: boolean;
}
class InputArgumentSchema {
name: string;
type: string;
isRequired: boolean;
hasDefault: boolean;
}
Auftragsversprechen
class JobPromise {
onStatus(eventHanlder: (argument?: any) => void): JobPromise;
onWorkflowEvent(eventHanlder: (argument?: any) => void): JobPromise;
}
class JobPromise {
onStatus(eventHanlder: (argument?: any) => void): JobPromise;
onWorkflowEvent(eventHanlder: (argument?: any) => void): JobPromise;
}
Auftrag
class Job {
processId: string;
argument?: any;
jobId: string;
on(eventName: string, eventHanlder: (argument?: any) => void): void;
}
class Job {
processId: string;
argument?: any;
jobId: string;
on(eventName: string, eventHanlder: (argument?: any) => void): void;
}
JobResult
class JobResult {
[Key: string]: any;
}
class JobResult {
[Key: string]: any;
}
WorkflowEventData
class WorkflowEventData {
name: string;
payload: string;
}
class WorkflowEventData {
name: string;
payload: string;
}
- Methoden und Eigenschaften
- Init
- Einstellungen
- Auf
- Zustimmungsaufforderung
- fehlende-Komponenten
- open-uipath-protocol
- Prozesse erhalten (Get Processes)
- Schema für Eingabeargumente abrufen
- Job starten (Start Job)
- Auftrag auf
- Status
- Workflow-Ereignis
- Prozess starten (Start Process)
- Status „Prozess ein“
- Prozess bei Workflowereignis
- Prozess anhalten (Stop Process)
- Modelldefinitionen
- IRobotSDK
- Einstellungen
- RobotProcess
- InstallProcessResult
- EingabeArgumentSchema
- Auftragsversprechen
- Auftrag
- JobResult
- WorkflowEventData