Closed rschouten97 closed 2 months ago
Unfortunately, this doesn't work as other features depend on an empty or null department. If we want to implement this, we need to check if the property exists on the account object and this check in the set- functions need to be removed from the functions.
@Rick-Jongbloed , a check if the property exists isn't that complex either right? Could be something like this:
if ("budgetHolder" -in $Account.PsObject.Properties.Name) {
if ($null -ne $Account.budgetHolder) {
# Resolve budgetholder id
$splatParamsBudgetHolder = @{
Account = [ref]$account
AuditLogs = [ref]$auditLogs
Headers = $authHeaders
BaseUrl = $config.baseUrl
lookupErrorHrBudgetHolder = $config.lookupErrorHrBudgetHolder
lookupErrorTopdesk = $config.lookupErrorTopdesk
}
Get-TopdeskBudgetholder @splatParamsBudgetHolder
}
}
However, the main issue is for budgetHolder as this is not a required field, whereas departmet is in that case. So for starters, could we just implement a check for the budgetHolder? If necessary we can always add the checks for other properties as well.
This is fixed in the new PSv2. Linked to new branch/pr
When we don't use a field, we don't provide it in the mapping (account) object. However, if I outcomment (or remove) the field budgetHolder, like so:
The function Get-TopdeskBudgetHolder to query the Topdesk budgetholder ID is still performed and returns the following error: Requested to lookup budgetholder, but budgetholder.lookupValue is missing. This is a scripting issue.
IMO this should not be the case. We should only query and use the provided fields of the mapping (account) object.
This can be easily solved by changing this:
To this:
The example given is for budgetholder, but this should be for every field (that isn't required).