Extend Contract context with contract state
Twan Duvigneau
When selecting the contracts of a person we can clearly see whether a contract is a future contract, active contract or past contract. We'd like to have this information available in the context data of a contract. This way if we want to only write active functions or departments of a person to for example the function field in the Active Directory we can make a filter on the contracts which are in condition with the active flag. Right now we need to do a filter on starts and end date, taking into consideration null values etc. This would make the filtering way easier is powershell and especially javascript fieldmapping.
R
Rick van den Dijssel
Twan Duvigneau is using inConditions on a contract not easier and gives you more information about which contracts are in scope of the rule that apply on the account?
Twan Duvigneau
Rick van den Dijssel Hi Rick, if we only want to have the active titles for a person in for example the title field for the Active Directory target we cannot use inconditions because the accounts are created for example 30 days ahead of the start date of the contract. Which means they are incondition to early, and old contracts for too long. Thats why we would like the contract state, because this way we don't need to make a filtering on the dates of a contract, like so:
$personContext.person.contracts | Where-Object {
($_.Context.inConditions -eq $true -or $actionContext.dryRun -eq $true) -and $_.Context.State -eq 'Active'
}
This would give us more flexibility, we could also filter out specific functions that are going to be added within the next 30 days etc.
For Context, to achieve the same filtering right now we'd need the following where-object condition:
$personContext.person.contracts | Where-Object {
($_.Context.inConditions -eq $true -or $actionContext.dryRun -eq $true) -and
(
(
$Null -eq $_.EndDate -and
[DateTime]$_.Startdate -le [DateTime]::Today
) -or
(
$Null -ne $_.EndDate -and
[DateTime]$_.EndDate -ge [DateTime]::Today -and
[DateTime]$_.Startdate -le [DateTime]::Today
)
)
}
This where object would be way more complex in a javascript fieldmapping as well, where as the first option with a Context.State key would be rather easy to implement.