Skip to main content

Hosted Apps and Desktops - How to Fix 'Unable to Retrieve an Offer'

Overview

This article provides steps on how to fix the specific error message below when discovering offerings on the Hosted Apps and Desktops Offering Management Page.

Error

HAAD Unable to retrieve an offer

Process

First, we need to confirm if the offering is missing from the Citrix Delivery controller.

  • Navigate to your Citrix Delivery controller and run the below command using an adminstrative PowerShell session:
    • Replace the -uuid paramter with the GUID of offering in the initial error.
Get-BrokerApplication -uuid 'abfe0-4d=a2fe=1abf=9ffe=701abf4d709d' 

This command will help us confirm that the offering is missing from the delivery controller which is causing this error.

This is typically caused by the offer being removed directly on the delivery controller instead of from the Hosted Apps and Desktops service.

We will then confirm that this offer exists in the Database with the below SQL Query:

  • Please update the last line to be the relevant UUID which we used to get the broker application.
use olm
select p.[Label] as 'Application Offer',pv.[Value] as 'UUID'
from Plans p
join PropertyValues pv on pv.ObjectID = p.ObjectId
join Properties pr on pr.PropertyID = pv.PropertyID
where p.[Label] is not null
and pr.[Name] = 'CitrixAppId'
and pv.[Value] = '30b73d67-e242-42f5-9677-486078a60351'

This will retrieve the Offering from the Database as shown below:

HAAD Unable to retrieve an offer

You can confirm that the Application Offer (In this case "Calculator") is a removed application directly on the Citrix Delivery Controller UI if required.

If this Offer has correctly been removed from the delivery controller but not the database, run the below SQL query:

use olm

/*
Update the two below variables (Customer Code and AppName) with the Customer Code and the Target Application we have.
This is the "Offering Name" not UUID.
*/

declare
@CustomerCode nvarchar(10) = 'AR', -- Change this to customer's code
@AppName nvarchar(100) = 'Calculator', -- Change this to target offering to be removed from customer
@OfferingName nvarchar(max),
@ObjectId int,
@ObjectType nvarchar(50),
@Customer nvarchar(20),
@User nvarchar(20)

declare @PlanObjects as table
(
ObjectId int primary key,
ObjectType nvarchar(50),
Customer nvarchar(20),
[User] nvarchar(20)
)

select @OfferingName = [Name] from Plans where [Label] = @AppName

declare cur cursor local for
select p.ObjectId, o.[Type], c.[Name], u.[Name]
from Plans p
inner join Services su on su.ObjectID = p.OwnerId
inner join Objects o on o.ObjectID = su.ObjectId
inner join ObjectTypes ot on ot.ObjectTypeID = o.ObjectTypeID
inner join Users u on u.UserID = su.UserID
inner join Customers c on c.CustomerID = u.CustomerID
where p.[Name] = @OfferingName
and c.[Name] = @CustomerCode

HAAD Unable to retrieve an offer

Run script below on the Citrix delivery controller where HAaD web service in installed to check/fix offering advertisement entry in metadata:

Atria Citrix Offering Uid With Option To Repair
Param(
[Parameter(Mandatory)]
[String]$ApplicationName # Search application by BrowserName/Name/PublishedName
)

Function Get-CitrixApplication {
Param(
[Parameter(Mandatory)]
[String]$ApplicationName
)

# Find by PublishedName - Application name (for user)
$Application = Get-BrokerApplication -PublishedName $ApplicationName -ErrorAction SilentlyContinue

If(!$Application) {
# Find by Name - Application name (for administrator)
$Application = Get-BrokerApplication -Name $ApplicationName -ErrorAction SilentlyContinue
}

If(!$Application) {
# Find by BrowserName
$Application = Get-BrokerApplication -BrowserName $ApplicationName -ErrorAction SilentlyContinue
}

return $Application
}

Function Get-OfferingFromDesktopGroupMetadata {
Param(
[Parameter(Mandatory)]
[Int32]$DesktopGroupUid,

[Parameter(Mandatory)]
[String]$ApplicationName
)

$DesktopGroup = Get-BrokerDesktopGroup -Uid $DesktopGroupUid
$AppMetadata = $DesktopGroup.MetadataMap.GetEnumerator() | ? { $_.Value -eq $ApplicationName }

return New-Object -TypeName PSObject -Property @{
OfferingName = $AppMetadata.Value
OfferingId = $AppMetadata.Key
OfferingUid = ($DesktopGroup.MetadataMap.GetEnumerator() | ? { $_.Key -eq "$($AppMetadata.Key)&RelatedId" }).Value
}
}

Function Get-OfferingAdvertisementMetadata {
Param(
[Parameter(Mandatory)]
[Int32]$DesktopGroupUid,

[Parameter(Mandatory)]
[String]$OfferingId
)

$DesktopGroup = Get-BrokerDesktopGroup -Uid $DesktopGroupUid
$AppMetadata = $DesktopGroup.MetadataMap.GetEnumerator() | ? { $_.Value -eq $OfferingId }
$AdvertisementId = ($AppMetadata.Key -split '&')[0]
$Advertisement = New-Object -TypeName PSObject -Property @{
MetadataId = $AdvertisementId
}

$DesktopGroup.MetadataMap.GetEnumerator() | ? { $_.Key -match $AdvertisementId } | ForEach {
$Advertisement | Add-Member -NotePropertyName ($_.Key -replace "$AdvertisementId&", '') -NotePropertyValue $_.Value
}

return $Advertisement
}

[Object[]]$Application = $null
[Object[]]$Application = Get-CitrixApplication -ApplicationName $ApplicationName

Write-Host "`nCitrix Application" -ForegroundColor Green
$Application | Select ApplicationName, Name, BrowserName, PublishedName, UUID, Uid

Switch($Application.Count) {
0 {
Write-Host "Cannot find citrix application with name '$ApplicationName'! Try using the app's BrowserName instead." -ForegroundColor Red
exit
}

1 {
[Int32]$DesktopGroupUid = $Application.AssociatedDesktopGroupUids[0]
}

Default {
[Int32]$ApplicationUid = Read-Host -Prompt "Multiple applications found! Please select a UID from the list above"
[Int32]$DesktopGroupUid = ($Application | ? { $_.Uid -eq $ApplicationUid }).AssociatedDesktopGroupUids[0]
}
}

[Object]$Offering = $null
[Object]$Offering = Get-OfferingFromDesktopGroupMetadata -DesktopGroupUid $DesktopGroupUid -ApplicationName $Application.BrowserName

If(!$Offering) {
Throw "Offering not found!"
}

[Object]$Advertisement = $null
[Object]$Advertisement = Get-OfferingAdvertisementMetadata -DesktopGroupUid $DesktopGroupUid -OfferingId $Offering.OfferingId

If(!$Advertisement) {
Throw "Advertisement not found!"
}

Write-Host "`nAdvertised Offering Metadata:`n" -ForegroundColor Green
$Offering | fl
$Advertisement | fl

If($Application.Uid -ne $Offering.OfferingUid) {
$Response = Read-Host -Prompt "Application Uid and Offering Uid does not match! Would you like to update offering Uid to match? (y/N)"

If($Response -in ('y', 'Y')) {
Set-BrokerDesktopGroupMetadata -DesktopGroupId $DesktopGroupUid -Name "$($Offering.OfferingId)&RelatedId" -Value $Application.Uid
Set-BrokerDesktopGroupMetadata -DesktopGroupId $DesktopGroupUid -Name "$($Advertisement.MetadataId)&AppId" -Value $Application.Uid
}
}

If you have any questions or require any help or assistance, please contact us at support@getatria.com.