posts - 16 , comments - 4 , trackbacks - 0

Wednesday, July 8, 2015

create custom user profile property of type taxomomy multivalue

http://sharepoint-community.net/profiles/blogs/sp2013-powershell-create-userprofile-taxonomy-based-property -----------------------------------OR-------------------------------------------- param ( # Site Url input parameter [string]$SiteUrlParameter ) try { $propertyNames = New-Object System.Collections.ArrayList $propertyDisplayNames = New-Object System.Collections.ArrayList $termSetNames = New-Object System.Collections.ArrayList $siteUrl = "http://ABC:123" if($SiteUrlParameter -ne $null) { $siteUrl = $SiteUrlParameter } # Add your Custom User Properties to the Arraylist below #if you add term set name as NA, the correspoding property will be added as single line of text $propertyNames.Add("UPS-ABC") $propertyDisplayNames.Add("ABC") $termSetNames.Add("ABC") $propertyNames.Add("UPS-ABC") $propertyDisplayNames.Add("ABC") $termSetNames.Add("ABC") $propertyNames.Add("UPS-ABC") $propertyDisplayNames.Add("ABC") $termSetNames.Add("ABC") $propertyNames.Add("UPS-ABC") $propertyDisplayNames.Add("ABC") $termSetNames.Add("ABC") $propertyNames.Add("UPS-ABC") $propertyDisplayNames.Add("ABC") $termSetNames.Add("ABC") if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null) { Add-PSSnapin "Microsoft.SharePoint.PowerShell" } [System.Void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Office.Server") [System.Void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Office.Server.UserProfiles") [System.Void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Office.Server.UserProfiles.UserProfileManager") $site = Get-SPSite $siteUrl $serviceContext = Get-SPServiceContext $site $upConfigMgr = New-Object Microsoft.Office.Server.UserProfiles.UserProfileConfigManager($serviceContext) $coreProperties = $upConfigMgr.ProfilePropertyManager.GetCoreProperties() $taxonomySession = Get-SPTaxonomySession -Site $site $loopcount = 0 foreach($propertyName in $propertyNames) { $propertyDisplayName = $propertyDisplayNames[$loopcount] $termSetName = $termSetNames[$loopcount] if($coreProperties.GetPropertyByName($propertyName) -ne $null) { Write-Host "Property Already exists, deleting" $propertyName $coreProperties.RemovePropertyByName($propertyName) } $upcoreproperty = $coreProperties.Create($false) $upcoreproperty.Name = $propertyName $upcoreproperty.DisplayName = $propertyDisplayName if($termSetName -ne "NA") { $upcoreproperty.Type = [Microsoft.Office.Server.UserProfiles.PropertyDataType]::StringMultiValue $upcoreproperty.IsMultivalued = $true $mytermSet = $taxonomySession.GetTermSets($termSetName,1033) $upcoreproperty.TermSet = $mytermSet[0] } else { $upcoreproperty.Type = [Microsoft.Office.Server.UserProfiles.PropertyDataType]::StringSingleValue $upcoreproperty.IsMultivalued = $false $upcoreproperty.Length = 100 } $upcoreproperty.Description = "This Property Value is populated by a Timer Job" $upcoreproperty.IsSearchable = $true $coreProperties.Add($upcoreproperty) $userProfilePropertyManager = $upConfigMgr.ProfilePropertyManager $userProfileTypeProperties = $userProfilePropertyManager.GetProfileTypeProperties([Microsoft.Office.Server.UserProfiles.ProfileType]::User) $userProfileProperty = $userProfileTypeProperties.Create($upcoreproperty) $userProfileProperty.IsVisibleOnEditor = $false $userProfileProperty.IsVisibleOnViewer = $true $userProfileTypeProperties.Add($userProfileProperty) $upSubTypeManager = [Microsoft.Office.Server.UserProfiles.ProfileSubtypeManager]::Get($serviceContext) $userProfile = $upSubTypeManager.GetProfileSubtype([Microsoft.Office.Server.UserProfiles.ProfileSubtypeManager]::GetDefaultProfileName([Microsoft.Office.Server.UserProfiles.ProfileType]::User)) $userProfileProperties = $userProfile.Properties $userProfileSubProperty = $userProfileProperties.Create($userProfileProperty) $userProfileSubProperty.DefaultPrivacy = [Microsoft.Office.Server.UserProfiles.Privacy]::Public $userProfileSubProperty.PrivacyPolicy = [Microsoft.Office.Server.UserProfiles.PrivacyPolicy]::OptIn $userProfileSubProperty.IsUserEditable = $false $userProfileSubProperty.UserOverridePrivacy = $false $userProfileProperties.Add($userProfileSubProperty) $userProfileProperty.CoreProperty.Commit() $userProfileProperty.Commit() $userProfileSubProperty.Commit() Write-Host "Propert Created InternalName" $propertyName " Display Name " $propertyDisplayName " Mapped to Termset " $termSetName $loopcount = $loopcount+1 } } catch { Write-Error "Error Creating Profile properites, check error details." Write-Error $_.message }

Posted On Wednesday, July 8, 2015 6:14 AM | Comments (1) | Filed Under [ taxonomy folksonomy CUSTOMUSERPROFILE USERPROFILE PROPERTY ]

confirm or alert code behind

http://stackoverflow.com/questions/5825165/javascript-alert-showmessage-from-asp-net-code-behind

http://stackoverflow.com/questions/28760687/invoke-onclientclick-of-button-in-code-behind

http://stackoverflow.com/questions/16393542/how-to-call-confirmation-box-in-if-condition-from-code-behind

ScriptManager.RegisterStartupScript(this,this.GetType(), "Message","confirm('Number of rows ');", true);
**if (ClientScript.RegisterStartupScript(typeof(Page), "Confirm", "<script type='text/javascript'>return Confirm('Are you sure you want to change Hiring Manager for this requirement.');</script>"))**

Posted On Wednesday, July 8, 2015 12:45 AM | Comments (1) |

Powered by: