# Site 6.3.x updates













function Execute6.3SiteUpdates






{






	#SiteUpdate_6.3_01 6310 Skip because of SiteUpdate_8.0_03






	SiteUpdate_6.3_02 6310






	SiteUpdate_6.3_03 6300






	SiteUpdate_6.3_04 6300






	SiteUpdate_6.3_05 6300






	SiteUpdate_6.3_06 6300






	SiteUpdate_6.3_07 6301






	SiteUpdate_6.3_08 6301






	SiteUpdate_6.3_09 6302






	SiteUpdate_6.3_10 6310






	SiteUpdate_6.3_11 6310






	SiteUpdate_6.3_12 6310






	SiteUpdate_6.3_13 6310






	SiteUpdate_6.3_14 6310






	SiteUpdate_6.3_15 6310






	SiteUpdate_6.3_16 6310






	SiteUpdate_6.3_17 6310






	#SiteUpdate_6.3_18 6310 Skip because of SiteUpdate_8.0_09






	SiteUpdate_6.3_19 6311






	SetTemplateVersion "6.3.1.1" -IgnoreWhenHigherVersion






}













# List: SettingValues






# Remove items (if any)






# Import new data






function SiteUpdate_6.3_01($patchVersion)






{






	if ($patchCheck -ge $patchVersion -or $newSite -eq $true) 






	{






		return






	}













	UpdateSettingValues






}













# Update portal.aspx






function SiteUpdate_6.3_02($patchVersion)






{






	if ($patchCheck -ge $patchVersion) 






	{






		return






	}






	






	UpdatePages $languageInfo[0] $updateSite @("portal.aspx")






}













# List: Skills






# Add content type to list: EscapeMaxQueueSizeSkill






# Add field to content type: wsp_ucc_skill_max_queue_count






function SiteUpdate_6.3_03($patchVersion)






{






	if ($patchCheck -ge $patchVersion) 






	{






		return






	}













	$listTitle = "Skills"






	$ctName = "EscapeMaxQueueSizeSkill"













	AddPnPFieldFromXml '<Field ID="{2bcfe8f1-6ee7-413f-925e-804f4d5b9da8}" Type="Number" Name="wsp_ucc_skill_max_queue_count" DisplayName="Max Queue Count" Required="FALSE" Description="Maximum queue count before escape" Group="AnywhereNow" />' $null "wsp_ucc_skill_max_queue_count" -IgnoreDuplicateException






	AddPnPContentType $ctName "0x0100d38d5473574c5547b83b7dcb8afdda6a" "Add a EscapeMaxQueueSizeSkill item to the Skills list"






	AddPnPFieldsToContentType $ctName @("wsp_ucc_skill_max_queue_count", "wsp_ucc_skills_escapeskill", "wsp_ucc_ShowOnWallboard")






	AddPnPContentTypesToList $listTitle @($ctName) -DontSetDefault






	AddPnPView $listTitle "EscapeMaxQueueSizeSkillView" "EscapeMaxQueueSizeSkillView" 30 "<Where><Eq><FieldRef Name=""ContentType"" /><Value Type=""Text"">EscapeMaxQueueSizeSkill</Value></Eq></Where><OrderBy><FieldRef Name=""ID"" /></OrderBy>" @("LinkTitle", "wsp_ucc_skill_max_queue_count", "wsp_ucc_skills_escapeskill", "wsp_ucc_ShowOnWallboard") -RemoveIfExists






	AddForms $updateSite_RelativeURL $listTitle






}













# List: Settings






# Update 'DisableCallForwarding' setting value (moved description update to SiteUpdate_8.0_07)






function SiteUpdate_6.3_04($patchVersion)






{






	if ($patchCheck -ge $patchVersion) 






	{






		return






	}













	$listTitle = "Settings"






	$updateItem = Get-PnPListItem -List $listTitle -Query '<View><Query><Where><Eq><FieldRef Name="wsp_ucc_Key" /><Value Type="Text">DisableCallForwarding</Value></Eq></Where></Query></View>'






	if ($updateItem -ne $null) 






	{






		$checkValue = $updateItem["wsp_ucc_Value"]






		if ($checkValue -eq "true" -or $checkValue -eq "false")






		{






			if ($checkValue -eq "true")






			{






				SetPnPListItem $listTitle $updateItem @{"wsp_ucc_Value" = "All"}






			}






			elseif ($checkValue -eq "false") 






			{






				SetPnPListItem $listTitle $updateItem @{"wsp_ucc_Value" = "None"}






			}






		}






	}






}













