Tag Info

Hot answers tagged

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

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(); ...


6

AFAIK, it's only possible to use getByName in SharePoint 2013, not in 2010. See MSDN reference for more information var groupCollection = clientContext.get_web().get_siteGroups(); visitorsGroup = groupCollection.getByName("SomaGroupName");


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

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

Everywhere in this answer replace sp2010 with your site url, Table with your list name, PortalHomeDataContext with your site name (without spaces) + DataContext and RestTest.ServiceReference1 with your generated namespace. This is tested against a SharePoint 2010 site: http://sp2010/_vti_bin/listdata.svc/Table?$filter=(Color eq 'Red') and (Active eq false) ...


4

One oddity about the JSOM is that you need to wrap the CAML query in a <View> tag. var proproductIDVal = "TR543A1Z"; var queryXml = "<View><Query><Where><Eq><FieldRef Name = 'ProjectID'/><Value Type='Text'>" + productIDVal + "</Value></Eq></Where></Query></View>"; var query = new ...


4

I have used SharePoint’s JavaScript Object Model to retrieve the current logged in username.Once you have executed the load and executeQueryAsync methods and the call to SharePoint was sucessful, then inside of the onQuerySucceeded method is where I display the username to the browser using the SP.Principal.get_loginName property. Try it out…you can host ...


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

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 ...


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

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


3

You added the <RowLimit>500</RowLimit> yourself in the ViewXml Property - so only 500 items will be returned. AFAIK there is no limit, but you could run into a timeout or memory limit on your client. I would recommend you the free CAMLDesigner (http://sharepoint.biwug.be/SitePages/Caml_Designer.aspx) - there you can create your caml and check ...


3

Just wrap your code inside the uploadMyFile function into ExecuteOrDelayUntilScriptLoaded, as shown below: <script type="text/javascript"> $(document).ready(function() { $("#some-a-element").click(function uploadMyFile(directory)) { ExecuteOrDelayUntilScriptLoaded(function() { // something ...


3

Good way to remove handlers from dialog's close button is using $clearHandlers Method. Check code below: function fValidateBeforeClose(event) { var isValid = true; //set IsValid value if(isValid) { //close dialog SP.UI.ModalDialog.get_childDialog().close(); } else { alert('Not valid'); } } function ...


3

To view who has opened documents, you can run a Audit Log report. This is can achieved using the Audit Log reports You go to the following setting: Site Actions > Site Settings > Site Collection Administration > Audit Log reports. Check Configure audit settings for a site collection


3

There is no built in way via the SharePoint JavaScript Object Model according to my research. Likely you will have to build your JavaScript to work with the SharePoint 2010 Alerts Web Service: http://msdn.microsoft.com/en-us/library/websvcalerts(v=office.14).aspx using JQuery or whatever framework calls from JavaScript on your page.


3

I found a working example at http://spdevlab.com/2013/03/28/creating-wiki-web-part-and-publishing-pages-via-csom-in-sharepoint-2010/. This example worked on the first try without issue.


3

I'm not exactly sure what which aspect is confusing your so I will break down the process into some steps. Let's imagine we have a custom list titled Issue Tracker with the following definition: Fields: Id (number) the default field Title (text) the default field Problem Description (text) Products (multiselect ...


3

First of all - you have aמ unnecessary closing tag </Eq> at the end. Also, you can not put more than 2 conditions in the AND or OR, In addition, You have to convert your DateTime object to a ISO8601 format. So your CAML should look like this: <Where> <And> <Eq> <FieldRef Name='Team' /> <Value ...


3

If you are updating a list item more than once in succession, after the first update the list item (oListItem in your case) object will have become stale, and the server will reject the update. SharePoint uses a hidden field called owshiddenversion, which gets downloaded along with your CSOM object, to determine which version you are editing. When you send ...


3

In order to set a lookup field using CSOM, the ID of the item from the lookup list should be specified. This ID can then be used to set the listitem's FieldLookupValue. FieldLookupValue lv = new FieldLookupValue(); lv.LookupId = 1; item["Project"] = lv; item.Update(); clientContext.ExecuteQuery(); Below is provided the complete example for specifying ...


3

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. ...


3

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() { ...


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

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 clientcontext = new ...



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