Copy one list items new list using client side object model
Hi,
I have a requirement like i need to copy one list information to new list with createdby and modified by fields.I need to use client side object model code.Can u please send me the code sample.
Regards,
Praveen
Hi,
According to your post, my understanding is that you want to copy one list items new list using client side object model.
You can use console application.
Here is a similar thread for your reference:
https://social.technet.microsoft.com/Forums/sharepoint/en-US/28a43891-7505-4d34-b513-fdd66773c2a3/copy-list-item-to-another-list-using-client-object-model-in-console-application?forum=sharepointdevelopmentprevious
Best Regards,
Linda Li
Linda Li
TechNet Community Support
Similar Messages
-
Cross Site Collection lookup using client side object model
I have to do Cross Site Collection lookup using client side object model or Odata ,
no servier side.. any ideas experts?Did you read about cross site publishing feature in SP 2013?
Check this out
http://sharepoint.microsoft.com/blog/Pages/BlogPost.aspx?pID=1038
http://blogs.technet.com/b/sharepoint_quick_reads/archive/2012/09/18/sharepoint-2013-cross-site-publishing.aspx
http://blog.helloitsliam.com/Lists/Posts/Post.aspx?ID=89
http://blogs.msdn.com/b/ritazh/archive/2012/09/26/sharepoint-2013-how-to-setup-cross-site-publishing-enable-catalog-use-managed-navigation.aspx
http://stackoverflow.com/questions/1151036/sharepoint-lookup-column-across-site-collection-boundary
You will need custom code for this, but since the amount is minimal and this is Stack Overflow I assume that won't be a problem. You will want to make your own listview web part that queries the list using ListViewByQuery. An example can be found here:
http://blogs.msdn.com/b/ramg/archive/2009/04/21/implementing-a-simple-cross-site-collection-list-view-webpart.aspx -
Full mask permission in SharePoint using Client Side Object Model
Full mask permission in SharePoint using Client Side Object Model does not include all the base permission while it does have all base permission in server side . Is this a bug ?
Or do we have any workaround for this.
BasePermissions.Set(PermissionKind.FullMask); is not updating all the permissions.
It seems that there is some limitation with Microsoft.SharePoint.Client.dll as mentioend at below link . Do we have any workaround here.
http://break962.rssing.com/browser.php?indx=7116806&last=1&item=9
Ashish Baranwal || To know what you know and what you do not know, that is true knowledgeYou can write your own loop to upload multiple files via an individual call.
http://sharepoint.stackexchange.com/questions/108525/multiple-file-upload-with-metadata-using-rest/108532#108532
More reference: http://sharepointfieldnotes.blogspot.com/2014/04/uploading-documents-and-setting.html
Please 'propose as answer' if it helped you, also 'vote helpful' if you like this reply. -
Import TermSet CSV using client side object model
Hello,
I want to import CSV in TermStore using client side object model. Unfortunately there is no ImportManager here.
Is there any other way (Other than reading from CSV and adding term one by one to term store)?
Regards, Nanddeep NachanHi,
Here is a tool(server-side) from codeplex for your reference:
SharePoint 2010 CSV Bulk Taxonomy TermSet Importer/Exporter
If you want to import termsets from CSV in Client-Side, we can refer the tool above.
You can develop a windows form application and use .Net Client Object Model to achieve it. The following articles is about how to operate the termset using Client Object Model for you reference:
http://sundarnarasiman.net/?p=87 (Download)
http://code.msdn.microsoft.com/office/SharePoint-2013-Synchronize-d40638d1/sourcecode?fileId=72317&pathId=166025385
http://www.c-sharpcorner.com/Blogs/10853/how-to-create-a-term-set-for-the-specified-group-using-clien.aspx
Thanks,
Dennis Guo
TechNet Community Support
Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
[email protected]
Dennis Guo
TechNet Community Support -
Hi,
The requirement is to create ""Document Sets in Bulk" using JSOM. I am using the following posts:-
http://blogs.msdn.com/b/mittals/archive/2013/04/03/how-to-create-a-document-set-in-sharepoint-2013-using-javascript-client-side-object-model-jsom.aspx
http://social.msdn.microsoft.com/Forums/sharepoint/en-US/1904cddb-850c-4425-8205-998bfaad07d7/create-document-set-using-ecma-script
But, when I am executing the code, I am getting error "Cannot read property 'DocumentSet' of undefined "..Please find
below my code. I am using Content editor web part and attached my JS file with that :-
<div>
<label>Enter the DocumentSet Name <input type="text" id="txtGetDocumentSetName" name="DocumentSetname"/> </label> </br>
<input type="button" id="btncreate" name="bcreateDocumentSet" value="Create Document Set" onclick="javascript:CreateDocumentSet()"/>
</div>
<script type="text/javascript" src="//ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.2.min.js"> </script>
<script type="text/javascript">
SP.SOD.executeFunc('sp.js','SP.ClientContext','SP.DocumentSet','SP.DocumentManagement.js',CreateDocumentSet);
// This function is called on click of the “Create Document Set” button.
var ctx;
var parentFolder;
var newDocSetName;
var docsetContentType;
function CreateDocumentSet() {
alert("In ClientContext");
var ctx = SP.ClientContext.get_current();
newDocSetName = $('#txtGetDocumentSetName').val();
var docSetContentTypeID = "0x0120D520";
alert("docSetContentTypeID:=" + docSetContentTypeID);
var web = ctx.get_web();
var list = web.get_lists().getByTitle('Current Documents');
ctx.load(list);
alert("List Loaded !!");
parentFolder = list.get_rootFolder();
ctx.load(parentFolder);
docsetContentType = web.get_contentTypes().getById(docSetContentTypeID);
ctx.load(docsetContentType);
alert("docsetContentType Loaded !!");
ctx.executeQueryAsync(onRequestSuccess, onRequestFail);
function onRequestSuccess() {
alert("In Success");
SP.DocumentSet.DocumentSet.create(ctx, parentFolder, newDocSetName, docsetContentType.get_id());
alert('Document Set creation successful');
// This function runs if the executeQueryAsync call fails.
function onRequestFail(sender, args) {
alert("Document Set creation failed" + + args.get_message());
Please help !!
Vipul JainHello,
I have already tried your solution, however in that case I get the error - "UncaughtSys.ArgumentNullException: Sys.ArgumentNullException:
Value cannot be null.Parameter name: context"...
Also, I tried removing SP.SOD.executeFunc
from my code, but no success :(
Kindly suggest !!!
Vipul Jain -
What is Sharepoint client side object model ?
What is Sharepoint client side object model ?
The client-side object model (CSOM) provides client-side applications with access to a subset of the SharePoint Foundation server object model, including core objects such as site collections, sites, lists, and list items. As described in Data Access for
Client Applications, the CSOM actually consists of three distinct APIs—the ECMAScript object model, the Silverlight client object model, and the .NET managed client object model—that target distinct client platforms. The ECMAScript object model and the Silverlight
client object model provide a smaller subset of functionality. This is designed to enhance the user experience, because it minimize the time it takes Silverlight applications or JavaScript functions running in a Web page to load the files required for operation.
The .NET managed client object model provides a larger subset of functionality for standalone client applications. However, these APIs provide a broadly similar developer experience and work in a similar way.
You can write both managed client object model code and JavaScript Client Object model code in Visual Studio. As an example, you can create a console application having managed client object model code. Similarly, you may create a Visual Web Part and have
JavaScript client object model code in it. The JavaScript client object model code can also be directly written inside the SharePoint Designer as well.
Blog | SharePoint Learnings CodePlex Tools |
Export Version History To Excel |
Autocomplete Lookup Field -
Client side object model examples in sharepoint 2010
Hi,
I wanted to learn client side object model in share point 2010.Please provide some urls with examples.
Regards,
PraveenHi Praveen,
here is your links to start with ....explained with examples. :)
http://www.codeproject.com/Articles/399156/SharePoint-Client-Object-Model-Introduction
http://zimmergren.net/technical/sp-2010-getting-started-with-the-client-object-model-in-sharepoint-2010
Please 'propose as answer' if it helped you, also 'vote helpful' if you like this reply. -
Implementation Options: Server Side Object Model & Client Side Object Model
Hi All, I'm design a custom web application and it will be deploy on SharePoint 2010/2013 (to be confirmed) server, and I found some aritical as follows:
http://consultingblogs.emc.com/sanjaypatel/archive/2011/09/17/comparison-between-server-side-object-model-client-object-model-rest-api-s-and-decision-matrix-on-what-to-use-when.aspx
May I ask ask your advice for following items?
1) Is the above URL still valid? e.g. Vice Versa for SharePoint 2013?
2) Microsoft has a phase out plan for server side object model or not? (e.g. MOSS 202X)
3) For programmatcally update of SharePoint permission: should I call client-side OM instead of server-side OM even I will deploy the web application to SharePoint server?
Thank you very much.
.NET Beginner 3.5In sharepoint 2013 I don't think this link is
http://consultingblogs.emc.com/sanjaypatel/archive/2011/09/17/comparison-between-server-side-object-model-client-object-model-rest-api-s-and-decision-matrix-on-what-to-use-when.aspxis reliable at all.
what is your say?
====================================================
Hi All, I'm design a custom web application and it will be deploy on SharePoint 2010/2013 (to be confirmed) server, and I found some aritical as follows:
http://consultingblogs.emc.com/sanjaypatel/archive/2011/09/17/comparison-between-server-side-object-model-client-object-model-rest-api-s-and-decision-matrix-on-what-to-use-when.aspx
May I ask ask your advice for following items?
1) Is the above URL still valid? e.g. Vice Versa for SharePoint 2013?
2) Microsoft has a phase out plan for server side object model or not? (e.g. MOSS 202X)
3) For programmatcally update of SharePoint permission: should I call client-side OM instead of server-side OM even I will deploy the web application to SharePoint server?
Thank you very much.
.NET Beginner 3.5 -
Creating/copying documents using client side object (javascript)
Hi
I want to the user to press a button and this creates or copies documents (Excel) into a document library on the same site. There are many examples showing how to do this for a list but how can it be achieved for documents?
I've looked at SPFile.CopyTo method but dont know how to use it.
So the source file would have a number of destination files and the name and column data would be altered at time of creation. Looking for a client side javascript solution.
Hope someone can assist.
ThanksHi,
According to your description, my understanding is that you want to copy or create excel files into a document library using JavaScript Client Object Model.
For copying excel files, you can use get_files function to get files within a specific folder , and then you can use file collection
push function to copy files and get_name function to get the file name.
Here is a detailed code demo for your reference:
How do I move files from one document library to another using JSOM?
For creating files, you can use Jquery upload plugin to achieve it,here is a detailed code demo for your reference:
How to Upload File to Document Library using JavaScript Client Object Model?
Thanks
Best Regards
TechNet Community Support
Please remember to mark the replies as answers if they help, and unmark the answers if they provide no help. If you have feedback for TechNet Support, contact
[email protected] -
How to get plain text out of a multi line text field in Client Side Object Model?
I am trying to read plain text from a MultiLineTextField in a List. This is how my code looks so far:
//Get connection
ClientContext context = new ClientContext("URL");
Web site = context.Web;
context.Load(site);
context.ExecuteQuery();
//Get list collection
ListCollection lists = context.Web.Lists;
context.Load(lists);
context.ExecuteQuery();
//Get specific list
List menu = lists.GetByTitle("menu");
CamlQuery camlQuery = new CamlQuery();
camlQuery.ViewXML = "<View/>";
ListItemCollection dishes = menu.GetItems(camlQuery);
context.Load(menu);
context.Load(dishes);
context.ExecuteQuery();
//Iterate through all dishes
foreach(ListItem dish in dishes)
Console.WriteLine("Dish: {0}:", dish.FieldValues["Name"]);
Console.WriteLine("Price: {0}:", dish.FieldValues["Price"]);
//Here I get my problem
Console.WriteLine("Ingredients: {0}:", dish.FieldValues["Ingredients"]);
In the last line where I try to read the ingredients, I am reading from a MultiLineTextField which is set to RichText. It is also supposed to stay in RichText format, as hyperlinks are supposed to be added there. The problem is that the output not only contains
div-tags but also some weird question marks I never added to the field. I am trying to solve this issue for a couple of days now but it seems that there are only two possible solutions.
Set the field from RichText to PlainText, which is not an option in my case.
Use Regex to remove the div-tags. Please do not suggest this option. Mainly because I do not consider this to be a clean solution for this issue. Plus, I tried it and it removes the tags but those weird question marks stay.
There seems to be a third option I found
here. It is also mentioned in this
question and it seems to work. But I can not get it to work for me. This is how it looks:
string myString = item.FieldMultiLineText[Field_Name];
So I wonder what is item supposed to be here? I suppose it is not a
ListItem because in my case it does not offer a FieldMultiLineText-property.
A short, informative code snippet would be great if you decide to help me with this issue.
Thanks in advance.
Algorithmen und Datenstrukturen in C#:
TechNet WikiThank you for your reply. Unfortunately ListItem does not contain a definition for the Fields method.
Algorithmen und Datenstrukturen in C#:
TechNet Wiki
You need to use the Microsoft.SharePoint class library and then use the sharepoint version of all the list objects you are using. See below.
//Get connection
ClientContext context = new ClientContext("URL");
Web site = context.Web;
context.Load(site);
context.ExecuteQuery();
//Get list collection
SPListCollection lists = context.Web.Lists;
context.Load(lists);
context.ExecuteQuery();
//Get specific list
SPList menu = lists.GetByTitle("menu");
CamlQuery camlQuery = new CamlQuery();
camlQuery.ViewXML = "<View/>";
SPListItemCollection dishes = menu.GetItems(camlQuery);
context.Load(menu);
context.Load(dishes);
context.ExecuteQuery();
//Iterate through all dishes
foreach(SPListItem dish in dishes)
Console.WriteLine("Dish: {0}:", dish.FieldValues["Name"]);
Console.WriteLine("Price: {0}:", dish.FieldValues["Price"]);
//Here I get my problem
SPFieldMultiLineText multilineField = dish.Fields.GetField("Ingredients") as SPFieldMultiLineText;
string ingredients = "";
if (multilineField != null)
ingredients = multilineField.GetFieldValueAsText(dish["Ingredients"]);
Console.WriteLine("Ingredients: {0}:", ingredients);}
I hope this helps
Alex -
SharePoint 2013 Client Side Object Model Javascript
Hi,
I am using Javascript Client Object Model in SharePoint 2013. What i am trying to do is:
retrieve items from a particular list which exist on an another site collection. However, the Items that I want to retrieve will be based on particular value in the current site's list where I am writing the script.
So for eg: I have a sharePoint list called "project status" in site A with project name (hyperlink URL field) and project status as Managed metadata fields as two fields.
I have site B where I have "projects" list with Project name as the URL field. what I want to do is compare the project URL name in Projects list in site B to the Project name URL in Project status list in Site A and retrieve the status
so I can do a dashboard in site B using the same status in Site AHi Cooltechie1234,
You can filter the list item using CAML Query firstly and then set the managed metadata field label using JavaScript Client Object Model.
If you have trouble in CAML Query, I suggest you can use CAML Designer to figure it out.
More reference:
http://cann0nf0dder.wordpress.com/2013/04/10/search-caml-query-with-managed-metadata/
http://sharepoint.stackexchange.com/questions/113146/how-do-you-properly-write-to-a-managed-metadata-column-from-jsom-sharepoint-20
http://www.vrdmn.com/2012/12/working-with-taxonomy-and-javascript-in.html
Best Regards
Zhengyu Guo
TechNet Community Support -
URL data type in CAML Query with Client side object model
hi,
How do I write a CAML query to filter list items based on the URL field using it's Description?
Same with REST API. How do I construct a REST query so that filter list items based on the URL data type using it's Description.Hi Cooltechie,
Thanks for posting your query, Below are the example that you can use in your CAML query
<Where><Eq><FieldRef Name="FileRef"/><Value Type="Url">sites/SiteCollection/SubSite/Site Documents/Excel Report.xls</Value></Eq></Where>
Note: Do not include the server name or beginning /.
The following examples assuming you have a list or library setup with a URL column named "My Document".
The link is to a document that is hosted on the sharepoint server (do not need server name):
<Where><Eq><FieldRef Name="My_x0020_Document"/><Value Type="URL">/sites/subsite/Site%20Documents/Excel%20Report.xls</Value></Eq></Where>
The link is an absolute URL to something not on the server... for example http://www.google.com:
<Where><Eq><FieldRef Name="My_x0020_Document"/><Value Type="URL">http://www.google.com</Value></Eq></Where>
I hope this is helpful to you, mark it as Helpful.
If this works, Please mark it as Answered.
Regards,
Dharmendra Singh (MCPD-EA | MCTS)
Blog : http://sharepoint-community.net/profile/DharmendraSingh -
Client side object model examples
Hi,
I wanted to learn more about client object model with examples.Can u please share some important urls to learn client object model with examples.
Regards,
PraveenRefer to the following articles, hope it helps
http://msdn.microsoft.com/en-us/library/office/fp179912(v=office.15).aspx
http://msdn.microsoft.com/en-us/library/ee857094(v=office.14).aspx
http://www.codeproject.com/Articles/399156/SharePoint-Client-Object-Model-Introduction
--Cheers -
Query list items and display in client webpart..
I am using the code below to display list items in clientwebpart but getting errors.Below is the code written in js file..What is wrong with the code??
Error:javaScript runtime error: Unable to set property 'innerText' of undefined or null reference
'use strict';
var context = SP.ClientContext.get_current();
var user = context.get_web().get_currentUser();
var web;
var spHostUrl;
var parentcontext;
spHostUrl = decodeURIComponent(getQueryStringParameter('SPHostUrl'));
parentcontext = new SP.AppContextSite(context, spHostUrl);
web = parentcontext.get_web();
var list = web.get_lists().getByTitle("ListsTask");
var camlQuery = new SP.CamlQuery();
camlQuery.set_viewXml("");
this.listItems = list.getItems(camlQuery);
context.load(listItems);
context.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded),
Function.createDelegate(this, this.onQueryFailed));
// This code runs when the DOM is ready and creates a context object which is needed to use the SharePoint object model
$(document).ready(function () {
getUserName();
// This function prepares, loads, and then executes a SharePoint query to get the current users information
function getUserName() {
context.load(user);
context.executeQueryAsync(onGetUserNameSuccess, onGetUserNameFail);
// This function is executed if the above call is successful
// It replaces the contents of the 'message' element with the user name
function onGetUserNameSuccess() {
$('#message').text('Hello ' + user.get_title());
// This function is executed if the above call fails
function onGetUserNameFail(sender, args) {
alert('Failed to get user name. Error:' + args.get_message());
function getQueryStringParameter(urlParameterKey) {
var params = document.URL.split('?')[1].split('&');
var strParams = '';
for (var i = 0; i < params.length; i = i + 1) {
var singleParam = params[i].split('=');
if (singleParam[0] == urlParameterKey)
return decodeURIComponent(singleParam[1]);
function onQuerySucceeded() {
$("#results").empty();
var listInfo = '';
var listEnumerator = listItems.getEnumerator();
listInfo += "<table><tr><th>Id</th><th>Title</th></tr>";
while (listEnumerator.moveNext()) {
var listItem = listEnumerator.get_current();
listInfo += '<tr><td>' + listItem.get_item('ID') + '</td>'
+ '<td>' + listItem.get_item('Title') + '</td>'
+ '</tr>\n';
listInfo += '</table>';
$("#results").html(listInfo);
function onQueryFailed(sender, args) {
$("#results").empty();
$("#results").text('Request failed. ' + args.get_message() +
'\n' + args.get_stackTrace());HI,
I have modified your code.
'use strict';
var context = SP.ClientContext.get_current();
var user = context.get_web().get_currentUser();
var web;
var spHostUrl;
var parentcontext;
spHostUrl = decodeURIComponent(getQueryStringParameter('SPHostUrl'));
parentcontext = new SP.AppContextSite(context, spHostUrl);
web = parentcontext.get_web();
// This code runs when the DOM is ready and creates a context object which is needed to use the SharePoint object model
$(document).ready(function () {
getUserName();
getitems();
// This function prepares, loads, and then executes a SharePoint query to get the current users information
function getUserName() {
context.load(user);
context.executeQueryAsync(onGetUserNameSuccess, onGetUserNameFail);
function getitems()
var list = web.get_lists().getByTitle("ListsTask");
var camlQuery = new SP.CamlQuery();
camlQuery.set_viewXml("");
this.listItems = list.getItems(camlQuery);
context.load(listItems);
context.executeQueryAsync(onQuerySucceeded1, onQueryFailed1);
// This function is executed if the above call is successful
// It replaces the contents of the 'message' element with the user name
function onGetUserNameSuccess() {
$('#message').text('Hello ' + user.get_title());
// This function is executed if the above call fails
function onGetUserNameFail(sender, args) {
alert('Failed to get user name. Error:' + args.get_message());
function getQueryStringParameter(urlParameterKey) {
var params = document.URL.split('?')[1].split('&');
var strParams = '';
for (var i = 0; i < params.length; i = i + 1) {
var singleParam = params[i].split('=');
if (singleParam[0] == urlParameterKey)
return decodeURIComponent(singleParam[1]);
function onQuerySucceeded1() {
$("#results").empty();
var listInfo = '';
var listEnumerator = listItems.getEnumerator();
listInfo += "<table><tr><th>Id</th><th>Title</th></tr>";
while (listEnumerator.moveNext()) {
var listItem = listEnumerator.get_current();
listInfo += '<tr><td>' + listItem.get_item('ID') + '</td>'
+ '<td>' + listItem.get_item('Title') + '</td>'
+ '</tr>\n';
listInfo += '</table>';
$("#results").html(listInfo);
function onQueryFailed1(sender, args) {
$("#results").empty();
$("#results").text('Request failed. ' + args.get_message() +
'\n' + args.get_stackTrace());
But still not able to get list items, i m finding soultion.
Thanks
varinder -
"Unknown list item type 'list'" error
Hi Friends,
I am facing a problem while creating a listbox (in inDesign JScript). I have written the following syntax to create the same:
var myDialog1 = app.dialogs.add({name:"Simple Dialog"});
var styleList = new Array("Part Num","Part Title","Chap Num","Chap Title","Chap TOC");
var submenuItems = new Array("Style Formatting","Indents and Spacing","Paragraph Rules","Keep Options","Hyphenations","Nested Styles","Bullets and Numbering");
with(myDialog1){
with(dialogColumns.add()){
with(dialogRows.add()){
with(borderPanels.add()){
with(dialogColumns.add()){
var styles = dropdowns.add({stringList:styleList,selectedIndex:0,minWidth:133});
with(dialogColumns.add()){
var submenu = ListBox.add("list",submenuItems);
myDialog1.show();
But it is showing the following error message:
"Unknown list item type 'list'"
I want to know that what I should write in the parameter list. Please help me in this regard.
Thanks a lot in advanceHi Adithi,
dialogColumns don't know a child called 'ListBox'.
You can use 'dropdowns' instead as you did in 'var styles = dropdowns.add({stringList:styleList,selectedIndex:0,minWidth:133});':
var submenu = dropdowns.add({stringList:submenuItems, selectedIndex:0});
Martin
Maybe you are looking for
-
Hi, I added a info object to a dimension in a cube. now i want to delete the info object from the cube. But since the cube has data in it, i cannot do it unless i delete all the data from the cube. When i select 'delete data', i'm given 2 options, de
-
Sales order going to dump when we enter product in the transcation
Hello Gurus, I am facing a problem in the sales order, when i enter a product in the transcation(TA) it going to dump........It is showing the message like this........., What happened?...... Error in the ABAP Application Program The current
-
Sql Server 2014 - Error message: Failed to read BLOB column
Hi all, Am experiencing this error in Microsoft SQL Server 2014 - 12.0.2000.8 (X64) Enterprise Edition (Build 7601: Service Pack 1). Error messages: Message: Failed to read BLOB column Stack: at Microsoft.SqlServer.Replication.Snapshot.SqlServer
-
Hi We are using Oracle Express Web Agent. In Java graph if we move the cursor on the grapgh it displays the exact measure value for that dimension value where the cursor is left. Is it possible to show all the values by default on the graph with out
-
IOS Publishing ERROR ITMS-9000
I'm really stressed out now with my error on publishing. I'm encountering these error. I've searched about this and tried all the possible solutions such as: Checking all the Provisioning Profiles. (Even deleting and creating new Distribution Profile