# List: OutboundDialerCalls, CT: OutboundDialerCall






# Add field to list: wsp_ucc_odc_parentid






# Remove field from content type






function SiteUpdate_6.3_05($patchVersion)






{






	if ($patchCheck -ge $patchVersion) 






	{






		return






	}













	$listTitle = "OutboundDialerCalls"






	$ctName = "OutboundDialerCall"






	AddPnPFieldFromXml '<Field ID="{a203531d-b432-459e-a577-4af34ad4ffce}" Type="Text" Name="wsp_ucc_odc_parentid" DisplayName="ParentId" Required="false" Group="AnywhereNow" />' $null "wsp_ucc_odc_parentid" $listTitle -IgnoreDuplicateException






	RemoveFieldsFromContentType $ctName @("wsp_ucc_odc_parentid") $listTitle






}













# List: Supervisors, CT: Supervisor






# Add field to content type: wsp_ucc_Supervisor_upn






# Update default view






function SiteUpdate_6.3_06($patchVersion)






{






	if ($patchCheck -ge $patchVersion) 






	{






		return






	}













	$listTitle = "Supervisors"






	$ctName = "Supervisor"






	AddPnPFieldFromXml '<Field ID="{d06edc51-8ef3-4b59-b97f-a4f98bd5885b}" Type="Text" Name="wsp_ucc_Supervisor_upn" DisplayName="UPN" Required="false" Group="AnywhereNow" />' $null "wsp_ucc_Supervisor_upn" -IgnoreDuplicateException






	AddPnPFieldsToContentType $ctName @("wsp_ucc_Supervisor_upn")






	AddPnPView "Supervisors" "AllItems" "AllItems" 30 '<OrderBy><FieldRef Name="ID" /></OrderBy>' @("wsp_ucc_Supervisor", "Edit", "wsp_ucc_Supervisor_phoneuri", "wsp_ucc_Supervisor_upn") -Default -RemoveIfExists






}













# List: Settings, Field: wsp_ucc_Value






# Convert field to multi line






function SiteUpdate_6.3_07($patchVersion)






{






	if ($patchCheck -ge $patchVersion) 






	{






		return






	}













	$field = GetPnpField "wsp_ucc_Value" "Settings"






	ConvertSingleLineToMultiLineField $field






}













# List: SettingValues, CT: SettingValue, Field: wsp_ucc_sv_type






# Add 'MultiLine' choice






# Fix field order in content type






# Convert field 'wsp_ucc_sv_default' to multi line






function SiteUpdate_6.3_08($patchVersion)






{






	if ($patchCheck -ge $patchVersion) 






	{






		return






	}






	






	$listTitle = "SettingValues"






	$field1 = GetPnPField "wsp_ucc_sv_type"






	$field2 = GetPnPField "wsp_ucc_sv_type" $listTitle






	$updateChoices = @("Dropdown", "Boolean", "RegEx", "MultiLine", "Playlist")






	AddChoiceFieldItems @($field1, $field2) $updateChoices






	AddPnPFieldsToContentType "SettingValue" $null @("Title", "wsp_ucc_sv_type", "wsp_ucc_sv_value", "wsp_ucc_sv_default", "wsp_ucc_sv_description", "wsp_ucc_sv_scope", "wsp_ucc_sv_settinggroup", "wsp_ucc_sv_readonly", "wsp_ucc_sv_active")






	$field3 = GetPnpField "wsp_ucc_sv_default" $listTitle






	ConvertSingleLineToMultiLineField $field3 1






}













# List: settingsList 






# Add 'Escape max queue size skill' link






function SiteUpdate_6.3_09($patchVersion)






{






	if ($patchCheck -ge $patchVersion -or $newSite -eq $true) 






	{






		return






	}






	






	$listTitle = "settingsList"






	$importFile = "$RootPath\AnywhereNow\CSV\settingsList.csv"






	$lcid = $languageInfo[0]






	if ($lcid -eq 1031)






	{






		$language = $languageInfo[2]






		$importFile = "$RootPath\AnywhereNow\CSV\$language\settingsList.csv"






	}













	$data = Import-Csv $importFile -Delimiter ";"






	foreach ($row in $data) 






	{






		$rowTitle = $row.Title






		if ($rowTitle -eq "Escape max queue size skill")






		{






			$item = Get-PnPListItem -List $listTitle -Query "<View><Query><Where><Eq><FieldRef Name=""Title"" /><Value Type=""Text"">$rowTitle</Value></Eq></Where></Query></View>"






			if ($item -eq $null) 






			{






				AddPnPListItem $listTitle @{"Title" = $row.Title; "wsp_ucc_URL" = $row.wsp_ucc_URL; "wsp_ucc_HeaderTitle" = $row.wsp_ucc_HeaderTitle;






											"wsp_ucc_sort" = $row.wsp_ucc_sort; "wsp_ucc_visible" = $row.wsp_ucc_visible}






			}






		}






	}






}













# Add libraries: InboundScreenRecordings, OutboundScreenRecordings






function SiteUpdate_6.3_10($patchVersion)






{






	if ($patchCheck -ge $patchVersion) 






	{






		return






	}













	$libraries = @("InboundScreenRecordings", "OutboundScreenRecordings")






	foreach ($library in $libraries) 






	{






		AddPnPList $library -DocumentLibrary | Out-Null






	}






}













# List: settingsList 






# Update 'Screen recordings inbound' and 'Screen recordings outbound' links






function SiteUpdate_6.3_11($patchVersion)






{






	if ($patchCheck -ge $patchVersion -or $newSite -eq $true) 






	{






		return






	}






	






	$listTitle = "settingsList"






	$importFile = "$RootPath\AnywhereNow\CSV\settingsList.csv"






	$key1 = "Screen recordings inbound"






	$key2 = "Screen recordings outbound"






	$lcid = $languageInfo[0]






	if ($lcid -eq 1031)






	{






		$language = $languageInfo[2]






		$importFile = "$RootPath\AnywhereNow\CSV\$language\settingsList.csv"






		$key1 = "Bildschirmaufnahmen eingehend"






		$key2 = "Bildschirmaufnahmen ausgehend"






	}













	$data = Import-Csv $importFile -Delimiter ";"






	foreach ($row in $data) 






	{






		$rowTitle = $row.Title






		if ($rowTitle -eq $key1 -or $rowTitle -eq $key2)






		{






			$item = Get-PnPListItem -List $listTitle -Query "<View><Query><Where><Eq><FieldRef Name=""Title"" /><Value Type=""Text"">$rowTitle</Value></Eq></Where></Query></View>"






			if ($item -ne $null) 






			{






				SetPnPListItem $listTitle $item @{"wsp_ucc_URL" = $row.wsp_ucc_URL}






			}






		}






	}






}













# List PluginFlowSettings






# Add 'wsp_ucc_pfs_value' field to default view






function SiteUpdate_6.3_12($patchVersion)






{






	if ($patchCheck -ge $patchVersion) 






	{






		return






	}













	AddPnPView "PluginFlowSettings" "AllItems" "AllItems" 30 "<OrderBy><FieldRef Name=""wsp_ucc_pfs_order"" Ascending=""True"" /></OrderBy>" @("LinkTitle", "wsp_ucc_pfs_operator", "wsp_ucc_pfs_value", "wsp_ucc_pfs_order", "wsp_ucc_pfs_condition", "wsp_ucc_pfs_flag", "wsp_ucc_pfs_flagvalue", "wsp_ucc_pfs_action", "wsp_ucc_pfs_skill", "wsp_ucc_pfs_prompt", "wsp_ucc_pfs_parentquestion", "wsp_ucc_pfs_pluginattribute", "wsp_ucc_pfs_message") -Default -RemoveIfExists






}













# List PluginAttributes, CT: PluginAttribute






# Add 'wsp_ucc_pa_scope' field to content type and default view






# Fix OrderBy of 'wsp_ucc_pa_order' field in default view






