Tag Info

New answers tagged

0

The below code gives the results of the field into a variable called myfield. <script type="text/javascript"> SP.SOD.executeFunc('sp.js','SP.ClientContext',update); var returnedItems; function update(){ var context=new SP.ClientContext(); var list=context.get_web().get_lists().getByTitle('Documents'); var caml = new SP.CamlQuery(); ...


0

I faced similar issue in Windows server 2008 R2 whereas my application worked fine in other machines. I was using the below method, NetworkCredential (String userName, String password) to create credential object for the ClientContext. I simply used another overloaded constructor of NetworkCredential Class which is, NetworkCredential(String userName, ...


0

I had a similar requirement in SharePoint Online and I have finished the Quest and you can refer it over Create content organizer rule in SharePoint Online using CSOM code. I believe you are required to use similar approach except instead of connecting to a SharePoint Online tenant site you need to get connected to the one on premise. What's the trick: If ...


0

By default, all fields all loaded if we don't specify any fields in ctx.load()So try using Ctx.load(item) and then retrieve whichever field you want by item.Id or item["Title"]


1

The Features property only returns Features that have been activated. Web.Features property


0

You can try this few lines of code. // Update the Metadata for the uploaded file in to the Document Set Microsoft.SharePoint.Client.File oFile = oRootWeb.GetFileByServerRelativeUrl("Server relative url of the file"); oFile.ListItemAllFields["Migrated"] = true; oFile.ListItemAllFields["Author"] = sSystemAccount; oFile.ListItemAllFields["Editor"] = ...


3

You can check the Template type of a web object. If it is APP#0 you don't need to add it to List. The example here shows how to get the web template. http://stackoverflow.com/questions/19382310/using-client-object-model-how-to-fetch-the-web-template-name-and-web-templat


-1

/_api/web/lists/GetByTitle('ListName')/items?$top=1000


1

Your OnSuccess must iterate the results: function onSuccess(sender, args) { var listItemEnumerator = items.getEnumerator(); while (listItemEnumerator.moveNext()) { var oListItem = listItemEnumerator.get_current(); alert('ID: ' + oListItem.get_id()); } } Also, move the OnSuccess and OnFail inside of your main function ...


1

Finally i found my answer after lots of research. It was the problem related to Authorization, the SharePoint server which i wanted to refer, had a Form based Authentication. So i updated my code according to that and it worked fine. Please find my below updated code using (ClientContext spcontext = new ClientContext("siteURL")) { ...


0

I tried some ways for same purpose. but did not get good results. However by using "xcopy" as DOS-prompt command , I've got Copy of Original Library. (see below. you must create "new_library" before this command) xcopy \\serverurl\original_library \\serverurl\new_libray /e note: "original_library" is not Library Template but normal Document Library.


0

For this you can use any of the two: var url = window.location.protocol + "//" + window.location.host + _spPageContextInfo.siteServerRelativeUrl; Or we can use var context = new SP.ClientContext(); var relativeWebUrl = context.get_url(); var fullWebUrl = window.location.protocol + '//' + window.location.host + relativeWebUrl ;


0

You can use this for Single select Managed metadata fields and Multislelect Managed metadata fields: while (listItemEnumerator.moveNext()) { var oListItem = listItemEnumerator.get_current(); ID_=oListItem.get_item('ID'); Name_=oListItem.get_item('Name'); MMD1_=oListItem.get_item('Nation').get_label();//single value MM field ...


0

According to your requirement, you can not get the id from the ClientPeoplePicker Control, the walk around is quite simple, with the key data mentioned by @Akshay Randive, you can call the next function: function GetUserId(userName) { //userName format = i:0#.w|bidev\sp_admin var siteUrl = _spPageContextInfo.siteAbsoluteUrl; var call = $.ajax({ ...


0

$(document).ready(function () { // Specify the unique ID of the DOM element where the // picker will render. initializePeoplePicker('peoplePickerDiv'); }); // Render and initialize the client-side People Picker. function initializePeoplePicker(peoplePickerElementId) { // Create a schema to store picker properties, and set the properties. ...


0

(function () { // Intialize the variables for overrides objects (window.jQuery || document.write('<script src="//ajax.aspnetcdn.com/ajax/jquery/jquery-1.10.0.min.js"><\/script>')); var overrideCtx = {}; overrideCtx.Templates = {}; overrideCtx.Templates.Fields = { 'Color': { 'NewForm': ...


1

You can easily create a list item with managed meta data field as : function createaListItem() { var clientContext = new SP.ClientContext.get_current(); var oList = clientContext.get_web().get_lists().getByTitle('Listname'); var itemCreateInfo = new SP.ListItemCreationInformation(); this.oListItem = oList.addItem(itemCreateInfo); ...


0

this is how i solved it. It may be useful to someone in the future. function ConverTimeZoneOnEventsList(){ var url = window.location.href; debugger; if (url.indexOf('Lists/Events/DispForm.aspx') >= 0) { var dateElements = document.getElementsByName('SPFieldDateTime'); for (var i = 0; i < dateElements.length; i++) { var temp = ...


0

Maybe you can simply take a look to the getPeerUrl() method in the SP.Publishing.Variations namespace: https://msdn.microsoft.com/en-us/library/office/jj954403.aspx Try this jQuery.getScript("_layouts/15/sp.publishing.js",null) var clientContext = SP.ClientContext.get_current(); var peerUrl = SP.Publishing.Variations.getPeerUrl(clientContext, ...


3

I have corrected your code and here you go $(document).ready(function() { ExecuteOrDelayUntilScriptLoaded(GetDesc, "sp.js"); }); function GetDesc() { context = new SP.ClientContext.get_current(); web = context.get_web(); siteURL=$(location).attr('href'); var titleName=document.title; var mListName= "TestList"; ...


1

Updating a list item in JSOM should be as simple as this: function updateListItem(itemId) { var clientContext = new SP.ClientContext(siteUrl); var oList = clientContext.get_web().get_lists().getByTitle('My List'); this.oListItem = oList.getItemById(itemId); oListItem.set_item('MyField', 'My Updated Field Value'); oListItem.update(); ...


0

NO need of "context.load(mList);" simply loading the ListItemCollection will bring the item collection. During itration process is going on you cannot make any changes into the item. Hence updation action should be seperated from itration process calling loop.


1

I have used below JavaScript function to get login name of current logged in user. While working on this code, it was noticed that get_loginName() function brought i:0#.w|DomainName\asad. So I have used string manipulation to get the desired one i.e. DomainName\asad function getCurrentUser() { try { var clientContext = new ...



Top 50 recent answers are included