-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add cmdlet to delete default user pinned views #22
Labels
Comments
Need to validate supportability & overall impact - that said user default is empty and there is no ability to unpin a view that is non-standard (if a user does it by accident, testing, etc). Changing these settings will force the users cache to expire so doing this on a mass scale may not be advised. Approach I'm thinking of taking is:
|
Clear-CrmUserPinnedViews #this will clear all user pinned views (no matter what they have pinned)
Update-CrmRecord -Id $systemUserId -EntityLogicalName usersettings @{"personalizationsettings"=""} Remove-CrmUserPinnedView #this is an attempt to clear the views by entityid - which seems to fail in and of itself, but if you dump ALL of them first, then add the result back, that seems to work
$etc = 4 #clear out the users Account pinned views entity (otc/etc 4)
$us = Get-CrmRecord -EntityLogicalName usersettings -Fields personalizationsettings -Id (Invoke-CrmWhoAmI).UserId
$systemUserId = $us.ReturnProperty_Id
$settings=[xml]$us.personalizationsettings
$etc = 2
$node = $settings.DefaultGridViews.SelectSingleNode("//EntityTypeCode[.='$etc']")
if(!$node -ne $null){
$node = $node.ParentNode
$node.ParentNode.RemoveChild($node)
}
#Attempt 1 - Successful update - but it doesn't "take" without clearing first
Update-CrmRecord -Id $systemUserId -EntityLogicalName usersettings @{"personalizationsettings"=""}
Update-CrmRecord -Id $systemUserId -EntityLogicalName usersettings @{"personalizationsettings"=$settings.InnerXml}
#Attempt 2 also failed
$newSettings = New-Object Microsoft.Xrm.Sdk.Entity
$newSettings.Id = $systemUserId
$newSettings.LogicalName = "usersettings"
$newSettings.Attributes.Add("personalizationsettings",$settings.InnerXml)
$updateRequest = new-object Microsoft.Crm.Sdk.Messages.UpdateUserSettingsSystemUserRequest
$updateRequest.UserId = $systemUserId
$updateRequest.Settings=$newSettings
$conn.ExecuteCrmOrganizationRequest($updateRequest) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
, ignore anything else that isn't grid views.
The text was updated successfully, but these errors were encountered: