I want to edit a link on the left side of a SharePoint 2013 Standard site. Clicking on Edit Links and changing the link to a desired site and then saving shows error "This operation has timed out. Please try again." and clicking on Quick launch keeps spinning. I have full access to the site.
What could be the cause ?
did You consider using PowerShell as a workaround solution? If something in SharePoint that is OOB and does not work I always consider PS to fix something :).
For Your case something like this may do the trick (example to delete and update):
if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null)
{
Add-PSSnapin "Microsoft.SharePoint.PowerShell"
}
$SPWeb = Get-SPWeb "[URL]";
$QuickLaunch = $SPWeb.Navigation.QuickLaunch;
foreach($item in $QuickLaunch)
{
$item.Title;
if($item.Title -eq '[quickLunchItemTitleToDelete]')
{
$SPWeb.Navigation.GetNodeById($item.Id).Delete();
}
if($item.Title -eq '[quickLunchItemTitleToModify]')
{
$item.Title = "[NewName]";
$item.Update();
}
}
also I saw You have in site settings link to Quick Lunch. But You may turn on a feature in web to get the more advanced 'Navigation' link and maybe from there You will be able to modify the link You need.
Go to Site settings > Under Site collection admin > Site collection
features
Click Activate in-front of SharePoint Server Publishing
Infrastructure
BUT please be aware that turning on this feature will add also other components to Your which may be not desired.
I hope this will be of any help to You :)
Related
I created a Custom Action Ribbon button for sharepoint online and i want to run a javascript code when the button is clicked.
Sharepoint documentation even provides an example of it: https://learn.microsoft.com/en-us/sharepoint/dev/schema/commanduihandler-element?redirectedfrom=MSDN#example
but when i'm trying it always returns an error Custom action urls must start with "http:", "https:", "~appWebUrl" or "~remoteAppUrl".
Another part of the documentation says that it is not possible https://learn.microsoft.com/en-us/sharepoint/dev/sp-add-ins/sharepoint-add-ins-ux-design-guidelines?redirectedfrom=MSDN#figure-4-a-custom-action-in-the-contextual-menu
So how do i make it work? is not possible anymore and only can do redirections?
or it deppends of the location? i have it defined as <CommandUIDefinition Location="Ribbon.Documents.Actions.Controls._children"> so it is displayed in the command bar.
is it possible? ... I suppose no
Unfortunately it is not possible to add a custom ribbon action with a javascript logic with a provider hosted add-in π€. I think the articles/links where you found it is possible refer to the Server ribbon xml custom action that could be modified using sandbox solutions (like the old school SharePoint days π), but now the sandbox is rather not supported in SP online.
For the Ribbon custom actions that are added with the add-in you should specify the direct link. This is already what needs to be specified when we add a Ribbon action in VS to the Add-in project (we should specify were we navigate to)
I also found this MSDN article (quite up to date - from 2020) where we may find:
CustomAction cannot contain JavaScript: Any UrlActions or CommandActions must be a URL to navigate to. (...)
So I am like 95% sure it should π not be possible... but I leave the 5% as I am not like an SP PRO (I think it is hard to be one as it is like sooooo much to know π)
possible solution you might take
What you might do is to add the custom Ribbion xml using PowerShell and attach any javascript logic to it also using PowerShell π. The only drawback is that the javascript file needs to be also somehow added to the page (like it could be stored in the SiteAssets library).
So to do that we need to:
create an xml file locally with our Ribbon command button like:
<CommandUIExtension>
<CommandUIDefinitions>
<CommandUIDefinition Location="Ribbon.Library.ViewFormat.Controls._children">
<Button Id="Ribbon.Library.ViewFormat.About"
Command="TestButton"
LabelText="Test"
Image32by32="{SiteUrl}/_layouts/15/1033/Images/formatmap32x32.png?rev=23"
Image32by32Top="-273"
Image32by32Left="-1"
Description="Test"
TemplateAlias="o1" />
</CommandUIDefinition>
</CommandUIDefinitions>
<CommandUIHandlers>
<CommandUIHandler
Command="TestButton"
CommandAction="javascript:test({SelectedItemId});"
EnabledScript="javascript:checkOneItemSelected();" />
</CommandUIHandlers>
</CommandUIExtension>
the output of the above will be a button like this
Next create a js file (also locally) with functions for the CommandAction and EnabledScript (so we need a test() function and checkOneItemSelected()). So the contents like
function test(itemId) {
alert(itemId);
}
function checkOneItemSelected() {
return (SP.ListOperation.Selection.getSelectedItems().length == 1)
}
... so locally I have two files
Now we need to connect to the site we want to add the Ribbon button using PowerShell (best would be to use PnP Powershell π)
connect to site using Connect-PnPOnline -Url <SiteUrl>
now lets add the JS local file to the site assets library like Add-PnPFile -Path .\customJS.js -Folder "SiteAssets"
so the output is (the file in the library)
now lets add the Ribbon button to the site (using xml) like
$ribbon = Get-Content .\CustomRibbonButton.xml
$ribbon = [string]$ribbon
Add-PnPCustomAction -Name "RibbonTester" -Title "RibbonTester" -Description "-" -Group "Tester" -Location "CommandUI.Ribbon" -CommandUIExtension $ribbon -RegistrationType ContentType -RegistrationId 0x0101
so the output of the above will be our button in the ribbon (also we need to turn on classic UI /off modern UI, to see the ribbon π)
now lets attach our JS to the button like Add-PnPJavaScriptLink -Name "AboutButtonScript" -Url https://tenanttocheck.sharepoint.com/sites/ClassicDeveloperSite/SiteAssets/customJS.js -Scope Web please be aware the change url to your tenantπ
and the output is like
did you considerπ€
Also did you consider to use spfx extensions and modern UI to be more up to date? In extensions you may use JS and maybe do some http request to some endpoint you want to target with the ids array (but this is only a suggestion)
hope my post will be of any help π
BR
If I use the GET statement:
https://graph.microsoft.com/beta/sites/root/sites/ then it correctly returns a list of sub sites under my main SharePoint site. But if I add a new Team Site sub-site to my main site and then run the same command it now returns
{
"error": {
"code": "itemNotFound",
"message": "The resource could not be found.",
"innerError": {
"request-id": "604af4de-b2b5-48cf-802b-1952a7d10b42",
"date": "2017-10-07T16:56:48"
}
}
}
When I delete the new sub-site the GET statement works again. I thought it was an issue with my SharePoint site so I reported it to Office 365 SharePoint support. They get the same error. It happens with Graph v1.0 and beta but is not in the Known Issues list.
I am trying to use this to get the Drive Id of a SharePoint library on a sub-sub site but cannot get past this issue on the problem sub-site. Is there any other way of getting a Drive Id of libraries on the sub-site that Graph at present seems unable to access?
Whilst the issue of Graph not being able to return a list of more than 7 sub-sites is still there, I have found a work around to enable me to get the Drive Ids of the Drives on the sub-sites. By using the /sites: /{sitepath} option (NB the colon) I was able to go directly to the required sub-sites and then get the relevant drive Ids.
I just wanted to follow up and say we have now made some improvements that should hopefully let these kinds of queries work past 7 subsites. So hopefully this issue is now resolved.
Workaround (v1.0 only) : use
https://graph.microsoft.com/v1.0/sites?search=*
as proposed here
I've been working on a PowerShell script, with the intent of refreshing a excel document's SQL data daily via task scheduler. The excel document is hosted on SharePoint. I've (after much, much trial and error) gotten it to work up until the checkin part.
Basically, Task Scheduler fires the PowerShell script daily.
The script creates an excel COM object.
It verifies it can checkout the document, then does so if able.
It then performs the refresh.
Finally, it attempts to checkin the document. At this point, it just
hands and nothing happens. I should note this ONLY happens when the
script is run via task scheduler, and 'whether user is logged in or
not' is selected. If run from the PowerShell cmd line or the
option 'user must be logged in' is checked, everything performs
fine.
Couple important notes-
The account is a service account user, although we granted it local login during testing. It has GOT to be unattended in practice though.
I followed the instructions for folders on this page-
https://social.technet.microsoft.com/Forums/en-US/aede572b-4c1f-4729-bc9d-899fed5fad02/run-powershell-script-as-scheduled-task-that-uses-excel-com-object?forum=winserverpowershell
It is worth noting I also had to set permissions on the folders mentioned a few posts past the initial comment. I STRONGLY suspect my current issue is similar/related- but it must not be these folders because I have pretty open permissions here.
I had to remove 'enhanced IE security' as this is a server box and PowerShell couldn't initially 'see' the SharePoint site.
I've checked the event log- the office log is apparently operational, but there is no popup at the time of checkin apparently.
I've set and verified COM permission settings, although it is possible I missed something here. Excel wasn't listed in the APP list but adding the user to the call privileges moved me forward on the task.
I'm pretty sure this doesn't happen if I run it as a dev administrator.
CYA-
I'm aware MS doesn't endorse the above, but I'm also aware people get it to work.
Powerpivot for SharePoint is not really an option at this time.
This is like my third question ever (I normally bang my head against the wall until I get it, but I'm getting a bit bloody here for 'just' a PowerShell script. Please bear with me if I'm over/under wordy :)
Truncated script below- (removed try/catch and debug messages. If you want the cleaned full let me know, I'd love to save someone the trouble I had.)
$i = "http://supersecretintranetsite/excelwithsqldatacon.xlsx"
# Creating the excel COM Object
$Excel = New-Object -ComObject Excel.Application;
Start-Sleep -s 5
# Setting up Excel to run without UI and without alerts
$Excel.DisplayAlerts = $false
$Excel.ScreenUpdating = $false
$Excel.Visible = $false
$Excel.UserControl = $false
$Excel.Interactive = $false
If ($Excel.workbooks.CanCheckOut($i))
{
# Opening the workbook, can be local path or SharePoint URL
$Workbook = $Excel.workbooks.Open($i);
# Perform the check out
$Workbook = $Excel.workbooks.CheckOut($i)
$Workbook = $Excel.workbooks.Open($i);
Start-Sleep -s 15
# Calling the refresh
$Workbook.RefreshAll();
# Forces a hold until all Refreshing is done
$Excel.CalculateUntilAsyncQueriesDone()
# Saving and closing the workbook
# $Workbook.Save() #- this hangs too
Start-Sleep -s 15
# THIS HANGS
$Workbook.CheckInWithVersion();
Start-Sleep -sec 5
#Release Workbook
[System.Runtime.Interopservices.Marshal]::ReleaseComObject($Workbook)
}
$Excel.quit();
Turned out to be more folder permissions.
I added full control permissions for that user to the Appdata folder in the \windows*\config\systemprofile folders and it worked.
I'd assigned read/write but I guess that wasn't enough.
Recently we have moved our web application from one server to another in Sharepoint 2010. Back up of entire web application was taken and restored in another server. But in the new server , the PDF files in the document library is not getting opened in browser. it always open in browser
I have already made following changes but didn,t work
Set browser file handling to Permissive from central admin
Set "open in browser" in setting s of doc library
Set the doc library file handling property using
$docLib = $web.lists["Your Document Library Title"]
$docLib.BrowserFileHandling = "Permissive"
$docLib.Update()
Added "AllowedInlineDownloadedMimeType.Add("Application/Pdf") in web app
Installed Adober eader in client machine
Even after trying all these, the PDF files are still opening in Client application(Adobe reader) but not in the browser
It would have been great help if anybody provide a solution for this. I have been banging head on this for two days
Regards
Vishnu
You need to add the MIME type to SharePoint 2010 to enable this - and it needs to be done at Farm level.
The powershell on here will do it; (I've not run it, but it is Technet so source should be good)
# <#
# .DESCRIPTION
#
# This script adds new MIME type to "AllowedInlineDownloadedMimeTypes" property list of defined SharePoint 2010 Web Application.
#
# Script prompts you for MIME type and Web Application URL.
#
# Code shall run in context of Farm Administrators group member.
#
# .NOTES
# File Name : Add_MIME_Type.ps1
# Author : Kamil Jurik, WBI Systems a.s.
# Created : 11/12/2011
#
If ( (Get-PSSnapin -Name "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null ) {
Add-PSSnapin "Microsoft.SharePoint.PowerShell"
}
Get-SPWebApplication
$WebApp = Get-SPWebApplication $(Read-Host "`nEnter Web Application URL")
Write-Host `n"Mime Type Examples:"`n"application/pdf, text/html, text/xml"`n
If ($WebApp.AllowedInlineDownloadedMimeTypes -notcontains ($MimeType = Read-Host "Enter a required mime type"))
{
Write-Host -ForegroundColor White `n"Adding" $MimeType "MIME Type to defined Web Application"$WebApp.url
$WebApp.AllowedInlineDownloadedMimeTypes.Add($MimeType)
$WebApp.Update()
Write-Host -ForegroundColor Green `n"The" $MimeType "MIME type has been successfully added."
} Else {
Write-Host -ForegroundColor Red `n"The" $MimeType "MIME type has already been added."
}
You can set the Browse file handling property to permissive
http://technet.microsoft.com/en-us/library/cc262107(v=office.14).aspx
A user who created various lists in SharePoint Server 2010 has subsequently been deleted from the site collection. This leaves the user id in the SPList.Author property but results in "User cannot be found" messages in various places that try to instantiate the SPUser object.
Is there any supported way to update the SPList.Author property? I have tried with the server OM, Client OM and lists.asmx web service and have failed with all three.
I've never done it before, but using this guide here, here is what you could try on Powershell:
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
$siteUrl = "your sharepoint site url"
$webName = "your webname"
$spSite = new-object Microsoft.SharePoint.SPSite($siteurl)
$spWeb = $spSite.OpenWeb($webName)
$listName = "your listname"
$userLoginName = "your username"
$spList = $spWeb.Lists[$listName]
$spList.Author = $spWeb.AllUsers[$userLoginName]
$spList.Update() // I don't know if this is required.
maybe find a way to remove the user from the sitecollection
I have accepted that it is not possible to update SPList.Author, but my need to do so has also weakened.
The reason I wanted to do this was the encountering of "user cannot be found" errors on the list settings and workflow settings pages. I thought that it may have been originating in the list - because tools like SharePoint manager show "user cannot be found" when I examine the list author property.
It turned out, however, to be coming from workflow templates, not lists, that had been published by the since-removed user.