function SiteUpdate_6.3_13($patchVersion)






{






	if ($patchCheck -ge $patchVersion) 






	{






		return






	}













	AddPnPFieldFromXml '<Field ID="{31fec519-33a1-4962-bfb7-2d7be335baa3}" Type="Text" Name="wsp_ucc_pa_scope" DisplayName="Scope" Required="FALSE" Group="AnywhereNow" />' -IgnoreDuplicateException                                                            






	AddPnPFieldsToContentType "PluginAttribute" @("wsp_ucc_pa_scope")






	AddPnPView "PluginAttributes" "AllItems" "AllItems" 30 "<GroupBy Collapse=""False"" GroupLimit=""100""><FieldRef Name=""wsp_ucc_pa_category"" Ascending=""True""/></GroupBy><OrderBy><FieldRef Name=""wsp_ucc_pa_order"" Ascending=""True"" /></OrderBy>" @("LinkTitle", "wsp_ucc_pa_systemname", "wsp_ucc_pa_show", "wsp_ucc_pa_show_toast", "wsp_ucc_pa_order", "wsp_ucc_pa_fieldtype", "wsp_ucc_pa_hyperlink", "wsp_ucc_pa_open", "wsp_ucc_pa_category", "wsp_ucc_pa_scope") -Default -RemoveIfExists






}













# List PluginFlowSettings






# Set empty choice value for "wsp_ucc_pfs_condition", "wsp_ucc_pfs_flag" and "wsp_ucc_pfs_action" fields






function SiteUpdate_6.3_14($patchVersion)






{






	if ($patchCheck -ge $patchVersion) 






	{






		return






	}













	$listTitle = "PluginFlowSettings"






	$field1 = GetPnPField "wsp_ucc_pfs_condition"






	$field2 = GetPnPField "wsp_ucc_pfs_condition" $listTitle






	$updateChoices = @("", "AND", "OR")






	AddChoiceFieldItems @($field1, $field2) $updateChoices






	$field1 = GetPnPField "wsp_ucc_pfs_flag"






	$field2 = GetPnPField "wsp_ucc_pfs_flag" $listTitle






	$updateChoices = @("", "Priority", "Recording")






	AddChoiceFieldItems @($field1, $field2) $updateChoices






	$field1 = GetPnPField "wsp_ucc_pfs_action"






	$field2 = GetPnPField "wsp_ucc_pfs_action" $listTitle






	$updateChoices = @("", "Callback", "Disconnect", "Forward", "Message", "PreferredHunt", "Prompt", "Question", "QueuedCallback", "Skill", "Voicemail")






	AddChoiceFieldItems @($field1, $field2) $updateChoices






}













# List: Settings






# Update 'IsAttendant' setting description






function SiteUpdate_6.3_15($patchVersion)






{






	if ($patchCheck -ge $patchVersion) 






	{






		return






	}













	$listTitle = "Settings"






	$updateItem = Get-PnPListItem -List $listTitle -Query '<View><Query><Where><Eq><FieldRef Name="wsp_ucc_Key" /><Value Type="Text">IsAttendant</Value></Eq></Where></Query></View>'






	if ($updateItem -ne $null) 






	{






		$descriptionItem = Get-PnPListItem -List "SettingValues" -Query '<View><Query><Where><Eq><FieldRef Name="Title" /><Value Type="Text">IsAttendant</Value></Eq></Where></Query></View>'






		if ($descriptionItem -ne $null)






		{






			SetPnPListItem $listTitle $updateItem @{"wsp_ucc_Description" = $descriptionItem["wsp_ucc_sv_description"]}






		}






	}






}













# List: Recordings






# Add 'Caller' field






# Update default view






function SiteUpdate_6.3_16($patchVersion)






{






	if ($patchCheck -ge $patchVersion) 






	{






		return






	}













	






	$listTitle = "Recordings"






	AddPnPFieldFromXml '<Field Type="Text" Name="Caller" DisplayName="Caller" Required="FALSE" Group="AnywhereNow" />' $null "Caller" $listTitle -IgnoreDuplicateException






	AddPnPView $listTitle "AllItems" "All Documents" 30 '<OrderBy><FieldRef Name="FileLeafRef" /></OrderBy>' @("DocIcon", "LinkFilename", "Modified", "Editor", "Caller") -Default -RemoveIfExists






}













