New answers tagged

1

I accomplished this using jQuery: <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script> <script> $(document).ready(function(){ var linkText = $(".ms-webpart-titleText").text(); $(".ms-webpart-titleText").html("<a href='InsertURL'>" +linkText+ "</a>"); ...


0

If you don't explicitly know that these fields exist prior to calling the items endpoint, then it would be helpful to make a call like /_api/web/lists/getbytitle('Thing')/Fields and look for the desired fields. If they exist, then you can call your items endpoint with your select and expand params, otherwise you don't.


1

Put your managed properties in Display Template ITEM (inside _catalogs/masterpage/Display Templates/Content Web Parts/filename_Item.html) under ManagedPropertyMapping <mso:ManagedPropertyMapping msdt:dt="string"> </mso:ManagedPropertyMapping> For example Add these two properties <mso:ManagedPropertyMapping msdt:dt="string"> 'Client ...


0

You have to use JQuery Deferred & Promise methods. Basically your AJAX call will return a promise and you can call our server button click event after the deffered action is resolved. See this api documentation and read this good post about the same. /* ajax calls returns promise by default*/ function doAjaxCall(){ return $.ajax({/*...


1

You don't have to deal with __metadata. Just specify your ContentTypeId in your request body and that's all. data: JSON.stringify({ __metadata: { "type": "SP.Data.Example_x0020_ListListItem" }, Title: "_", field1: "val1", field2: "val2", field3: "val3", ContentTypeId: "Your content type id" }) In the __metadata you need ...


2

Everything looks like it is working properly in your code, you are getting the data and manipulating the DOM. So that leaves why are you are seeing the results you are. That is because you are doing $('#postBody').text(curBody); instead of $('#postBody').html(curBody);. This is taking your data and making it raw text. Use the .html to make it literal html ...


2

An easy check for SharePoint Online or on premises would be to look at the host name. In the case of SharePoint Online, it will always be in the form of tenant.sharepoint.com. A local installation, third party hosted, or something running in Azure, it will be for all intents and purposes the same thing, an on premises installation. This then leads to how ...


0

//For updating custom column while uploading file you use following code with yayati's code function upload() { // Define the folder path for this example. var serverRelativeUrlToFolder = 'SiteAssets'; // Get test values from the file input and text input page controls. var fileInput = jQuery('#getFile'); var ...


1

Here's a small utility to attach properly to the SharePoint lifecycle. You use it like this: window.LifeCycleHelper.AttachToLoad(function(){ alert('Hello World'); }); Utility: //use an IIFE to create a scope and dont dirty the global scope (function (_) { // use strict to ensure we dont code stupid 'use strict'; var initHandlers = []; ...


0

I've found the issue. All or the functions has to be inside window.onload = function (). Then it works. <script language='javascript' type='text/javascript'> var itemId = 12; var targetListItem; var ref; //with window.onload window.onload = function () { SP.SOD.executeFunc('sp.js', 'SP.ClientContext', runCode); //...


0

Thank Amal for your idea, I have done it using Client Side Rendering. Please find the steps below, Create a new view in the Promoted Links list using All Promoted links view Link the below JS code to the list view webpart using JS Link (function () { var option = { Templates: { Item: CustomItem } } ...


0

This occurs because of Sharepoint sets the _spFormOnSubmitCalled to true and disallow more submits unless it is set back to false as occured in postback behavior. So at OnClientClick event you should set _spFormOnSubmitCalled to false; The final code should look like <asp:LinkButton ID="btnGenerateReport" runat="server" CssClass="generateReport ...


0

I Created a workflow to do this by removing edit permissions. The button is still there but it does the job. I have a 2010 workflow run and pause until field equals no Then it replaces all the permissions on the item to read and give the group that needs edit rights, edit permissions. For my workflow I gave edit permissions back at the end. You can ...


1

Preferably you do not hardcode Fieldnames in your CSR code, so you can re-use your code or make it into a generic function This is more generic and easier to maintain: var name = ctx.CurrentFieldSchema.Name; var value = ctx.CurrentItem[name]; var percentage = value / 100; var color = 'red'; if (percentage >= .5) { color = 'orange'; } else if (...


-1

SP.SOD.executeFunc("clienttemplates.js", "SPClientTemplates", function() { function getBaseHtml(ctx) { return SPClientTemplates["_defaultTemplates"].Fields.default.all.all[ctx.CurrentFieldSchema.FieldType][ctx.BaseViewID](ctx); } function init() { SPClientTemplates.TemplateManager.RegisterTemplateOverrides({ Templates: ...


0

Here is a CSR script: SP.SOD.executeFunc("clienttemplates.js", "SPClientTemplates", function() { function getBaseHtml(ctx) { return SPClientTemplates["_defaultTemplates"].Fields.default.all.all[ctx.CurrentFieldSchema.FieldType][ctx.BaseViewID](ctx); } function init() { SPClientTemplates.TemplateManager.RegisterTemplateOverrides({...


1

The content type object is not loaded. So you need another round trip to the server to get the details as below function SuccessHandler(result) { var newshtml = ''; listItemEnumerator = collListItem.getEnumerator(); while (listItemEnumerator.moveNext()) { oListItem = listItemEnumerator.get_current(); var CT = oListItem....


0

Go to your List Settings Page. Click on the "LastName" field you had created. Notice the URL to find the internal name of the field. The URLwill something like "http://...Field=[InternalName]" . This will give you the field name that you can use to access the field.


0

Did you try the below solution? http://stackoverflow.com/questions/10205192/x-frame-options-allow-from-multiple-domains You may have to allow that specific domain in which you want to show the documents. You can set X-Frame-Options in IIS for the specific site. Click on the site in IIS. In the middle pane look for HTTP Response Headers and add an entry ...


2

You should set the iframe source after you retrieved the data. This should go inside the onQuerySucceeded event as below function onQuerySucceeded(sender, args) { var listItemInfo = ''; var listItemEnumerator = collListitem.getEnumerator(); while (listItemEnumerator.moveNext()) { var oListItem = listItemEnumerator.get_current(); ...


0

A Remote Event Receiver may give you the correct token for the Client Context if you enable it on AppInstalling. It's difficult to access external Lists (from the App web), but if you throw in a WCF service and CSOM, it gives you a little more control This post may help you when defining different Client Context based on the situation. This post will give ...


0

Try the following: <Sharepoint:ScriptLink ID="ScriptLink1" Name="sp.ui.dialog.js" LoadAfterUI="true" Localizable="false" runat="server"></Sharepoint:ScriptLink> LoadAfterUI="true" worked for me. Reference


0

SharePoint exposes WebServices which you can use to load information to SharePoint from External Systems. Since you specifically requested for List Item Add below service can be used https://blogs.msdn.microsoft.com/ryanrogers/2004/10/08/adding-new-list-items-using-the-lists-asmx-web-service/ You can also check the REST endpoints https://msdn.microsoft....


0

For cross site collection scripts to work in app you have to do below things: Tenant level permissions Tenant scope deployment of the app.


1

refer msdn In short, override this method in your C# code, then your custom property will appear in the form context / field schema in javascript. public override Dictionary<string, object> GetJsonClientFormFieldSchema(Microsoft.SharePoint.WebControls.SPControlMode mode) { Dictionary<string, object> schema = base....


0

These are possible options: Use Rest SharePoint provides most of it's actions as REST endpoints. This could possibly cause some problems regarding the Cross-Origin policies. You can't use request batching here so you may suffer a lack of performance. Reference [Preferred] Use .NET CSOM (serverside) This will work as long as you can access the from ...


0

use Javascript client object model to retrive data from sharepoint list.Sharepoint site should have Anonymous access. Sample reference : JSOM


5

Try this for calling your function: SP.SOD.executeFunc('sp.js','SP.ClientContext',getMyTasks); You will get more info from below link: SP.SOD.executeFunc(key, functionName, fn) Method


0

Should you check this code Create a new function and rename it as bulkupdate Function BulkUpdate() { for(var i = 1; i<= 5; i++){ updateListItem(int i); } } } var siteUrl = '/sites/MySiteCollection'; function updateListItem(int i) { var clientContext = new SP.ClientContext(siteUrl); var oList = clientContext.get_web()....


0

Thank you all ! it's fixed it using the Cisar Chrome Extension and the problem was related to Field internal Name


1

It seems like clientContext.executeQueryAsync(succeededCallback, failedCallback) is missing from you code. You will be able to access list data in succeededCallback function only. Please refer msdn link for you reference.


0

You just need to specify the server relative url of the sibling site. http://<endpoint><serverrelativeurl of the sibling site>/_api/web/GetSubwebsFilteredForCurrentUser(nwebtemplatefilter,nconfigurationfilter)


1

OOTB way to achieve this is to make the User Name column as unique. This is only possible if the column is single select person or group column.


0

UPDATE: I ended up changing the column type to a drop down instead of radio buttons. That said, I did recently have another project which required me to capture the value of a radio button. In looking at the code in Chrome developer tools, it appears as though SharePoint doesn't give a title to radio button fields as it does with other field types, but ...


0

In SPServices 2013.01 and up, you need to include the webURL property. $(document).ready( function(){ var user = $().SPServices.SPGetCurrentUser({ webURL: "http://sharepoint/site/", fieldName: "Title", fieldNames: {}, debug: false }); alert(user); }); EDIT Added fieldsNames and debug properties to ...


0

Your question is not clear and hard to understand. I'm not sure you are using InfoPath in the way it was intended. InfoPath is a tool to display XML data in a visually appealing way. There is no immediate connection between InfoPath forms and Excel tables. InfoPath forms can be filled in and stored in a database or in a SharePoint library. The stored data ...


0

You can use the below code to find WebApp url, this takes care of port number too (if exists) var WebAppUrl=""; if (location.port) { WebAppUrl = window.location.protocol + "//" + window.location.host + ":" + location.port; } else { WebAppUrl = window.location.protocol + "//" + window.location.host; }


0

You can use the below code to find WebApp url, this takes care of port number too (if exists) var WebAppUrl=""; if (location.port) { WebAppUrl = window.location.protocol + "//" + window.location.host + ":" + location.port; } else { WebAppUrl = window.location.protocol + "//" + window.location.host; }


0

Couple of things you can do Use SharePoint Designer and the Edit file directly instead of upload. Use Script Editor Web Part and give it a go.


1

From app's iframe you will not be able to get hold of parent window url due to cross domain issue. The solution is to write a javascript that will be hosted in content editor webpart in parent window page. It will read parent window url and pass in that as query string parameter to app's iframe. Find sample code below. I have passed the parent url's query ...


0

I'm not sure what version this is for, but for 2013/O365 you can use the AJAXRefreshView function provided by SharePoint. Example using the list title prop, you can use the property that suits you: AJAXRefreshView({ currentCtx: g_ctxDict[ Object.keys(g_ctxDict).filter(function(v) { return "Tasks" === ...


0

You can use embed code in rich HTML text editor: After clicking the command, you are prompted to insert your code and given a preview: Alternative solution: SharePoint creates a Script Editor webpart on the page for you. It even includes an "Edit Snippet" button, so you can go back and edit the code later. OR you can use Content editor webpart and ...


0

You can achieve this by simply add a querystring "Source=" in your survey URL. First, create a thank you page (e.g. /pages/thankyou.aspx). Then, in your survey newform URL (e.g. <site url>/Lists/survey/NewForm.aspx) add the querystring like this: <site url>/Lists/survey/NewForm.aspx?Source=/Pages/thankyou.aspx When the users completed the ...


0

I have modified my code which gives me what I need - and workable in my environment. $(document).ready(function () { // Get a single select dropdown field var IntExtField = SPUtility.GetSPField('Internal_External'); // create a function to show or hide Internal External based on select value var showOrHideField = function() { var IntExtFieldValue = ...


0

On the page, insert two web parts, one for each library, and set them to show the last 10 modified items. Find the IDs of each webpart (using the developer tools) or wrap each webpart in a div with an ID you specify Then use Javascript to extract the URL parameter and jQuery to hide the other webpart. The following code is from http://jquery-howto.blogspot....


0

If you're just looking to use some jQuery to find the anchor tag in your nav menu whose href is the same as the current url you could do something like this: var currentRelUrl = window.location.pathname; var navNode = $(".s4-ql .menu-vertical a[href$='" + currentRelUrl + "']").addClass("highlight");


0

I had same issue where my parentColumn and childColumn were required fields. Once made them optional then it worked again. Not sure if SPServices has a way to deal with them if required.


0

The shortest dev cycle time would be to keep 80 pieces of data in identical ways and write your interface to reuse the code as much as possible. Also, minimize the number of fields per query, and queries per view. You will note from the example that this format scales well. The single field could be as easy as a hash where you use 2 bits for each item and ...


1

Good to see more CSR questions In View (and only in a View!) CSR code, the function actually gets 4 parameters. So you can write: View: function(ctx, CurrentFieldSchema, CurrentItem, ListSchema) { return String.format("{0} ({1})",CurrentItem.FileLeafRef,CurrentItem.ItemChildCount) }, The for loop in Daniels answer can be shortened with standard ...


0

As a thumb rule.. Use REST APIs for list data operations, for rest of requirements better to use client side APIs. REST APIs doesn't support Taxonomy retrieval/manipulations, please use client side APIs.



Top 50 recent answers are included