Tag Info

New answers tagged

-2

You can get the site url like this: var siteUrl = "<%= SPContext.Current.Web.Url %>";


0

Due to async nature of JSOM I would recommend this approach. The example demonstrates how to create multiple list items using JSOM: //Create multiple contact items using Named Function Expressions (http://stackoverflow.com/a/7065175/1375553) var createContactItems = function createContactItem(i,itemsCount) { ...


0

In addition set HTML_x0020_File_x0020_Type property to SharePoint.DocumentSet while creating a Document Set. The following example demonstrates how to create Document Set using SharePoint 2010 CSOM: public static void CreateDocumentSet(ClientContext ctx,string listTitle, string docSetName) { var list = ctx.Web.Lists.GetByTitle(listTitle); ...


0

You do not need to perform ExecuteQuery() on every iteration of your loop, each server request can have a 2MB loadsize (depending on your setup). you can add something like this to your loop. int counter = 0; foreach(var item in ListItem) { //do stuff counter++; item.Update(); if((counter%50) = 0) { context.ExecuteQuery(); ...


0

By default, the managed client object models authenticate users by using their Windows credentials (DefaultCredentials). So you don't need to explicitly set the Credentials. You do not have permission to perform this action or access this resource. This error happens when the current logged in user don't have permission to the resources. In your case ...


0

This error occurs since in SharePoint 2010 CSOM (V14) Where and GroupBy operators are not supported. Solution Replace the line: IQueryable<IGrouping<object, ListItem>> groupItems = contactItemsCollection.Where(i => i.FieldValues["Full_x0020_Name"] != null).GroupBy(item => item.FieldValues["Full_x0020_Name"]); with this one: ...


4

Example 1 Explicitly specify choice value: using (var ctx = new ClientContext(webUri)) { var list = ctx.Web.Lists.GetByTitle("Tasks"); var taskItem = list.GetItemById(itemId); taskItem["Status"] = "In Progress"; taskItem.Update(); ctx.ExecuteQuery(); } Example 2 Choose a value from field choice: using (var ctx = new ...


4

You Can set it by updating the Item with the choice value, as below newListItem["ChoiceFieldName"] = "ChoiceValue"; newListItem.Update(); clientContext.Load(newListItem); clientContext.ExecuteQuery(); But if you are assigning a Value which is not in the Choice Column, You need to create a choice value then assign it to the item.


1

SP Foundation does not include the User Profile Service, as @Aveenav noted. Therefore you probably do not have access to the REST endpoints for that service. Instead you will have to use the user information list to get this information. This will require two requets: one to get the current user's id, the second to get the user's info that you want. ...


0

1) Get all properties of current user: http://siteurl/_api/SP.UserProfiles.PeopleManager/GetMyProperties 2) Get single property of current user: http://siteurl/_api/SP.UserProfiles.PeopleManager/GetMyProperties/PictureUrl OR http://siteurl/_api/SP.UserProfiles.PeopleManager/GetMyProperties?$select=PictureUrl 3) Get Multiple Properties for the ...


0

For REST api, you could use 'GetMyProperties'. Use '$select' to retrieve only specific properties. the ajax method should be 'GET'. Here's a working example: $.ajax({ url: _spPageContextInfo.webServerRelativeUrl + "_api/SP.UserProfiles.PeopleManager/GetMyProperties?$select=DisplayName, PictureUrl", method: "GET", headers: { ...


0

You initialized the variable as itemID var itemID = $("#ctl00_m_g_32d59762_da31_442a_8334_da53c330611c_FormControl0_V1_I1_S7_I1_H1").text(); But called it with itemId this.varitem = list.getItemById(itemId); It's easy to overlook! But Javascript is case-sensitive, so you'll need this.varitem = list.getItemById(itemID); As discussed in the comments ...


1

You've got a plenty of answer how to check permissions. If you want to check the group membership (it is of course not the same as permissions), then you have to check which groups the current user is member of and decide where to redirect. Alternative 1 I have written a little example how to achieve this using jsom. Suppose you have a group called ...


3

In this approach it is determined whether User belongs to specific Group and if so, then he/she is getting redirected to another page: function isUserMemberOfGroup(userId, groupId, success,error) { var ctx = SP.ClientContext.get_current(); var allGroups = ctx.get_web().get_siteGroups(); var group = allGroups.getById(groupId); ...


3

I'm assuming you're on a standard SharePoint page -- if so, you can use the _spPageContextInfo object's userId and userLoginName properties. They come along for the ride when the page is rendered. From my browser dev tools: >_spPageContextInfo.userId 1337 >_spPageContextInfo.userLoginName "somebody@somecompany.onmicrosoft.com" If you're dealing ...


0

Found a way to implement the scenario. 1st popup code (from where the second popup opens) ~ HTML in Page 1 : <input id="sampleButtonParent" type="button" value="Open Modal Popup" onclick="OpenModalPopup('http://sampleurl.com/')" /> JS in Page 1: function OpenModalPopup(_url) { var options = { url: _url, title: "Modal Popup", ...


0

What you should do is on CallBack refresh the dialog elements. For example: on parent dialog load you might be executing ready function. Call that function once the child dialog closes function closewindow() { //Child Closed RefreshParentElements(); }


1

The DisplayName property is A string that contains the item display name, which for a document library item equals what the user types in the Name box of the item form. The default value equals the original name of the uploaded file minus the file type extension. as stated here. If you would like to order the items in a document library you can ...


4

I normally follow as below SP.SOD.executeFunc('sp.js', 'SP.ClientContext', readyFunction); function readyFunction() { getCurrUser(); evalGroups(); getDeptMgrs(); getItemOwner(); } Its more readable!


0

According to UserVoice driving improvements to SharePoint API Microsoft released SharePoint 2013 and SharePoint Online solution packs that contains the following change to the existing API: Web object exposes AlternateCssUrl property via CSOM (.Net, REST, JS) Alternatively you could install the latest versions of SharePoint Server 2013 Client ...


1

Option 1 Use Web.Webs property to get a web sites immediately beneath the Web site: using (var ctx = new ClientContext(webUri)) { var subWebs = ctx.Web.Webs; ctx.Load(subWebs); ctx.ExecuteQuery(); } Option 2 The following example demonstrates how to retrieve all web sites: public static void LoadAllWebs(Web web,List<Web> allWebs) { ...


2

function RetriveSites() { currentcontext = new SP.ClientContext(‘/collaboration/KeyWordsDemo’); /* to get the current context use this instead -à.get_current();*/ /*more info http://msdn.microsoft.com/en-us/library/ee658863.aspx*/ currentweb = currentcontext.get_web(); ...


1

Follow these links having good examples: http://khakicampbelldeveloper.wordpress.com/2012/06/28/sharepoint-2010-client-object-model-populate-drop-down-lists-and-save-list-items/ https://social.msdn.microsoft.com/Forums/sharepoint/en-US/5e96d47f-e3b9-4502-bb66-6feb728bcabf/populate-list-fields-in-dropdown?forum=sharepointdevelopmentprevious small example ...


1

I'm not sure what you mean with freeze, but I can't see where you call or close the "working on it". I made simple example with dummy code, maybe it will help you. Because I have never seen that async calls have locked the UI etc, so you could try this approach: SP.UI.ModalDialog.showWaitScreenWithNoClose("title", "message", 400, 400); var ...


0

Since you error message says Remote server. I am assuming this is SharePoint online. If that is the case then you need to pass the Credentials to the clientcontext as below using (ClientContext clientContext = new ClientContext(url)) { SecureString passWord = new SecureString(); foreach (char c in "yourpassword".ToCharArray()) ...


0

This article explains every scenario for the datetime picker control. I've used it without issue. http://theway4ward.wordpress.com/2013/07/30/211/


1

We have used Spin.js in several such scenarios. Usage Define a <div> in the HTML markup <div id="userTableSpinner"></div> Then in Javascript code find the div and start spinner and finally stop it once all processing is done: var userTableSpinner; function someProcessStartsHere() { if (userTableSpinner == null) { userTableSpinner ...


0

I think this should work RegisterModuleInit('/<yourSiteName>/SiteAssets/<yourJSfilename>.js', updateTitle); updateTitle(); function updateTitle() { var priorityFiledContext = {}; priorityFiledContext.Templates = {}; priorityFiledContext.Templates.Fields = { "Title": { "View": priorityFiledTemplate } ...


0

This happens only when you refresh the opened page more than once. Try opening the record again newly and you will not see this issue.



Top 50 recent answers are included