Tag Info

New answers tagged

0

In this situation I usually disable click event on default form save buttons (as long as it is sharepoint default form) and call my async functions instead. When the job is done, I call save function myself. It works well. Example: var originalSaveButtonClickHandler = function(){}; $(document).ready( function () { var saveButton = ...


1

Just realised the list was not saving the column, it appeared to when I selected the Edit column, data was present on the infopath form. I added the column later and I needed to toggle the data. Thanks


0

In the end I did it like this, although I think Vadim's approach may also be correct, I couldn't get it to work myself. get user id by name function getUserId = function (userName) { var clientContext = SP.ClientContext.get_current(); var web = clientContext.get_web(); var currentUser = web.ensureUser(userName); ...


0

You are halfway to answering your own question! :) As you noticed, the URLs are quite different, and the difference is the query string. The first part of a URL usually points to a page (like http://my/site/app/pages/default.aspx), and the query string is everything that comes after the ? character immediately following the page (like ...


0

Yes, as you said SPHostUrl is available as query string parameter for the first time the app is accessed from the host web. But it's no longer available if we go on access any other pages. The possible approach is to save the SPHostUrl somewhere in cookie/session. So that the same can be used further. I found an Article on the same with coding snippet and ...


0

So, you have the query string parameters available to grab from your URL and you are trying ways to do that. I suggest you look at the function GetURLKeyValue. It does exactly that. It is an OOTB SharePoint JavaScript function that is readily available on any page, SP 2010, 2013, without needing any library reference. For your case, the below function ...


0

Move the code that opens the mail client to success method. As JavaScript client object model runs asynchronously it doesn't wait for success method to complete. Hence the variable whose value is assigned in the success method is empty when calling mailto. function onQuerySucceeded(sender, args) { alert('Request succeeded. \n\nRetrieved Item is: ' + ...


1

You can write workflow/ event receiver on item updating calendar list to send email.


1

You could utilize SP.FieldUserValue.fromUser Method for that purpose, for example: var authorVal = SP.FieldUserValue.fromUser(userName); listItem.set_item('Author', authorVal); Complete example var properties = {}; properties['Title'] = 'Request N#789'; properties['Author'] = ...


0

In this post I describe the process of the authentication against O365. The most important steps are: We get the token from the security token service (STS) of MS Online. "Login" to the actual O365 site using the token provided by STS in the former step. As a result of this step, we have the required cookies (FedAuth and rtFA) to be used ...


1

JSRequest is OOB SharePoint JavaScript Object. If you want to use it in CEWP, wrap it insie the script tag. Example: <script type="text/javascript"> //First we must call the EnsureSetup method JSRequest.EnsureSetup(); //Get a query string parameter called Id. i.e - "page.aspx?Id=11" will return 11 itemId = JSRequest.QueryString["Id"]; //Get the ...


1

Did you set your groups to be expanded or collapsed by default? Note that expanding or collapsing happens dynamically, so when the group is collapsed and you try to "select" elements inside that group, they are not available until you expand the group, so these elements are loaded dynamically through JavaScript. If you want to apply your scripts to the ...


1

Updating this field requires the UpdateOverwriteVersion method when working on the server side (see sample). Since this method (or the SystemUpdate method) is not available in the client OM, I am a bit sceptic that you can achieve your goal. It's not clear, what you would like to achieve with this code: var userField = user.get_id() + ";#" + ...


1

Since you are in EditForm, the Url of the page will already contain the ID of the list item. Read this ID using JavaScript url mnipulation. Then use it to get item detials. You need to use SP.List.getItemById(id). Example code: <script type="text/ecmascript" language="ecmascript"> //Get the list item from the Announcements list whose Id is 4. Note ...


2

Use _spPageContextInfo in your JavaScript. Usage: var url = _spPageContextInfo.webServerRelativeUrl; alert(url); See others here: http://blah.winsmarts.com/2013-2-_sppagecontextinfo_is_your_new_best_friend.aspx


0

CAML doesn't have anything built in for that, so you are limited to making two async calls with the JavaScript client object model. The code snippet below checks a list called "Training Progress" for an item created by the current user. It updates it if it exists or creates it if it doesn't exist. ExecuteOrDelayUntilScriptLoaded( function(){ var ...


0

If i understand your question, you need to populate the choice field in form with Choice field column from SPList. Correct me if i am wrong. In you code, i do not see the code to append the choice fields. Might be due to that, its just displaying last item from choice field. In loop , Could you try below line of code? liHtml += "<option value=''>" + ...


0

I finally found a blog that got the answer, my problem was the same the autor had. Here's the link: Sharepoint/Project Server App with javascript and Web Part And here the code I developed in case someone else needs to do the same I needed: <script src="../SiteAssets/scripts/jquery-1.11.2.min.js" type="text/javascript"></script> <script ...


1

You would not use a CAML query to do that. You can get the selected items using SP.ListOperations.Selection.getSelectedItems(ctx) var ctx = SP.ClientContext.get_current(); var items = SP.ListOperation.Selection.getSelectedItems(ctx); See this related answer.


0

A method that does not include the DOM: var getTitle = function() { var id = getUrlVar('ID'), listId = _spPageContextInfo.pageListId.removeBraces(), ctx = SP.ClientContext.get_current(), list = ctx.get_web().get_lists().getById(listId), item = list.getItemById(id); ctx.load(item, 'Include(Title)'); ...


0

If you don't want to interrogate the DOM to get the item's Title value then you can use the Client Object Model implemented with JavaScript (aka JavaScript Object Model). See below for an example: http://www.boostsolutions.com/blog/introduction-to-sharepoint-2013-javascript-object-model/


1

For lookup columns use get_lookupValue() to get the lookup information. Example: oListItem.get_item('Programs').get_lookupValue() UPDATE In case lookup field supports multiple values, use this code: //Get Multiple Lookup Field value var categoryValues = item.get_item('Categories'); for(var i = 0; i < categoryValues.length; i++) { var categoryValue ...


0

In SharePoint 2013 JSOM API you could utilize SP.ServerSettings.getGlobalInstalledLanguages Method to retrieve all the installed languages, like this: function getInstalledLanguages(success,error) { var ctx = new SP.ClientContext.get_current(); var languages = SP.ServerSettings.getGlobalInstalledLanguages(ctx,15); ctx.executeQueryAsync( ...


2

Your speculation is correct, the example provided in the question is intended for creating a wiki page and not enterprise wiki publishing page. Since you mentioned in your question JavaScript Object Model (JSOM), the below example demonstrates how to create enterprise wiki page via JSOM in SharePoint 2013. How to create enterprise wiki page using ...


1

Couldn't you refactor the SPServices call into another function, that takes the "area" value, "topic" value, and the list selector as parameters? You'd still be querying the list 24 times, but it will look a lot cleaner. $(document).ready(function () { QueryNewsList("highlights", "company", "#highlights1"); QueryNewsList("downfalls", "company", ...


0

@paul-strupeikis has the correct answer here IMHO, but I would like to point out a straight forward alternative (albeit not as pretty): Consider using PowerShell in a Scheduled Task. It depends on how instant you need the transferring to occur, but if you could let it wait 2-5 minutes then this approach could be a good enough solution for you. We find ...


1

Your best bet would be using Event Receivers. That, though, requires developing a custom component. Here is a simple HOW-TO What you need is an ItemAdded event receiver, which would check the value of Management column and if it's true, the document would be copied to a different library. You can handle ItemUpdated event as well, if someone decides to ...


1

The following example demonstrates how to update enterprise wiki page content: function updateWikiPage(pageUrl,pageContent,success,error) { getFileWithProperties(pageUrl, function(file){ var listItem = file.get_listItemAllFields(); var itemProperties = {'PublishingPageContent': pageContent}; ...


0

Add the following between the <CommandUIExtension> open and close tag <CommandUIHandler Command="NewRibbonButtonCommand" CommandAction="javascript:Convertion();" EnabledScript="javascript:enable();"/>


2

Ok, thanks for all the help everyone. It was a good insight into how to go about doing what I wanted. The closest way I could get to 'almost' work was Francoise Becker's idea using SPServices jQuery library, however I think ive discovered that in the DISPFORM.aspx, the code behind is different to other pages as I couldnt get the code to run when the ...


3

Since SP.Taxonomy.Term exposes CustomProperties property you could replace the line: taxonomyTerm.get_objectData().get_properties().CustomProperties; with this one: taxonomyTerm.get_customProperties() In order to optimize the request, you could specify explicitly what properties to retrieve for SP.Taxonomy.Term object via SP.ClientContext.load method, ...


0

I've found that if you use enable the minor-version functionality it will keep documents that are dropped into the library checked-out until all required metadata is entered. This prevents other users from seeing the document


1

As Dylan Cristy suggested, you'll need to execute a CAML query to pull back just the items where the Title field is equal to the value you're looking for. Here's the syntax for doing that in the JavaScript client side object model: var title = "My Item Title"; // the title of the item you're looking for var ctx = SP.ClientContext.get_current(); this.web = ...


0

From the Library Menu if you select Modify View and change 'Style' to 'Shaded' it will remove the drag and drop. You end up with more of a list view.


1

Step 1: If you haven't got SPServices, get it -- it's free and it'll make your life easier. http://spservices.codeplex.com/ Step 2: Here's what I've used to get the ID (assuming Title is unique): // Define a lookup query that will pull only the records where the Title field is the one we are looking for var queryLookup = ...


1

I resolved it with: <script type="text/javascript"> var el = document.getElementsByTagName('a'); for(var i=0; i < el.length; i++) { el[i].innerHTML = el[i].innerHTML.replace("12:00 AM",""); } </script>


1

The lookup field in SharePoint internally always looks like ID;#Value example 10;#ItTeam So in field 'Article' You already have ID of target element in 'Department'. So You should parse it using jQuery getter(or see how Your existing JS function does it), and query ListItem element by this Id.


3

Based on your question, i understand that you want to get ID of Department item which is referenced in Article list. Correct me if i am wrong. To get ID of lookup list item, include following in you code(Assuming field name of lookup field from Department is "Department" in article list : var childIdField = listItem["Department"] as FieldLookupValue; if ...


3

One thing you can do is use SP.List.getItems(query) to query the 'Department' list for the item with the Title value you want. Once you get the list item, you can get its ID. (Keep in mind that the getItems(query) method will return a list item collection, even though that collection may only contain one item.) Your CAML query would look something like ...


0

Using 'new' is definitely required, as suggested by wjervis: var context = new SP.ClientContext(currentUrl);


0

So the sample has been updated and renamed here -https://github.com/OfficeDev/PnP/tree/master/Samples/Core.EmbedJavaScript This sample is the one I had issues with, and therefore shouldnt be used. https://github.com/OfficeDev/TrainingContent/tree/master/O3658/02%20Managing%20site%20settings%20using%20app%20model/Completed%20Projects/JavaScriptInjection I ...


0

Definetly we should not use 'id' or 'Class' for manipulating the elements. Instead we can use 'Title' for instance. Below is the example code to use. For Example i have select tag with the Title as Cars, i can get the value selected on the basis of Title name, instead of using its 'id' or 'class' <select id ="wp123123select" Title="Cars"> ...


0

I was able to get this working if my lookup has less tahn 20 items. However it is not working if i has more than 20 + items in Ie10. function ResetDropDownList(lookupcolumnName,NumStoreColName) { if(getField('select',lookupcolumnName)) { getField('input',NumStoreColName).value=''; $("select[title='"+ lookupcolumnName +"'] ...


1

Here is an example that demonstrates how to query all search results using SharePoint 2013 Search REST API: function search(webUrl,queryText,rowLimit,startRow,allResults) { var allResults = allResults || []; var url = webUrl + "/_api/search/query?querytext='" + queryText + "'&rowlimit=" + rowLimit + "'&startrow=" + startRow; return ...


1

Like to note that RootFolder as you point out yourself is not a bad idea if you were to use REST (and not jsom), like this: /_api/Web/Lists?$filter=RootFolder/Name eq 'MyImages' Then just pick the first one, and you get one result with all additional list data. (Syntax tested on 365, might need $expand on-premise.)


1

How to get List by its Url: function getListByName(name,success,error) { var ctx = SP.ClientContext.get_current(); var lists = ctx.get_web().get_lists(); var result = ctx.loadQuery(lists, 'Include(RootFolder)'); ctx.executeQueryAsync( function () { var list; for(var i = 0; i < result.length; i++) { ...


0

Here is the Example of Horizontal Accordion with jQuery and SharePoint : Horizontal Accordion in Sharepoint


1

Basically you would have to call the function that does that on regular basis using setInterval , but if you would like, here's another plugin that does that for you: Lite Accordion


1

I have run into this before on a couple sites. The performance/response degradation was at vastly different points for each farm once we introduced high concurrency, but consistent within each farm. The number of terms we were dealing with in both cases was significantly more than 60... I was not able to find an authoritative answer for performance bounds, ...


3

The following example demonstrates how to return web sites sorted by last modified date: function getWebs(success,error) { var ctx = SP.ClientContext.get_current(); var web = ctx.get_web(); var webs = web.getSubwebsForCurrentUser(null); ctx.load(webs); ctx.executeQueryAsync( function(){ var result = []; ...



Top 50 recent answers are included