# List: Voicemails






# Add fields: wsp_ucc_vmd_max_retries, wsp_ucc_vmd_agentsip, wsp_ucc_vmd_processed, wsp_ucc_vmd_result, wsp_ucc_vmd_skill






# Update default view






function SiteUpdate_6.3_17($patchVersion)






{






	if ($patchCheck -ge $patchVersion) 






	{






		return






	}






	






	$listTitle = "Voicemails"






	AddPnPFieldFromXml '<Field Type="Number" Name="wsp_ucc_vmd_max_retries" DisplayName="Retries" Required="FALSE" Group="AnywhereNow" />' $null "wsp_ucc_vmd_max_retries" $listTitle -IgnoreDuplicateException






	AddPnPFieldFromXml '<Field Type="Text" Name="wsp_ucc_vmd_agentsip" DisplayName="AgentSip" Required="FALSE" Group="AnywhereNow" />' $null "wsp_ucc_vmd_agentsip" $listTitle -IgnoreDuplicateException






	AddPnPFieldFromXml '<Field Type="Boolean" Name="wsp_ucc_vmd_processed" DisplayName="Processed" Required="FALSE" Group="AnywhereNow" />' $null "wsp_ucc_vmd_processed" $listTitle -IgnoreDuplicateException






	AddPnPFieldFromXml '<Field Type="Text" Name="wsp_ucc_vmd_result" DisplayName="Result" Required="FALSE" Group="AnywhereNow" />' $null "wsp_ucc_vmd_result" $listTitle -IgnoreDuplicateException






	AddPnPFieldFromXml '<Field Type="Text" Name="wsp_ucc_vmd_skill" DisplayName="Skill" Required="FALSE" Group="AnywhereNow" />' $null "wsp_ucc_vmd_skill" $listTitle -IgnoreDuplicateException






	AddPnPView $listTitle "AllItems" "All Documents" 30 '<OrderBy><FieldRef Name="FileLeafRef" /></OrderBy>' @("DocIcon", "LinkFilename", "Modified", "Editor", "Caller", "Delivered", "DeliveredDate", "Flow", "RecordedDate", "wsp_ucc_vmd_max_retries", "wsp_ucc_vmd_agentsip", "wsp_ucc_vmd_processed", "wsp_ucc_vmd_result", "wsp_ucc_vmd_skill") -Default -RemoveIfExists






}













# Lists: Settings, SettingValues, Fields: wsp_ucc_scope, wsp_ucc_sv_scope






# Update choices






function SiteUpdate_6.3_18($patchVersion)






{






	if ($patchCheck -ge $patchVersion) 






	{






		return






	}






	






	$updateChoices = @("Bot", "CDR", "Chat", "Config", "CRM", "Dialer", "Email", "Flow", "ML Routing", "OutboundDialer", "Playlist", "Prompt", "Quality Monitor", "Recording", "Reservation", "Scheduling", "SLA", "Survey", "User", "Voicemail")






	$field1 = GetPnPField "wsp_ucc_scope"






	$field2 = GetPnPField "wsp_ucc_scope" "Settings"






	$field3 = GetPnPField "wsp_ucc_sv_scope"






	$field4 = GetPnPField "wsp_ucc_sv_scope" "SettingValues"






	AddChoiceFieldItems @($field1, $field2, $field3, $field4) $updateChoices






}













# List: CannedResponses






# Update default view with Attachments field






function SiteUpdate_6.3_19($patchVersion)






{






	if ($patchCheck -ge $patchVersion) 






	{






		return






	}






	






	# Check if required field exists before updating view






	$field = GetPnPField "wsp_ucc_cr_text" "CannedResponses"






	if ($field -ne $null) {






		AddPnPView "CannedResponses" "AllItems" "AllItems" 30 '<OrderBy><FieldRef Name="ID" Ascending="True" /></OrderBy>' @("LinkTitle", "wsp_ucc_cr_text", "wsp_ucc_cr_skill", "Attachments") -Default -RemoveIfExists






	}
}





