Original Message:
Sent: Oct 01, 2024 09:48 AM
From: Valentin Zovko
Subject: Service broker: cannot parse MimeType in custom forms
I tried recreating it and for me it works in service broker. I did it like this:
Action Code:
// Return empty array if input is not presentif (!vms) { System.log("List is empty") return [];}// Split input to arrayvar list = vms.replace(/["']/g, "").split(/[,;\r\n|\n]/g);// Cleanupvar arr = list.filter(function(el) { return el != null && el !== '';});// Get all VMsvar allVMs = VcPlugin.getAllVirtualMachines(["name"], null);System.log("Total VMs: " + allVMs.length);// Create empty arrayvar vmsNotFound = [];// Interate over cleaned up list of VM namesarr.forEach(function(vmName) { // Check if VM name exists var result = allVMs.filter(function(vm) { return vm.name.toLowerCase() === vmName.toLowerCase().trim(); }); // Push to list of not found VMs when above query does not return any results if (!result || result.length === 0) { vmsNotFound.push(vmName) }});// Return list of not found VM namesreturn vmsNotFound;
Workflow with two variables, one string, one array of string.
Value options for "check" map to "vms".
This works in service broker.
"Check" contains the list of not found VM names.
Workflow does run too and completes.
Original Message:
Sent: Oct 01, 2024 08:37 AM
From: SistDip
Subject: Service broker: cannot parse MimeType in custom forms
Back to you mate ... with a different error. As for mime, also this work-around runs smmotly in orchestrator and Service Broker fails :
the code of the action is :
var content = inputText.replace(/["']/g, "").split(/[,;\r\n|\n]/g);var vmWithError = new Array()for each (var vmName in content) { //System.log("vmName > " + vmName) var found = Server.findAllForType("VC:VirtualMachine", "xpath:name='" + vmName + "'") //System.log(found.length) //check if the inserted vm exists or not if ( found.length == 0) { System.log(vmName + " NOT FOUND") vmWithError.push(vmName + " NOT FOUND") } else { // }}if ( vmWithError.length == 0 ) { vmWithError.push("Check VMs SUCCESSFULLY Completed")}return vmWithError.sort().toString()
where inputText is the text area
Original Message:
Sent: Sep 30, 2024 05:49 AM
From: SistDip
Subject: Service broker: cannot parse MimeType in custom forms
Hi Valentin ,
thanks for your reply, I also opened a case that is still "Under Investigation" by Broadcom.
I like your approach and will use it as a workaround and hope the problem will be solved.
Original Message:
Sent: Sep 30, 2024 02:28 AM
From: Valentin Zovko
Subject: Service broker: cannot parse MimeType in custom forms
I had a similar issue where I was trying to use input validation for MimeAttachment inputs and got the same error. I opened and case and received the following repsonse: "Upon checking internally I confirmed that unfortunately using file uploads in service broker is not supported. You can use them only if you are running the workflow directly in vRO. "
What is working in my case is simply use MimeAttachments as inputs but don't do the the input validation. Just pass is to the workflow. In the first step I validate the correct MimeType and fileextension. If that fails the workflow fails too.
In your case another approach could be to use the TextArea input and let the user just paste the list of VMs as a string and than process this string by splitting it to allow multiple ways of input, like comma, semiclon, space or tab seperation. Something like the following and then go on from there.
var array = input.replace(/["']/g, "").split(/[\s\n,;]/g);
Original Message:
Sent: Sep 27, 2024 08:28 AM
From: SistDip
Subject: Service broker: cannot parse MimeType in custom forms
Hello everyone,
I need your help to solve a problem that is driving me crazy : I got an error from service broker, trying to parse a file passed as inputFile(Mime).
I'll explain my usecase:
- users upload a txt into Service broker with a list of vms (VMs List)
- In VMs field I put an action that parse "VMs List" and check if the vm exists in our environment
If I run the workflow in Orchestrator, everything runs fine :
but if run from Service Broker, it fails with error :
I'm running on 8.18 Automation and the code for checkVmsFromFile is here :
//load file content split by linesvar fileContent = inputfile.content.split(/\r\n|\n/)//System.log("fileContent > " + fileContent)vmWithError = new Array()for each (var vmName in fileContent) { //System.log("vmName > " + vmName) var found = Server.findAllForType("VC:VirtualMachine", "xpath:name='" + vmName + "'") //System.log(found.length) //check if the inserted vm exists or not if ( found.length == 0) { System.log(vmName + " NOT FOUND") vmWithError.push(vmName + " NOT FOUND") }}if ( vmWithError.length == 0 ) { vmWithError.push("Check VMs SUCCESSFULLY Completed")}return vmWithError.sort()
Can someone help me to solve this problem ?