Tag Info

Hot answers tagged

9

How to check if current user belongs to SharePoint group via CSOM (JavaScript): function IsCurrentUserMemberOfGroup(groupName, OnComplete) { var currentContext = new SP.ClientContext.get_current(); var currentWeb = currentContext.get_web(); var currentUser = currentContext.get_web().get_currentUser(); ...


8

You cannot make cross-sitecollection calls from javascript client object model in SharePoint 2010. But you can make such calls in SharePoint 2013: var crossSiteContext = new SP.ClientContext("http://url-of-another-siteCollection/"); var crossSiteWeb = crossSiteContext.get_web(); crossSiteContext.load(crossSiteWeb); ...


7

Check out this blog post by Andrew Connell where he talks about using Breeze with SharePoint. With Breeze your code will look something more like: var promise = breeze.EntityQuery .from(contactType.defaultResourceName) .using(entityManager) .execute() .where('Id', 'eq', 1) .then(function (data) { return data.entity; }); // update the first ...


6

I don't think it is possible. I hope someone can prove the opposite. What you can do is to map the results into your own objects in the client. I had a similar issue, when I wanted to use $filter query strings in the REST calls to the listdata.svc in SharePoint 2010. The problem is that the Display Names are used for the columns and are different for ...


6

It actually depends on which version of SharePoint is used. SharePoint 2013 In SharePoint 2013 CSOM ListItem.Folder property gets a folder object that is associated with a folder item. SharePoint 2010 In SharePoint 2010 CSOM Folder property is not exposed for ListItem object. The following method could be used for retrieving Folder associated with ...


5

UPDATE: Shankar's comment is correct, my post does not really answer the original question. I must have misread it at the time. I leave my post for completeness but the other answers are the correct ones. The Client Object Model (CSOM) equivalent to the SPContext is the ClientContext. However since CSOM is a remote API there is no current context (unless ...


5

How to activate feature via Managed Client Object Model: public void ActivateFeature(string webFullUrl,Guid featureId,bool force,FeatureDefinitionScope featdefScope) { using (var ctx = new ClientContext(webFullUrl)) { var features = ctx.Web.Features; ctx.Load(features); ctx.ExecuteQuery(); features.Add(featureId, force, ...


5

Place the second code section in a function and call it from the success function of the first passing the userid as a parameter.


5

Since SP.SOD.executeFunc supports on demand scripts, but SP.SOD.executeOrDelayUntilScriptLoaded does not, I would recommend to use SP.SOD.executeFunc with CSOM: SP.SOD.executeFunc('sp.js', 'SP.ClientContext', function() { var clientContext = SP.ClientContext.get_current(); console.log(clientContext.get_url()); });


4

The limit is due to server-driven paging. It protects against developers inadvertently making a request that returns large result sets. You can use $top if you really want a large result set to be returned. Otherwise you can get the results a page at a time by checking __next. If it has a value, it contains the url that will return the next set of items. ...


4

SharePoint 2013 CSR OnPreRender handler could used for initialization of ClientContext since OnPreRender is called before the actual View/Fields rendering Example: (function () { function OnPreRenderDocItemTemplate(renderCtx) { SP.SOD.executeOrDelayUntilScriptLoaded(loadContext, 'sp.js'); function loadContext() { ...


4

All calls to SharePoint in the JavaScript Object Model are Asynchronous. This means that you have to make use of callback functions to get values back successfully. In your code, you have used the userQuerySucceeded callback function to fire when your query succeeds. Now to read the login name, you will have to do it inside the callback function. Try this ...


4

If you want to know if a list item has unique permissions the you would use the HasUniqueRoleAssignments property. This property available in the Managed Client Object Model but it is not in the Javascript Client Object Model. Update: Anders comment was correct, the HasUniqueRoleAssignments property is available in the Javascript Client Object Model (see ...


4

No, audiences are not supported in the SharePoint client object model. Its only supported in the Server Object Model. In the past I created a Web Service in SharePoint that could take a user name and return the audiences for that user, leveraging the Server Object Model...but that approach probably doesn't work in your scenario.


4

We can do it using Client Object model, to do it, we need the xml file of the webpart you need to add. You can get it by the following method, Step 1: Goto Site settings-> Web part Gallery. Step 2: Then choose the needed web part, click edit -> click view XML -> copy the XML, then put it in the below code. ClientContext clientconteext = newy ...


4

You can find a great article that explains the cross-domain / cross-site collection issues and how to resolve them on the MSDN: Solving cross-domain problems in Apps In the link above the following explanation can be found: Cross-site collection calls A different problem that is often lumped into the same cross-domain category is issuing calls to ...


4

There is another method in which you can upload extend the limit of the documents or files attached. Following is the code i used: Suppose I have a folder called attachments with several files, Following are the parameters used: destWeb-Destination SharePoint Web destSite-Destination SharePoint Site destList-Destination SharePoint List itemDest-List Item ...


4

To check-out: //get the connection ClientContext ctx = new ClientContext("http://sitename"); //get the home page File home = ctx.Web.GetFileByServerRelativeUrl("/SitePages/home.aspx"); //checkout in case it's needed; doesn't hurt if it doesn't home.CheckOut(); To check-in: //checkin in case it's needed; doesn't hurt if it doesn't ...


4

You can use this method: function ActivateFeature(featureGuid) { var clientContext = new SP.ClientContext.get_current(); var site = clientContext.get_site(); var guid = new SP.Guid('{'+featureGuid+'}'); var featDef = site.get_features().add(guid, false, SP.FeatureDefinitionScope.site); clientContext.executeQueryAsync(Function.createDelegate(this, ...


4

AFAIK, using the existing services; it is not possible to access the content database informations from Client Object model or services. As a work around you can create your own WCF service and deploy it in SharePoint, which can provide your required data. How to Customize WCF Services in SharePoint 2010 SharePoint 2010: Create Custom WCF Service


4

ExecuteOrDelayUntilScriptLoaded is a method used to delay a function call unless a particular script is loaded. Yes, you can use it in application page. If you are using CSOM you need to add a reference to sp.js file. You can also use SP.SOD.executeFunc if you are using on demand scripts. A very good article on this is here


4

When developing JavaScript apps against the SharePoint 2013 REST and CSOM APIs it is recommended to leverage Promises Patterns since it allows separate out the various asynchronous calls while still maintaining the dependency between them. There are several techniques for implementing promises, but one of the easiest is to make use of the jQuery $.Deferred ...


4

You need to use the overload for SPField.Update that takes a boolean parameter. That will push the changes to lists that use the field.. I.e., in Powershell: $myField.Update($true) MSDN documentation here.


3

If you are working on SharePoint Online (2013), then they have introduced a new variable to hold the current user's login name in the _spPageContextInfo global object. _spPageContextInfo.userLoginName; This will get you the login name without making any AJAX calls with the JSOM or REST.


3

You can`t. The Client Object Model (CSOM) does not provide access above the Site Collection level. As far as I know, the only way to do what you want is to create a custom web service that gets the Web Application information using the Server Object Model and have the remote application use it instead of the CSOM.


3

Your filters should be: var refinementFilters = new string[] { "doc, docx" }; for (var i = 0; i < refinementFilters.Length; i++) { keywordQuery.RefinementFilters.Add("FileType:" + refinementFilters[i]); } where you add the property you want to filter on as part of the filter, not just the value. A good exercise is to use fiddler or similar when you ...


3

why are you using ajax post event? that is like a click event to post to the server yet your checking for somthing on the client side! how about you wait on the dom to finish, you could have a loading event like a gif that loops that shows.... once the dom is complete you could fade out that image! $(window).load(function() { ...


3

you can use this code to retrive the items from MSDN: // Starting with ClientContext, the constructor requires a URL to the // server running SharePoint. ClientContext context = new ClientContext("http:SiteUrl"); // Assume the web has a list named "Announcements". List announcementsList = context.Web.Lists.GetByTitle("Announcements"); // This creates ...


3

you can do CRUD operations using SPServices e.g - Create Items function CreateNewItem() { $().SPServices({ operation: "UpdateListItems", async: false, batchCmd: "New", listName: "Objectives", valuepairs: [["Title", "YourTitle"], ["Message=", "Message Text"]], completefunc: function(xData, Status) { alert("done"); } });} ...


3

The code that you've provided, works in my case. Probably the reason why it returns NULL is because property name that is passed does not exist.. The following code sample demonstrates how to retrieve custom field property value: function loadFieldsProperties(listTitle) { var clientContext = new SP.ClientContext(); var targetList = ...



Only top voted, non community-wiki answers of a minimum length are eligible