Tag Info

New answers tagged

0

First add the page you created the new web part to the Pages library. Lets assume the page name is Page1.aspx. Then in the page you need to add the link to it add it like this. <a href="javascript:OpenPopUpPage('/Pages/Page1.aspx');">Page Popup</a>


0

For new/edit form's, the inputs all have titles that are set to the field name. So if your field is called "Today", then the following jQuery selector will retrieve the field: $("input[title='Today']"); // If the field is a required field, then it will be title='Today Required Field' Then use .val(today) to set the inputs value. But this only helps you ...


1

I've used a technique like this in the past to handle the execution of jQuery after webparts ajax load or ajax refresh, http://stackoverflow.com/a/7062485/318776. Basically after the ajax call/postback is complete, it will execute your code. <script type="text/javascript"> Sys.Application.add_init(function () { ...


2

It looks like Microsoft have introduced the SiteLogoUrl property now within SPWeb in Office 365: http://blogs.office.com/2014/08/13/uservoice-driving-improvements-sharepoint-api/ and https://officespdev.uservoice.com/forums/224641-general/suggestions/6234945-make-the-sitelogourl-property-available-in-csom The <SiteLogoUrl> element is emitted from the ...


1

This is not possible with pure SharePoint Online/O365.


1

Even though Web class does not expose Groups property like SPWeb class does, you could still retrieve a collection that contains all the groups for the website. How to retrieve groups for a web Use RoleAssignmentCollection.Groups property to get the groups that directly belong to the access control list (ACL). for this securable object. CSOM using (var ...


0

I had the same issue here, and being an application developer in C++ I forgot that the tab/page instance holds the javascript environment in the same way that an undeleted pointer is held by an application for the lifespan of the application. So if for whatever reason your script fails and bails out, then the local SP namespace objects are now inaccessible ...


0

I realize that this response is very delayed but I figured out how to do this after a lot of reverse engineering and maybe this will save someone else some time. To better understand and improve on this example, it will be helpful to: Have an understanding of how a ribbon is created and how commands are registered Take a look at the sp.ribbon.js file and ...


1

The solution is similar to the one I provided in this accepted answer: Attach a Javascript function to an OOTB ribbon button. Here's the code, adopted for your case: <CustomAction Id="TrackDownloadsAction" RegistrationType="List" RegistrationId="100" Location="CommandUI.Ribbon"> <CommandUIExtension> <CommandUIDefinitions> ...


0

One option is to add a link to the item which has the attachement as a workaround if you don't want to add third party tools or Azure/Provider hosted Apps. In your e-mail template Define E-mail Message add a Link and edit the link with String Builder to get a direct link to the item. It's not an optional solution but it fairly easy for a user to click on ...


0

I have code I use to upload files using the filereader object. The uploadFile function is called on the event change of a file input and passes the event.target.files to the function. If you are using IE you will need to use a polyfill to provide the same functionality. I have used https://github.com/Jahdrien/FileReader. Event Object: jQuery('#' + ...


0

This would refresh the page if the parent was closed via a submit button and not by clicking on the 'X'. Clicking on the 'X' would not refresh the page. var options=SP.UI.$create_DialogOptions(); options.url=''; options.height = 400; options.dialogReturnValueCallback = function(dialogResult) {SP.UI.ModalDialog.RefreshPage(dialogResult)}; ...


1

Yes, you can do it from JS. The code will be something like this: (function () { var workflowInstanceId = 'PUT-YOUR-GUID-HERE'; var context = SP.ClientContext.get_current(); var web = context.get_web(); var servicesManager = SP.WorkflowServices.WorkflowServicesManager.newObject(context, web); var instance = ...


0

Try this $('#tbSearch').keypress(function(event){ var keycode = (event.keyCode ? event.keyCode : event.which); if(keycode == '13'){ //Your Code that you want to execute or simply call the function RedirectUrl() RedirectUrl(); } }); You need JQuery reference


0

According to the documentation: MSDN Use this simple code to set value people picker: //Get people picker Object var peoplePicker = this.SPClientPeoplePicker.SPClientPeoplePickerDict["peoplepickerID"]; // where peoplepickerID is ID of the element people picker that you could set value. peoplePicker.AddUserKeys(user.DisplayText); // set value, where ...


1

First of all, SP.List.getItems Method returns SP.ListItemCollection object not an SP.ListItem object. Second, in your case you have to submit first query in order to retrieve item collection and then only to get the item and delete it, for example: var items = list.getItems(query); context.load(items); context.executeQueryAsync( function() { ...


1

You are attempting to use a SP.ListItem method on a SP.ListItemCollection object. SP.List.getItems() returns a SP.ListItemCollection object. You must iterate through this to get to the items themselves. Try the following: function deleteListItemSP(title){ var siteUrl = 'mylink'; var clientContext = new SP.ClientContext(siteUrl); var oList = ...


0

If your goal is to remain true in using SharePoint 2013 OOTB, as a front-end developer, IMO, you should store your custom Javascript and CSS files in the Style Library. Make a sub folder within that location and store your items there. You could then reference your items from your custom .htm master pages and .htm page layouts. When you say... "My ...


1

Yes Master Page gallery is the recommended location in SharePoint 2013. But one thing that I have notified with that is it always go through an authentication check, which for every SharePoint document it does. This make things slow. (Might not be much visible with the single users, but depending on the Secure Store Service and the number of users access it ...


0

There are a lot of things that go into this and there are a lot of options, that is evident by this post. My personal best practice is reference libraries in the master page, like jQuery. Store these libraries in the layouts folder, if you have access to deploy them to the servers, otherwise I store them with javascript files that utilize the libraries. ...


1

If you can attach JS to the save action in your IFrame its quite easy. //set this in your IFrame when your item was saved var itemWasSaved = 0; if(yourItemWasSaved){ var itemWasSaved = 1; } //check if the item was saved via accessing the IFrame variable var iFrameItemInfo = $('#youriframe').get(0).contentWindow.itemWasSaved;


0

For the OR part.. How to get the SC URL from a full URL in JSOM Sadly the only way is try and error. Here's my code to get the SC URL (I wanted to get fields of a image listitem by its full URL) related SE post function getFileProperties(url, fileUrl) { //to get the file specific client context //you can create the ...


4

Sure you can. It's JS code after all and you could either use global variable to store your information or the provided ctx object. Here' a example for both possibilities: ControlTemplate: <!--#_ window.ThisIsGlobal = "this works !"; ctx.MyVar = "THIS WORKS !"; _#--> ItemTemplate: <!--#_ ...


1

I use to call REST like this in my current project: var formDigest = $('#__REQUESTDIGEST').val(); $.ajax({ type: "POST", url: "your URL here", headers: { "X-RequestDigest": formDigest }, contentType: 'application/json; charset=utf-8', data: JSON.stringify({ "ParamName": "Param Value" }), datatype: 'json', }) .done(function (data) { ...


0

Just found a way around! Using SPservices: function NuevaIncidencia(){ $('#Aceptar').attr("disabled", "disabled"); var values = [['Title', $('#titulo').val()], ['Descripci_x00f3_n', $('#descripcion').val()], ['Tipo_x0020_Incidencia', $('#tipo').val()], ['Prioridad', $('#prioridad').val()], ['Estado', 'Abierta']]; ...


0

Because you're working in an iframe, you'll have to call the parent document from within the frame. Follow these instructions: http://stackoverflow.com/questions/4689145/pass-jquery-variables-between-iframe-and-parent


1

You could use _spFriendlyUrlPageContextInfo.termId to get the Term information(GUID) for the current page.


1

This is a document library, and libraries don't follow the same conventions as regular lists with regards to the contents of the Title field. For a simple solution, you should find what you're looking for if you just use oListItem.get_item('FileLeafRef') as Vadim suggests. See below for some other useful info, but in summary when I run into something like ...


0

You need to declare the collListItemsEP variable globally so that it'll be defined when used in the success callback.


1

This would help. There’s a JavaScript API for Creating Ribbons! http://dbremes.wordpress.com/2011/01/16/theres-a-javascript-api-for-creating-ribbons/ Intro to Manipulating the SharePoint 2010 Ribbon with JavaScript http://sharepointtaproom.com/2011/09/09/intro-to-manipulating-the-sharepoint-2010-ribbon-with-javascript/ Plus, surely, the same stuff can be ...


0

I got it to work so I will share my victory with you. This code works if you need to get the Site collections paths, title etc. var queryUrl = spAppWebUrl + "/_api/search/query?querytext='sharepoint'&trimduplicates=false&rowlimit=400&refinementfilters='contentclass:equals("STS_Site")' $.ajax({ url: queryUrl, method: "GET", headers: { "Accept": ...


2

In order to retrieve File or Folder properties you could use the following associated List Item properties: FileRef - returns File/Folder relative Url FileLeafRef - returns File/Folder name Example function getListItems(listTitle,success,error) { var context = SP.ClientContext.get_current(); var list = ...


0

Using the client side object model or CSOM from SharePoint Online, you can retrieve the details of a list item and create a new list item. Basically, you would use at least two rountrips to the server from. First, you want to use the JavaScript library provided with SharePoint to get the SharePoint context, send an asynchronous query to SharePoint Online ...


1

I did this for a wiki. I added a new page layout instead of using a content editor, but the process should be quite similar. This will pick up any h1 - h4 header located on the page and include it in the TOC. It will add a hyperlink to the item in the TOC so you can navigate to that section directly. Place the <div> where you want the table to be. ...


0

You cannot add javascript directly to a content editor. You can add javascript to a content editor by uploading a text file to somewhere on the sharepoint site and then referring to it in the web part settings. Assuming your issue is the javascript being removed from your content editor. If you are using SP2013 you can also use a script editor web part to ...


0

What columns do you have added to the default view for the library? I've seen issues like this before when I had forgotten to add the columns I wanted to the default view. It seems unlikely Title wouldn't be in there, though... I also saw a similar SO question where the .load function uses an extra argument: clientContext.load(collListItem, ...


0

The getfilebyserverrelativeurl endpoint returns an SP.File object, so you need to select and expand the "ListItemAllFields" object with your document request to get the list item (SP.ListItem) that corresponds to your document, then you can expand to get the ParentList (SP.List) item for that document Append this select and expand statement to your list ...


1

It will depend upon how your master page is structured. A neat way would be add a new div wrapper inside #s4-workspace and add the CSS for the wrapper class. Include the css/reference from the master page: /* For Fixed Width */ div.wrapper { margin: 0 auto; width: 1000px; } /* For Fluid Width */ div.wrapper { margin: auto 5% !important; ...


0

To strip the Html, you could do something like this: function stripHtml(body) { var regex = /(<([^>]+)>)/ig; var result = body.replace(regex, ""); return result; } If you're using jQuery, you can use text() function ex. var divText = $("#myDiv").text();


1

No, this is exactly what the masterpage is designed for. You're going about it the completely wrong way though. These are CSS customizations. Add the following somewhere in the header: <style> #s4-workspace{ width:1024px; margin:auto; } </style> Modify accordingly Also, go through a CSS tutorial to explain to you the basics: ...


0

I never did figure out what exactly in the script is interfering with the normal ribbon functionality, but it appears to be one of my context calls. Since I finally got my script working the way I wanted after weeks of work, I didn't want to change the script and risk breaking it. In the environment, users only need maybe 3 functions off the ribbon anyway, ...


1

In order to get data from your list to your form, you will need to use either CSOM (JSOM or C#, depending on how your app is hosted) or REST. See these links on how to get list items: CSOM JSOM REST If the list is on the host web, and you are trying to get items from the app, you will need to use the Cross-Domain Library, Sp.RequestExecutor.js. Here is ...


3

It basically depends on your personal experience with the different technologies, there are many opinions out there with lots of pros and cons that may or may not be relevant to you. I personally very much dislike pure javascript CSOM because of all the context loading and SPServices was a good abstraction for that, but eversince I've used REST in SP2013 I ...


0

I'm not sure if I understand the question correctly, but I think you have a completely new customized webform that has absolutely no connection to SharePoint. And now you want that form to include data from a SharePoint list item using html + css + jss, is this correct? Microsoft has good documentation on this, if you go through this I'm confident you'll ...


1

Where is the list located? Is it inside the same app web or the host web? If it is app web, then follow this article. If it is the host web, then you need to enable permissions in the app permissions to read list. Then access the host web voa javascript. All need to be done with JS Async calls.


1

I build something similar. I just checked if the current url contains the path of my navigation element. In your case the URLs would cause that multiple links are marked as active. But with a ordered set of URLs you can avoid this. // URLs ordered by length to ensure correct results var orderesNodes = []; orderesNodes[0] = ...


-1

I used like this work for me EX: <SharePoint:DateTimeControl ID="txtstartdate" AutoPostBack="true" CssClassTextBox="h25" DateOnly="true" runat="server" OnDateChanged="dateDateBorrowed_OnDateChanged" />SharePoint:DateTimeControl CssClassTextBox="h25" AutoPostBack="true" ID="txttodate" DateOnly="true" runat="server" ...


2

Pros A wide range of SharePoint functionality is exposed with the SOAP Web Services, much of which is not available in CSOM Allows anonymous access (assuming it is enabled for the underlying objects) Works cross-site and cross-domain, assuming that the authentication model you are using allows it Simpler syntax than the CSOM. Simply pass the required ...


0

I would use the SPServices UpdateListItem function for this. Set your form information to a JQuery variable and use SPServices to update the list data from there. <input type="text" class="myInput"></input> <script type="text/javascript" src="it/_layouts/js/jquery-1.8.2.js"></script> <script type="text/javascript" ...


0

For me, and to make my work modular, I prefer to have a JavaScript file with every page (i.e. for /Lists/Products/AllItems.aspx page I love to have Products/AllItems.js. You can achieve this logic by using delegate control with simple Switch/case and inject Script file reference into the delegate control after checking the URL



Top 50 recent answers are included