< Back
Set-AffinityFieldValue
Post
NAME Set-AffinityFieldValue
SYNOPSIS
Update a field-value
SYNTAX
Set-AffinityFieldValue [-FieldValueID] <Int64> [-FieldValue] <Object> [<CommonParameters>]
DESCRIPTION
This function updates a field-value based on a field_value_id.
If a given field has never been set, New-AffinityFieldValue needs to be called instead of
Set-AffinityFieldValue. Calling the wrong function will result in an error otherwise. The best way to test for
this now is to call Get-AffinityFieldValue first, then decide which function to call based on whether a given
field value is null or not.
There are a few peculiarities to be aware of:
1) allows_multiple Attribute. If a given field has the allows_multiple attribute set, then
New-AffinityFieldValue needs to be called to add additional field values instead of
Set-AffinityFieldValue.
2) dropdown_options Attribute. If a given field has the dropdown_options attribute set, then the
-FieldValue should be set with the desired dropdown value ID instead of the desired dropdown text.
3) value_type Attribute. Each field has different value type, which requires a different input. Please
see https://api-docs.affinity.co/#field-value-types for reference.
PARAMETERS
-FieldValueID <Int64>
The field_value_id from Affinity
Required? true
Position? 1
Default value 0
Accept pipeline input? false
Accept wildcard characters? false
-FieldValue <Object>
The value to update for a given field
Required? true
Position? 2
Default value
Accept pipeline input? false
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
OUTPUTS
System.Management.Automation.PSObject
NOTES
No enhancements planned.
-------------------------- EXAMPLE 1 --------------------------
PS C:\\>$ListEntries = Get-AffinityListEntry -ListName 'List'
foreach ($entry in $ListEntries) {
$EntryFieldValues = Get-AffinityFieldValue -OrganizationID $entry.entity.id -ListID $entry.list_id -Expand
if ($EntryFieldValues.'Status'.field_value -like "Error") {
Update-AffinityFieldValue -FieldValueID $EntryFieldValues.'Status'.field_value_id `
-FieldValue "Success"
}
}
RELATED LINKS
https://api-docs.affinity.co/#fields
https://api-docs.affinity.co/#field-values
https://api-docs.affinity.co/#the-field-value-resource
https://api-docs.affinity.co/#update-a-field-value
SYNOPSIS
Update a field-value
SYNTAX
Set-AffinityFieldValue [-FieldValueID] <Int64> [-FieldValue] <Object> [<CommonParameters>]
DESCRIPTION
This function updates a field-value based on a field_value_id.
If a given field has never been set, New-AffinityFieldValue needs to be called instead of
Set-AffinityFieldValue. Calling the wrong function will result in an error otherwise. The best way to test for
this now is to call Get-AffinityFieldValue first, then decide which function to call based on whether a given
field value is null or not.
There are a few peculiarities to be aware of:
1) allows_multiple Attribute. If a given field has the allows_multiple attribute set, then
New-AffinityFieldValue needs to be called to add additional field values instead of
Set-AffinityFieldValue.
2) dropdown_options Attribute. If a given field has the dropdown_options attribute set, then the
-FieldValue should be set with the desired dropdown value ID instead of the desired dropdown text.
3) value_type Attribute. Each field has different value type, which requires a different input. Please
see https://api-docs.affinity.co/#field-value-types for reference.
PARAMETERS
-FieldValueID <Int64>
The field_value_id from Affinity
Required? true
Position? 1
Default value 0
Accept pipeline input? false
Accept wildcard characters? false
-FieldValue <Object>
The value to update for a given field
Required? true
Position? 2
Default value
Accept pipeline input? false
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
OUTPUTS
System.Management.Automation.PSObject
NOTES
No enhancements planned.
-------------------------- EXAMPLE 1 --------------------------
PS C:\\>$ListEntries = Get-AffinityListEntry -ListName 'List'
foreach ($entry in $ListEntries) {
$EntryFieldValues = Get-AffinityFieldValue -OrganizationID $entry.entity.id -ListID $entry.list_id -Expand
if ($EntryFieldValues.'Status'.field_value -like "Error") {
Update-AffinityFieldValue -FieldValueID $EntryFieldValues.'Status'.field_value_id `
-FieldValue "Success"
}
}
RELATED LINKS
https://api-docs.affinity.co/#fields
https://api-docs.affinity.co/#field-values
https://api-docs.affinity.co/#the-field-value-resource
https://api-docs.affinity.co/#update-a-field-value