I have a document library in a sub site. How do I add a link to that library into the root site's left navigation bar?
Dynamic or static links are fine.
Assuming you mean the Quick Launch (which is the left-side navigation shown in most non-application pages), then click "Site Actions", and choose "Site Settings". Under "Look and Feel", pick "Quick Launch". You can add the sub site's document library as a heading of its own, or as a link underneath any heading (it really doesn't matter too much outside of design perspective). This method is best for static links, of course.
The Quick Launch is not restricted to the current site: you can link any external URL you have. The document library of the subsite, basically, is treated as an external URL to the root site. Just make sure you use the full URL, then there's no chance for failure.
This should do it, if you want to do it programmatically:
using (SPSite site = new SPSite("http://localhost"))
{
using (SPWeb web = site.OpenWeb())
{
var navigationNode = new SPNavigationNode("stackoverflow","http://www.stackoverflow.com", true);
web.Navigation.QuickLaunch.AddAsLast(navigationNode);
web.Update();
}
}
Related
How do you use redirection on Acumatica mobile xml or msdl to redirect to an external link?
All I could find is If an action on an Acumatica ERP form provides redirection to an external URL, you can map the action to use it in the mobile app. To do this, you need no additional attributes in the action object. However, the redirect attribute of the tag must be set to True, as shown in the following example.
Thanks
There may be other ways, but from the new T410 course for MSDL in 2018R2, you need to do a couple of steps. (Got this at Acumatica Summit 2018 Web Services course - Lesson 6 in the training guide which should be available soon if not already.)
First, define a new toolbar button on the form for your external link
(This example is for the SO303000 screen)
public PXAction<AR.ARInvoice> TestURL;
[PXButton(CommitChanges=true)]
[PXUIField(DisplayName = "TestURL")]
protected void testURL(){
throw new PXRedirectToUrlException(
"http://www.acumatica.com",
"Redirect:http://www.acumatica.com"
)
}
After publishing your project, go back to the Customization Project in the Mobile Application section to map the button. Add this to the commands section of the page as shown in the following example.
add container "InvoiceSummary" {
add field …
add recordAction "TestURL" {
behavior = Void
redirect = True
}
}
Not sure if this answered your question as you pretty much had the MSDL code listed, so maybe it is a matter of where you placed your code within the mobile definition? In the training class, we placed it inside the container where we wanted the link which then appears on the menu on the mobile app when viewing that container.
We have developed an internal portal with multiple subsites using sharepoint office 365. We created our own page layouts/masterpage for the sites and most of the things like menu's, page body and page logos are customized(unique for all sites/subsites).
Each page has a header logo and a url assigned to that logo(logo describes site or subsite name). We have written a javascript file to load these logo and url and calling on the masterpage. Now the problem is these logo and link should load based on Global navigation
Example:
If the site is using the same navigation items as the parent site?
Yes - pull logo and link from site above
No - pull logo and link according to site name
if i get the GlobalNavigation setting value then i can do this in javscript file. Is there a way to get this GlobalNavigation setting value in javascipt file? I googled on this but didn't get enough information.
Thanks in advance,
Amarnath
--------UPDATED-------
I am using the below code but getting error "sp.runtime.js:2 Uncaught Error: The property or field 'Source' has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly requested"
used code
var ctx = SP.ClientContext.get_current();
var web = ctx.get_web();
//Navigation Provider Settings for Current Web.
var webNavSettings = new SP.Publishing.Navigation.WebNavigationSettings(ctx, web);
//Global Navigation (Top Navigation Bar)
var navigation = webNavSettings.get_globalNavigation();
navigation.set_source(1);
webNavSettings.update();
ctx.executeQueryAsync(onSuccess, onFailure);
We have a specific business need where we need to allow users to be able to create Wiki Page in a Wiki Library but restrict them from adding web parts to a Wiki Page. If we provide a user to contribute access to the Wiki Library, the user is able to add web part by clicking on Insert and add an existing web part.
Does anyone know anyway to have the user be able to contribute to the content of the page by editing it, but not add web parts to the page?
Thanks
If you can add custom code you could create an event receiver feature for the list item ItemUpdating event for the wiki in order to check for the presence of a web part and cancel the save and display a message.
Event receivers for lists will fire for all lists based on a template (so in your case all wiki libraries) if you only want this to operate on an individual instance then modify the sample code below to check for the wiki library instance you want to control.
public override void ItemUpdating(SPItemEventProperties properties)
{
base.ItemUpdating(properties);
SPListItem item = properties.ListItem; //get the list item being updated
string pageUrl = item.Url; //get the item url for the web part manager
SPLimitedWebPartManager lwpm = properties.Web.GetLimitedWebPartManager(pageUrl, PersonalizationScope.Shared); //get the web part manager
if (lwpm.WebParts.Count > 0) //test for the presence of any web parts
{
properties.Cancel = true; //cancel the save
properties.ErrorMessage = "WebParts are not allowed on this wiki page."; //display message to the user
}
}
I have a SharePoint 2010 MySites set up on its own web application. There is the standard site collection at the base level, http://site:80/.
The personal sites for each user is at the managed URL /personal/.
I have a working event handler which add items to the Newsfeed when a user adds something to a picture library.
THE PROBLEM:
The problem is, this only works if they add to a picture library at the base site collection, http://site:80/, and does NOT work if they add to http://site:80/personal/last first/.
Does anyone know why? The event handler feature is site scoped and my understanding is that it should work on all subsites.
The problem is that personal sites are not subsites of My Site host. In fact each user's personal site is a site collection on its own. So basically you need to register your event receiver not only for My SIte host, but also for each user's personal site.
Ok. Because you can only 'staple' features to site definitions which will be provisioned in the future, you need a way to activate new features on existing sites.
So, the fix I discovered and used follows:
The default page for the newsfeed is http://site:80/default.aspx. If you create an event receiver and scope it for 'site' and deploy it globally or to that web application, then it will work on the base site collection. Each personal site is a site collection and has the feature but it needs to be activated on each personal site collection.
So, in the default.aspx page, you place the following which will activate the feature if it has not yet been activated.
<script runat="server" type="text/c#">
protected override void OnLoad(EventArgs e) {
base.OnLoad(e);
String sAccount = (((SPWeb)((SPSite)SPContext.Current.Site).OpenWeb()).CurrentUser.LoginName).Split('\\')[1];
String basePersonalURL = "http://site:80/personal/";
String eventReceiverFeatureId = "12345678-1234-1234-1234-1234567890ab";
using(SPSite site = new SPSite(basePersonalURL + sAccount)) {
site.AllowUnsafeUpdates = true;
using(SPWeb web = site.RootWeb) {
web.AllowUnsafeUpdates = true;
try { site.Features.Add(new Guid(eventReceiverFeatureId)); } catch {}
web.AllowUnsafeUpdates = false;
}
site.AllowUnsafeUpdates = false;
}
}
</script>
You also need to edit the web.config file in order to allow inline code to run for this page. Hope this helps.
I'd like to expose a web part to some users, but not all of them. How can I show or hide a web part in the Add Web Parts pop up window? I'd like to do this through code, and I'm hoping to use SharePoint Roles to make this happen.
I know you can manage which web parts show up in the Add Web Parts window in the Web Part Gallery.
While I haven't done it... since it's just another SharePoint List, you should be able to programmatically assign roles to Groups/Users?
More Info...
Update - Since you want to see some code. Nothing special, just a quick hack. You'll definitely want to do your standard error checking, etc. HTH :-)
using (SPSite site = new SPSite("YOUR SP URL"))
{
using (SPWeb web = site.OpenWeb())
{
SPList list = web.Lists["Web Part Gallery"];
// Your code for choosing which web part(s) to modify perms on
// will undoubtedly be more complex than this...
SPListItem listItem = list.GetItemById(19);
SPPrincipal groupToAdd = web.SiteGroups["YOUR GROUP NAME"] as SPPrincipal;
SPRoleAssignment newRoleAssignment = new SPRoleAssignment(groupToAdd);
SPRoleDefinition newRoleDefinition = web.RoleDefinitions["Read"];
newRoleAssignment.RoleDefinitionBindings.Add(newRoleDefinition);
listItem.RoleAssignments.Add(newRoleAssignment);
}
}
You can do this with SharePoint Groups.
Go to the Web Part Gallery, click "Edit" on the web part you wish to scope, then click Manage Permissions. Here you can specify which users or groups can use the web part.