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
Related
I develop on SharePoint 2013 foundation. For some SharePoint list there is immediately created alert for special user. Alert created programmatically. User noticed about list items fields changing through email. So may question when list fields changed different times user receive email only for one change, why? For more information Immediately Alert timer job run after that fields changing. How to configure alert programmatically (C#) in order alert to work for two changes or there is another way?
Sample code to create alert.
SPList list=web.Lists.TryGetList("Documents");
SPUser user = web.EnsureUser(#"domainName\user");
SPAlert newAlert = user.Alerts.Add();
newAlert.Title = "My Custom Alert";
newAlert.AlertType=SPAlertType.List;
newAlert.List = list;
newAlert.DeliveryChannels = SPAlertDeliveryChannels.Email;
newAlert.EventType = SPEventType.Add;
newAlert.AlertFrequency = SPAlertFrequency.Immediate;
newAlert.Update();
how to disable list item's attachment using coding in sharepoint 2010
Please help. I will provide further screen shots if needed.
You can set this via the SPList object using the EnableAttachments property. Here's a PowerShell example.
$web = $site.OpenWeb();
$list = $web.Lists["ListName"]
$list.EnableAttachments = $false
$list.Update()
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
I am new with SharePoint document library system with 2010 foundation. I need to create a document Id (auto generated one) whenever I add a new document in my SharePoint library. Do I need to write an event receiver or anything else ?
Any reference or guidelines are appreciated.
Thanks.
You do not need neither event receiver nor any code. Every item of document library (and any list) automatically gets unique ID whenever item is created.
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();