Functions/New-IAWidgetDataValueFieldMaps.ps1

Function New-IAWidgetDataValueFieldMaps {
    <#
        .SYNOPSIS
            This is used to create a new DataValueFieldMap based on an inputted DataValueFieldMapsObject.
        .DESCRIPTION
            This command will take an inputted DataValueFieldMap and fit it in a webrequest after which it will be sent to Insight Analytics to be created.
        .EXAMPLE
            $IAWidgetDataValueFieldMapsObject = New-IAWidgetDataValueFieldMapsObject -WidgetId $response.Id -WidgetTemplateId $response.WidgetTemplateId
 
            foreach($item in $IAWidgetDataValueFieldMapsObject){
                New-IAWidgetDataValueFieldMaps -IAWidgetDataValueFieldMaps $item
            }
    #>

    Param(
        [Parameter(Mandatory = $true)]
        [PSObject] $IAWidgetDataValueFieldMaps,
        [Switch] $Passthru
    )

    $Uri = "WidgetDataValueFieldMaps"
    $Body = $IAWidgetDataValueFieldMaps | ConvertTo-Json

    Write-Verbose "Body: $Body"

    $response = Invoke-IAQuery -QueryUrl $Uri -Method Post -Body $Body

    if($Passthru){

        if ($null -eq $response) {
            return $null
        }

        return $response
    }
}