Start Job throwing error

I have to call a process from another process, for that i am using ‘Start Job’ activity.
The Robot has the edit create rights on jobs and process, also the process name I am passing is in the "packageName_environmentName’ format but I’m still getting the error => Start Job: An invalid result was encountered for parameter Process Name

Screenshot attached :

Any help will be appreciated :slight_smile:

@loginerror @Pablito : Guys, any suggestions?

Hi @shubhiyadav

Could you double check this permission?

1 Like

I have done it, though it got resolved now by passing the process name instead of “packageName_EnvName”, but is it right? @loginerror

Not according to our documentation:

I’ll check if something shouldn’t be updated :slight_smile:

Yes @loginerror exactly, till the time i was following the format mentioned in document it was throwing error in Process parameter, but when i wrote just the process name it worked fine.

This may create confusion for many in future, so thought to inform you.

1 Like

Using throw will change the job object’s State property to “Failed”. The key is to use the job object returned from Start-Job or Get-Job and check the State property. You can then access the exception message from the job object itself.

Per your request I updated the example to also include concurrency.

$createZip = {
    Param ( [String] $source, [String] $zipfile )

    if ($source -eq "b") {
        throw "Failed to create $zipfile"
    } else {
        return "Successfully created $zipfile"
    }
}

$jobs = @()
$sources = "a", "b", "c"

foreach ($source in $sources) {
    $jobs += Start-Job -ScriptBlock $createZip -ArgumentList $source, "${source}.zip"
}

Wait-Job -Job $jobs | Out-Null

foreach ($job in $jobs) {
    if ($job.State -eq 'Failed') {
        Write-Host ($job.ChildJobs[0].JobStateInfo.Reason.Message) -ForegroundColor Red
    } else {
        Write-Host (Receive-Job $job) -ForegroundColor Green 
    }
}