< Back
New-AffinityFieldValue
Post
NAME New-AffinityFieldValue
SYNOPSIS
Create a field-value for an entity
SYNTAX
New-AffinityFieldValue [-FieldID] <Int64> [-EntityID] <Int64> [[-ListEntryID] <Int64>] [-FieldValue] <Object>
[<CommonParameters>]
DESCRIPTION
This function creates a field-value based on a field_id, entity_id, and field_value (optionally a list_entry_id
if updated a list-specific field).
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
-FieldID <Int64>
The field_id from Affinity
Required? true
Position? 1
Default value 0
Accept pipeline input? false
Accept wildcard characters? false
-EntityID <Int64>
The entity_id from Affinity (could be a person_id, opportunity_id, or organization_id)
Required? true
Position? 2
Default value 0
Accept pipeline input? false
Accept wildcard characters? false
-ListEntryID <Int64>
The list_entry_id from Affinty
Required? false
Position? 3
Default value 0
Accept pipeline input? false
Accept wildcard characters? false
-FieldValue <Object>
The value to create for a given field
Required? true
Position? 4
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
Need to perform two validations before invoking REST API call:
1) Validate whether list_entry_id is required (server will throw error otherwise)
2) Validate whether $FieldValue matched field type (server will throw error for egregious type differences,
but not necessarily for minor differences). Validating this will usually require an additional 1-2 API
calls if the necessary data is not already cached.
-------------------------- 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 ($null = $EntryFieldValues.'Status'.field_value) {
New-AffinityFieldValue -FieldID $EntryFieldValues.'Status'.id `
-EntityID $entry.entity.id `
-FieldValue "New"
}
}
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/#create-a-new-field-value
SYNOPSIS
Create a field-value for an entity
SYNTAX
New-AffinityFieldValue [-FieldID] <Int64> [-EntityID] <Int64> [[-ListEntryID] <Int64>] [-FieldValue] <Object>
[<CommonParameters>]
DESCRIPTION
This function creates a field-value based on a field_id, entity_id, and field_value (optionally a list_entry_id
if updated a list-specific field).
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
-FieldID <Int64>
The field_id from Affinity
Required? true
Position? 1
Default value 0
Accept pipeline input? false
Accept wildcard characters? false
-EntityID <Int64>
The entity_id from Affinity (could be a person_id, opportunity_id, or organization_id)
Required? true
Position? 2
Default value 0
Accept pipeline input? false
Accept wildcard characters? false
-ListEntryID <Int64>
The list_entry_id from Affinty
Required? false
Position? 3
Default value 0
Accept pipeline input? false
Accept wildcard characters? false
-FieldValue <Object>
The value to create for a given field
Required? true
Position? 4
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
Need to perform two validations before invoking REST API call:
1) Validate whether list_entry_id is required (server will throw error otherwise)
2) Validate whether $FieldValue matched field type (server will throw error for egregious type differences,
but not necessarily for minor differences). Validating this will usually require an additional 1-2 API
calls if the necessary data is not already cached.
-------------------------- 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 ($null = $EntryFieldValues.'Status'.field_value) {
New-AffinityFieldValue -FieldID $EntryFieldValues.'Status'.id `
-EntityID $entry.entity.id `
-FieldValue "New"
}
}
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/#create-a-new-field-value