I need to extract som information from a SharePoint list. Let us call this list for list_A. And in list_A I have column containing sharepoint users. That show their lync status (online, offline, busy etc), and when I hover over that user name I will get an "toolbox" that shows additional information. (See the picture)
What I now want is to extract that list of users into an SharePoint web part and have the ability to show the same information as in list_A. In other words I want to get the lync integration, with their status and the info box on hover. I figure I will manage to extract the information from the list without any problems using a method somewhat like the one below:
using (SPSite site = new SPSite(url))
{
using (SPWeb web = site.OpenWeb())
{
SPList lists = web.Lists["listName"];
foreach (SPListItem item in lists.Items)
{
string test = Convert.ToString(item["columnName"]);
TextBox1.Text += test;
}
}
}
But the question is if there is an asp or sharepoint controller that will allow me to show this kind field on the web page/in the web part?
Create a LiteralControl and use the following code to display the user presence in your webpart
("<span><img border=\"0\" height=\"12\" src=\"/_layouts/images/imnhdr.gif\" onload=\"IMNRC('" + userEmail+ "')\" ShowOfflinePawn=\"1\" alt=\"\" id=\"user_presence_icon\"/></span>");
There is a forum discussion on this topic and can be refered here -
Hope this helps
Related
Creating a SP 2013 Online app using CSOM. I m creating a custom ASPX page in SP designer, and to insert and update item to a SharePoint list. Earlier the List input form was developed InfoPath 2013, where file Attachment control was used. Since the code is not rewritten using ClientContext, can someone tell me how it should be done?
You might want to Check out the SharePoint Stackexchange for SharePoint specific questions.
List list = web.Lists.GetByTitle("listtitle");
ListItem item = list.GetItemById(1);
var attachment = new AttachmentCreationInformation();
attachment.FileName = "fileName";
attachment.ContentStream = new MemoryStream(System.IO.File.ReadAllBytes("streamFile"));
Attachment att = item.AttachmentFiles.Add(attachment);
context.Load(att);
context.ExecuteQuery();
https://sharepoint.stackexchange.com/questions/144814/how-to-attach-files-to-list-item-using-client-object-model
I’m currently trying to use web part connections to connect an out the box List to my visual webpart. Now I can find lots of examples of connecting 2 custom web parts together using a user defined interface but am having trouble finding examples of the functionality I require.
Scenario 1 : Ability to add my Visual Web part to a list view and connect them so my WP is the consumer of the List and that when the user clicks/selects a row in the list view my web part would get sent the id of the item.
Scenario 2 : Ability to add my Visual Web part to a list display form and connect them so my WP is the consumer of the List item and the Id of the list item get passed to the WP when the form loads/displays.
Now I know that this is what I need to consume the data
[ConnectionConsumer("Parameter", AllowsMultipleConnections = false)]
public void ThisNameDoesNotMatter(IWebPartParameters provider)
{
_provider = provider ;
}
but unsure of whether I should be using the IWebPartParameters, IWebPartRow or the IFilterConsumer.
I guess I’m starting to wonder if this is even possible as I'm struggling to find any examples of this functionality.
Any help would be great.
Cheers
Lee
Ok so I found what I was looking for partialy, below is the code that captures the Connection object
private IWebPartField _provider = null;
[ConnectionConsumer("Parameter", AllowsMultipleConnections = false)]
public void ThisNameDoesNotMatter(IWebPartField provider)
{
_provider = provider ;
}
the IWebPartField Interface was what I was looking for to consume a value from anouther webpart (in my case a List column field).
To get the Field I needed if my custom webpart is on the display form of the list I just get it from the query string.
How can I create a function that copies some item from one Sharepoint discussion board to another? Everything is quite simple except field name Posted By, MyEditor, and Editor.
If this is a one-time thing, you might look at using the Content Deployment API (there's a Content Deployment Wizard app that provides a UI for it).
Otherwise, you should be able to set the "posted by" by using something like this (assuming web is an open SPWeb and newItem is a discussion item):
SPUser user = web.Users["DOMAIN\\username"];
newItem[SPBuiltInFieldId.Author] = user.ID;
newItem[SPBuiltInFieldId.Editor] = user.ID;
newItem.SystemUpdate();
I'm just starting to use sharepoint designer and realised there's a lot that can be done to extend the basic features in sharepoint. We have an email alert sent out when a new task is created (by the user) and I want to customise the email so that it also includes a link called 'Assign'. When clicked, I want this link to automatically update the task with the assigned to field for the person that clicked it.
So I think the way to do this would be to hard-code the assign to value in the url behind this link, but I have no idea if this is possible or if there is an easier/better way to do this.
Any advice would be appreciated as I'm a complete beginner.
thanks.
I will not cover "How to modify the contents of an eamil alert" here as that is a seperate question and there are a lot of articles that cover that already.
For the Assigned link :-
You would need to create a custom page (or web part on an existing page) as the destination of your Assign link - this would take the Task ID as a query string param and then update the assigned to with the current user.
You could make this flexible by also taking the ListID but you may want to think about how this could be abused and put appropriate measures in place.
EDIT - in response to comment.
This is top of my head, not checked in compiler. This would have to sit on the same server as SharePoint to work as its using the OM - if you want to use a different server (why would you though) then look in the web services.
private void updateAssignedTo(Guid listId, int itemID)
{
SPWeb web = SPContent.Current.Web();
SPList list = web.Lists[listId];
SPListItem item = list.GetItemById(itemID);
item["Assigned To"] = web.CurrentUser;
item.Update();
}
You're going to have to work out how to get this code into to page or web part (SharePoint Designer is not going to cut it I think, you need Visual Studio) but its a starting point.
I cannot show the content of a document library using a list view contained in a web part located on my root web application.
Here is the site structure:
main_site
subsite1
Shared Documents
subsite2
Shared Documents
My webpart is located on the main_site.
In this webpart, I have a Sharepoint ListViewWebPart in which I want to show the Shared Documents from subsite1 for instance, but it does not seem to work. I get the following error:
List does not exist
The page you selected contains a list
that does not exist. It may have been
deleted by another user.
What is odd is that when I debug, I can see that the SPList is correctly initialized and contains the element of my list. However at the line Controls.Add(mylistview), is where the error occurs.
Here is the code I use to bind the list to my ListView:
SPList list = SPContext.Current.Site.AllWebs["subsite1"].Lists["Shared Documents"];
ListView lv = new ListView();
lv.ListId = list.ID.ToString();
lv.ViewId = list.DefaultView.ID.ToString();
lv.DataBind();
this.Controls.Add(lv);
Does someone have a logical explaination and solution to this problem?
The problem is that the list is in another site.
It is possible to use the ListViewWebPart to reference a list from another site in the same site collection. You need to use the WebId property to do this. Here is a code example.
Another option is to use SharePoint Designer to create a Data View Web Part. This will allow you to use a list from another site or the SharePoint web serivces to pull data in. The results look similar to the list view web part and there is some powerful functionality you can use. This is the first blog post I found that demonstrates this, there should be several others.
Finally, you could use the Content Query Web Part. You probably know this one already and it is really more for displaying and not manipulating data.
Edited to remove incorrect information.