I want to programatically create list on Sharepoint using Web Services.
I tried "Lists.AddList Method" but it would create list in current site only.
Is there any other way to create list? (Using Web Services : C#)
You can create SPWeb object of the desired location and add list in it dynamically. See following:
http://msdn.microsoft.com/en-us/library/ms425818.aspx
Have you tried this MSDN page, Lists.AddList Method (Lists)?
I think here you can find what you need.
To Create List on specified path
Lists listService = new Lists();
listService.PreAuthenticate = true;
listService.Credentials = new NetworkCredential(username,password,domain;
String url = "http://YourServer/SiteName/"; // put your desired path here
listService.Url = url # + /_vti_bin/lists.asmx";
XmlNode ndList = listService.AddList(NewListName, "Description", 100);
Related
I'm Trying to create new instance of a DotNetBrowser and assign it to my panel inside windows forms.
Based on DotNetBrowser start guide, to create new instance of browser (that have its own cache, etc) I need to do following:
BrowserContextParams params1 = new BrowserContextParams("C:\\my-data1");
BrowserContext context1 = new BrowserContext(params1);
Browser browser1 = BrowserFactory.Create(context1);
My question is, what do I do with this browser now?
I want to asign it to my browserpanel like this
browserpanel.Controls.Add(browser1);
But this will not work because I need to have object of a class
WinFormsBrowserView to assign it to browserpanel. And If I create object of a type WinFormsBrowserView, I cant customize it as documentation explains.
And the Browser inside newly constructed WinFormsBrowserView is readonly, so i cant assign this browser to it.
Found solution:
BrowserContextParams params1 = new BrowserContextParams("C:\\my-data1");
context1 = new BrowserContext(params1);
browser1 = BrowserFactory.Create(context1);
WinFormsBrowserView browserview = new WinFormsBrowserView(browser1);
Here is the code which I have written to access the Projects and the team, but it shows some error. I want to access the project and then the Source Code present in the Source Control Explorer in the Project/Team.
Uri _serverUri = new Uri("MyURI");
string _teamProjectName = "MyProject";
TfsTeamProjectCollection collection =
TfsTeamProjectCollectionFactory.GetTeamProjectCollection(_serverUri);
// Retrieve the project URI. Needed to enumerate teams.
var css4 = collection.GetService<ICommonStructureService>();
ProjectInfo projectInfo = css4.GetProjectFromName(_teamProjectName);
// Retrieve a list of all teams on the project.
TfsTeamService teamService = collection.GetService<TfsTeamService>();
var allTeams = teamService.QueryTeams(projectInfo.Uri);
allTeams.ToList().ForEach
(
allteams => { Console.WriteLine(allteams); });
The error which it shows is "The type or namespace 'Core' does not exist in the namespace Microsoft.TeamFoundation.Server
I also want to access the source control, so if anyone can help me with both of my issues.
I am attempting to create two lists that are linked to each other, programmatically, on activation of my web part.
public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
SPWeb spWeb = properties.Feature.Parent as SPWeb;
if (spWeb != null)
{
// Create our Lists
spWeb.Lists.Add("Memeber Records", "Holds a list of Memebers", SPListTemplateType.GenericList);
spWeb.Lists.Add("Certification", "Certifications and Their Descriptions", SPListTemplateType.GenericList);
SPList list = spWeb.Lists["Memeber Records"];
SPList certList = spWeb.Lists["Certification"];
// Add Outr Fields
list.Fields.Add("Memebr ID", SPFieldType.Integer, true);
list.Fields.Add("Memeber Name", SPFieldType.Text, true);
// were missing a item - a drop down with static content such as: Association, Company, Head Office
list.Fields.Add("Memeber Certification", SPFieldType.Lookup, false);
list.Update();
certList.Fields.Add("Certfication Title", SPFieldType.Text, true);
certList.Fields.Add("Description", SPFieldType.Text, true); // This one should be a text box allowing 256 characters
certList.Update();
}
}
As you can see I am needing your help to figure out how to create a couple more things:
I need a drop down with static content in it as a field. But .Fields.Add() doesn't have a drop down feature in list
certList's second field is suppose to be a text box with up to 250 characte's if not more.
How do I link certList to list such that when selecting a member certification it pulls from the certtList
Is there anything else that I am missing to have this work upon activation of this web part? I scoped it to site but when deploying (when I created the project, I selected) its Farm instead of Sandbox
Have you tried using the choice field. The list.Fields.Add has a overload where you can populate the choices too. I haven't tried it but this is specifically for choice fields.
I am trying to learn using MonoTouch. I am basically trying to create something similar to the sms message application that is built into the iphone.
I want the Edit button and a add button within the root element. Is this possible?
Im creating the root element like
var root = new RootElement ("My Items");
Section section = new Section();
foreach (var item in GetData()) {
var element = new RootElement(item.ItemName,0,0) {
new Section(item.Description)
};
section.Add(element);
}
root.Add(section);
What do I need to do to add the 2 buttons and load the different views?
You are probably adding the root to a dialog view controller,
var dv = new DialogViewController(root,true);
In this case, just initialize the buttons for the navigation items of the view controller
dv.NavigationItem.RightBarButtonItem = new UIBarButtonItem("Edit", UIBarButtonItemStyle.Plain,null);
and so on and set up event handlers for dv.NavigationItem.RightBarButtonItem.Clicked.
That should do it!
I am attempting to load document files into a document library in SharePoint using the CopyIntoItems method of the SharePoint Copy web service.
The code below executes and returns 0 (success). Also, the CopyResult[] array returns 1 value with a "Success" result. However, I cannot find the document anywhere in the library.
I have two questions:
Can anyone see anything wrong with my code or suggest changes?
Can anyone suggest how I could debug this on the server side. I don't have a tremendous amount of experience with SharePoint. If I can track what is going on through logging or some other method on the server side it may help me figure out what is going on.
Code Sample:
string[] destinationUrls = { Uri.EscapeDataString("https://someaddress.com/Reports/Temp") };
SPCopyWebService.FieldInformation i1 = new SPCopyWebService.FieldInformation { DisplayName = "Name", InternalName = "Name", Type = SPListTransferSpike1.SPCopyWebService.FieldType.Text, Value = "Test1Name" };
SPCopyWebService.FieldInformation i2 = new SPCopyWebService.FieldInformation { DisplayName = "Title", InternalName = "Title", Type = SPListTransferSpike1.SPCopyWebService.FieldType.Text, Value = "Test1Title" };
SPCopyWebService.FieldInformation[] info = { i1, i2 };
SPCopyWebService.CopyResult[] result;
byte[] data = File.ReadAllBytes("C:\\SomePath\\Test1Data.txt");
uint ret = SPCopyNew.CopyIntoItems("", destinationUrls, info, data, out result);
Edit that got things working:
I got my code working by adding "http://null" to the SourceUrl field. Nat's answer below would probably work for that reason. Here is the line I changed to get it working.
// Change
uint ret = SPCopyNew.CopyIntoItems("http://null", destinationUrls, info, data, out result);
I think the issue may be in trying to set the "Name" property using the webservice. I have had some fail doing that.
Given the "Name" is the name of the document, you may have some success with
string targetDocName = "Test1Name.txt";
string destinationUrl = Uri.EscapeDataString("https://someaddress.com/Reports/Temp/" + targetDocName);
string[] destinationUrls = { destinationUrl };
SPCopyWebService.FieldInformation i1 = new SPCopyWebService.FieldInformation { DisplayName = "Title", InternalName = "Title", Type = SPListTransferSpike1.SPCopyWebService.FieldType.Text, Value = "Test1Title" };
SPCopyWebService.FieldInformation[] info = { i1};
SPCopyWebService.CopyResult[] result;
byte[] data = File.ReadAllBytes("C:\\SomePath\\Test1Data.txt");
uint ret = SPCopyNew.CopyIntoItems(destinationUrl, destinationUrls, info, data, out result);
Note: I have used the "target" as the "source" property. Don't quite know why, but it does the trick.
I didn't understand very well what you're tying to do, but if you're trying to upload a file from a local directory into a sharepoint library, i would suggest you create a webclient and use uploadata:
Example (VB.NET):
dim webclient as Webclient
webClient.UploadData("http://srvasddress/library/filenameexample.doc", "PUT", filebytes)
Then you just have to check in the file using the lists web service, something like:
listService.CheckInFile("http://srvasddress/library/filenameexample.doc", "description", "1")
Hope it was of some help.
EDIT: Don't forget to set credentials for the web client, etc.
EDIT 2: Update metada fields using this:
listService.UpdateListItems("Name of the Library, batchquery)
You can find info on building batch query's in here: link
The sourceurl is used in Sharepoint. It is a link back to the "Source Document." When in your document library, hover over the item, to the right appears a down pointing triangle. Clicking on it, brings up a menu. Click on the "View Properties" Option. On this page you will see the following "This item is a copy of http://null ( Go To Source Item | Unlink )"
Because we are using the Copy function Sharepoint is keeping track of the "Source item" as part of the Document Management feature.