Tag Info

New answers tagged

0

Found the solution. All it took was replacing this bit of code: var h3 = '<h3>' + oListItem.get_item('Title') + '</h3>'; var div = '<div>' + oListItem.get_item('Floor') + '</div>'; var content = $(h3 + div); content.appendTo("#accordion").show(); with this bit of code var newDiv = "<h3> " ...


0

Quick fix Reference entry object by this keyword: this.entry = webList.addItem(entryCreationInformation); to make it accessible in handler, then you could grab list item id: function success() { console.log(entry.get_id()); }


0

You need to give entry the proper scope to be valid inside the success handler. The quick and dirty way to do this would be to make it a global variable. Then you can access it in the handler: function success() { var id = entry.get_item("ID"); }


0

What i understand from your question is you want to display recently added item in the same page. One simple way of doing this is:- Create a view, sort the view by Created and have Item Limit in the view to 5( or however number of recent records you want to see. Add a List View web part on your page, make sure you select the view you have ...


7

Add "?contents=1" to the url of the page. There you can delete not working webparts and also closed webparts from the page. For example: http://mywebsite/default.aspx?contents=1


0

I didn't understood your question fully, but check out this article as this has one option to update a calculated column automatically. http://www.moustafarefaat.com/MoustafaPWS/Default.aspx?pg=a7c6f024-82ee-46e6-aa8d-fc80383ec723&detail=19ba94b9-d1a4-42a8-8ae8-46ab17c93f14 You may need to modify this as per your requirement. Also, can you put some ...


0

If the format does not vary from what you presented, you could use split, and access the desired elements in array notation. itemDate = itemDate.split(" "); itemDate = itemDate[1] + " " + itemDate[2]; You lose any date properties by doing this, so if the other elements of the date object are important you're probably better off with moment.js.


1

When you need to work with dates in javascript, I strongly recommend using the excellent moment.js library. It makes formatting dates a snap. var d = moment("Thu Jul 25 09:30:07 PDT 2013"); d.format("DD MMM"); // "25 Jul"


4

I would suggest that you consider using moment.js for working with dates. Nk SP's solution will, of course, work fine for your current question, but moment gives you a lot of flexibility for working with dates and formatting them. Here is an example (note jQuery is not a requirement): $(document).ready(function(){ var d = new Date("Thu Jul 25 09:30:07 PDT ...


2

You can do: var d=new Date("Thu Jul 25 09:30:07 PDT 2013"); var monthNames = [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ]; var yourNiceDate= d.getDate()+" "+monthNames[d.getMonth()];


0

This example will reverse the order, works for me: var c = SP.ClientContext.get_current(); var folder = c.get_web().get_lists().getByTitle(<list title>).get_rootFolder(); c.load(folder, 'ContentTypeOrder'); c.executeQueryAsync(function() { folder.set_uniqueContentTypeOrder(folder.get_contentTypeOrder().reverse()); folder.update(); ...


1

Since $expand operator specifies which projected fields from a joined list are returned, the REST query: /_api/web/lists/GetByTitle('<List Title>')/items(<Item Id>)/?$expand=ContentType returns list item entity with content type entity. In order to return the specific item properties along with Content Type properties, you should use ...


2

What we did was to use this marvelous trick by @user1337886 and @damjan-tomic: Reindex Pages Library using powershell. Might be originating from something like http://blog.icsharp.net/2013/04/how-to-force-web-list-or-library-to-recrawl.html . Just instead of using PowerShell or C# we did it using JSOM, which makes it a tiny bit different, and we triggered ...


0

Since Web properties (Web.AllProperties) could be requested using a single query using the following syntax: clientContext.load(webs,'Include(Url,AllProperties)'); you don't need to perform any subsequent asynchronous requests using executeQueryAsync method to load web properties per every web. The following example demonstrates how to load web ...


1

Now that you have explained your issue better and I see your question actually has nothing to do with getting the title and URL, I can make a suggestion. Load the web properties in a batch. Then use a single execute query after the while. Anonymous functions embedded just to keep lines of code down. var ctx = SP.ClientContext.get_current(); var ...


1

In order to get value from Web.AllProperties property (PropertyValues type) you could use the following ways: FieldValues property Item property Example: get Web AllProperties var context = new SP.ClientContext.get_current(); var web = context.get_web(); var props = web.get_allProperties(); context.load(props); ...


0

Try to load web object also after getting it, context.load(web); Moreover, try to get title and url using myPropBag.get_item("propertyname"). Similarly, use myPropBag.set_item("propertyname") to set properties.


1

This happens because of the asynchronous behaviour of client object model. If you want to wait till the code in executequeryasync completes then you can use Jquery deferreds. Here is a nice article explaining how to use deferreds http://scenicsharepoint.blogspot.in/2012/12/using-jquery-deferred-object-with.html?m=1


2

You only have a reference to the list item, but the actual list item is not fetched to you from the server until you do the executeQueryAsync. Not until then do you have any actual information to work with.


1

Natively CSOM only allows for asynchronous calls. If you want to overcome that, you can use a framework such as http://spservices.codeplex.com/


0

I think you would use SPServices GetListItems operation and specify the CAMLQuery option with a CAML query designed to only get the item(s) with your URL. Example: $().SPServices({ operation: "GetListItems", async: false, listName: "YOUR LIST NAME", CAMLQuery: "<Query><Where><Eq><FieldRef Name='FileRef' /><Value ...


0

Go to Site Settings > Site Content Types Create Site Content Type with Required Values In your doc lib, set this new content type as default content type Drag and Drop a file, it will keep the new file checked out to you and ask to provide required fields values in order to check in Thanks, Salman Haleem


2

I just did a simple test, and this code works just fine: var context = SP.ClientContext.get_current(); var item = context.get_web().get_lists() .getByTitle('Test') .addItem(new SP.ListItemCreationInformation()); item.set_item('MyField', ['Hello', 'World']); item.update(); context.executeQueryAsync(); And this is quite identical to your code, so that ...


0

var item; function insertItem() { var itemCreateInfo = new SP.ListItemCreationInformation(); newListItem = list.addItem(itemCreateInfo); var checked = $('input[name=' + field.internalName + 'group]:checked'); // loop through the choices and concat with ',' newListItem.set_item(field.internalName, 'Choice1, Choice 2'); newListItem.update(); ...


0

I'm not sure how much of a hack this is, but we got tired of the HostWebUrl; So we edited the SharePointContext.cs: On Home controller we save the SPHostUrl if provided. Where SharePointContext.cs tries to resolve the host url from HttpContext.Request.QueryString, if the QueryString does not contain the SPHostUrl we simply read it from the cookie. We ...


0

You should not use the file name in ExecuteOrDelayUntilScriptLoaded. but the function you want to trigger. Try this in your masterpage (2010) ExecuteOrDelayUntilScriptLoaded(function(){ var lcid = SP.Res.lcid; if(lcid == "1033") { alert('English'); /* Works only, if it in script editor and page is in edit mode */ } }, "sp.js")


1

Use the $filter query option with Author property to filter items by Modified field: $filter=AuthorId eq <UserId> How to retrieve current user via SharePoint REST API If the current user is not determined, then it could be requested using the following method: function getCurrentUser(url,complete, failure) { $.ajax({ url: url + ...


3

In order to set Url Field value in SharePoint REST specify the following JSON object: URL: {Url: 'http://www.microsoft.com',Description: 'MSFT'} where URL is the name of a field. Example var metadata = { Title: 'myTitle', URL: {Url: 'http://www.microsoft.com',Description: 'MSFT'}};


1

A document set is a folder, so your selection[item].fsObjType check will return the same value for folders and document sets. What you probably could do in your if (selection[item].fsObjType != 0) is to make a call to check the ContentType property of the item you have selected, if you use the OOTB Document Set content type you could simply confirm the ...


2

Prefer SP.SOD.executeFunc over SP.SOD.executeOrDelayUntilScriptLoaded Since SP.SOD.executeFunc supports load on demand scripts, there is no need to reference explicitly SP JavaScript files using SharePoint:ScriptLink The following example demonstrates how to initialize UserProfiles CSOM in application page: SP.SOD.executeFunc('SP.js', 'SP.ClientContext', ...


1

Use SP.SOD.executeFunc('sp.js','SP.ClientContext',runthiscode); instead of SP.SOD.executeOrDelayUntilScriptLoaded. because SP.SOD.executefunc makes sure the file is loaded and then executes the method and SP.SOD.executeOrDelayUntilScriptLoaded will only put the method on queue untill the file is loaded(so if file is not loaded then never executes). ...


2

The SP.Utilities.Utility.getLayoutsPageUrl is contained within the sp.js file. You have to make sure that sp.js has been loaded, before calling the function. SP.SOD.executeFunc('sp.js', 'SP.Utilities.Utility.getLayoutsPageUrl', getCurrentUrl); function getCurrentUrl(){ currentURL = SP.Utilities.Utility.getLayoutsPageUrl(""); }


0

For some of the permissions like Search , User Profile Service, Social Capabilities etc, you need to be tenant admin and not just site collection admin. For more details on this topic please check the following msdn articles App Permissions in SP 2013 Search apps in SP 2013 So basically, you need to login from tenant admin account and then "Trust" the ...


0

I have written a feature that when activated at the Site Collection Settings, will inject the jQuery library into the Masterpage using a delegate control. That way you can add the library on a site by site basis. Bismarck


1

No that is not possible, you need to understand what a context really is.. when you are running the JavaScript code, it resides within a page/app.. which is SharePoint based.. and thus has the context of what contains it.. The server side code SPContext.Current again has the context because it resides within SharePoint.. Or when you are using Client Object ...


0

I doubt your list title is My_x0020_Rooms SP.ListCollection.getByTitle(strListName) uses the list title. My guess is that you have replaced the space with _x0020_ like you do with InternalNames of fields. So try changing it to: var oList = clientContext.get_web().get_lists().getByTitle('My Rooms'); Edit: You have done the same with siteUrl, that ...


-1

You can load the jquery library within each web part. We experienced the same problem and this was the only solution that worked. The master does not load until after the web parts have loaded.


0

If anyone else needs to do this, here is the script I used. It's based on a couple of examples I found through googling, and I've added to it by finding the current item's ID and passing it to the URLs I'm generating. On my list, I created a single line of text column called "Actions" and then placed it in the view where I wanted my buttons to appear. This ...


2

REST (with jQuery.ajax): $.ajax({ url: "/_api/lists/getByTitle('Test')/getItemById(1)/AttachmentFiles/getByFileName('test.txt')", method: 'DELETE', headers: { 'X-RequestDigest': $('#__REQUESTDIGEST').val() } }); You can see the REST API endpoints at http://msdn.microsoft.com/en-us/library/office/jj860569(v=office.15).aspx . And you can see ...


0

Setting Title value The line: listItem.set_item("Title", Title.name); is used for setting Title column from Title.name object. Are you using something like this to initialize Title object? var Title = {}; Title.name = $('#title').val(); Ensure sp.js library is loaded In order to ensure that sp.js is loaded, change function your function to ...


1

I am afraid you are out of luck. there is no api to check if user belongs to a group in AD in sharepoint. But sharepoint does have a notion of Audiences Sadly, i dont think there is no REST api for audiences either. Via code here. From here The behavior is by design. SharePoint will not unwind AD groups for audience feature to work as this will cause ...


1

Andrew Connell is pretty keen on SharePoint 2013 SPAs. He has several blog posts about his experience with Breeze + Angular such as this one "Getting BreezeJS to Work with the SharePoint 2013 REST API". His PluralSight course on the subject will be published very soon along with a sample. There's a "Breeze.Angular.SharePoint" nuget package that loads your ...


1

In addition, for client javascript, _spPageContextInfo is your friend. http://blah.winsmarts.com/2013-2-_spPageContextInfo_is_your_new_best_friend.aspx


0

You can use a deferred with a resolve for your return value that is populated during async execution. After that you return a promise that you catch in a done method on function calling (check jQuery documentation: http://api.jquery.com/deferred.promise/): functionToCall().done(function (returnedValue) { // do something with the returned value }); ...


1

Using C# (server-side): SPSite siteCollection = SPContext.Current.Web.Site; var rootSiteCollection = siteCollection.WebApplication.Sites[0].Url; If you have alternate URLs, then use 'AlternateUrls' On the client side, you could use plain old javascript var winLoc = window.location; var siteUrl = winLoc.protocol + '//' + winLoc.host + (winLoc.port ? ':' ...


0

I found a solution and it's rather simple really... What I had to do: Create a custom view for my list Edit that view to show the Heading and Subheading (it was shown graphically before, but not as "data") Edit the view so it has a really large "limit results" number. I chose 10000 per page for now (otherwise the created xml file doesn't show all data ...


1

Here's a link that helped me out when I needed to find out what javascript function is bound to each ribbon button. Basically, the steps you have to follow are (applies to sp2010, the might be slight differences in sp2013): Find the id attribute of the ribbon button. eg. Ribbon.EditingTools.CPEditTab.Markup.Html.Menu.Html.EditSource-Menu16. Next go to 14 ...


1

All you need to to is to pass some query strings to the aspx page without any JS call. As like in wiki this goes like this. <a href="/demo/wiki/Seiten/home.aspx?ControlMode=Edit&DisplayMode=Design">Edit this page</a> This works for every page and not only for wiki page. The valid control mode values can be found on the MSDN as the values for ...


1

The issue is that your POSTing another attachment before SharePoint is done processing the item with larger files. So when you try to perform another operation on the item (adding another attachment, etc) a race condition is is reached and SharePoint throws the error. When the attachment files are smaller, the process has time to complete before you start ...


1

A cleaner way would be to create a new View with all necessary filters and use it on the pages(as Webpart) and apply JSLink to the web part properties. JSLink: You could always add a conditional check within the JS but that might offset the paging and result in empty cells. For ex. customItemHtml: function (ctx) { var _taskStatus = ...



Top 50 recent answers are included