javascript
11 TopicsAdding custom javascript to sharepoint
Hi, i would like to create a webpart that pops up on a site at random location with something like "Congratz, you won!". I am absolutely new to sharepoint development, but i am very familiar with java. So i guess i can manipulate the DOM somehow with javascript and insert somewhere my visible part of the webpart. I followedhttps://learn.microsoft.com/en-us/sharepoint/dev/spfx/web-parts/get-started/build-a-hello-world-web-partbut i am already struggling. Where i can inject the javascript so it gets executed? Because everything is getting escaped (and the code is shown). I found some old code on one of our servers which "loads" some .js from inside a .ts like: link = document.createElement("script"); link.setAttribute('type', 'module'); link.setAttribute('src', srcPath); link.setAttribute(dataIdentifier, 'true'); and then adding it with document.head.appendChild(link), but i am not sure if this is really how this is supposed to work or if there is something like "addJavascript(...)" or any other better approach to add javascript on client side. Any help is very appreciated!12KViews0likes3CommentsSharepoint OAuth2.0 API Access
I created the API in share-point and saved all XML permission to the app, however I am getting the error code"-2147024891, System.UnauthorizedAccessException", I am able to get the access token. When passing the access token to the share-point API it is throwing the above mentioned error. Alternatively I tried to create the app in AzureAD and grant all the permission to the share-point App, and when getting the access token and while passing the access token to the share-point API it is throwing me the error code : "{"error_description":"Exception of type 'Microsoft.IdentityModel.Tokens.AudienceUriValidationFailedException' was thrown."}", Do anyone has the fix how resolve this error. I1.2KViews0likes1CommentNext Js as WebPart
Hi there, I have an application that was made using Next Js and my team wants to put it on a share point page, I have been trying to find information to know if this is even possible. I found WebParts but I am not sure if that is compatible with Next Js and I haven't found any resources that could help me with this. Any help will be appreciated. Thanks.3.7KViews0likes1CommentLoad predefined data from columns and update field with possible selection with Javascript
I am struggling with piece of code. I am working on SharePoint 2013 and I am trying to set 2 fields fixed when creating a new item in list. All 3 fields are lookup columns, but the red highlighted fields I want to set as fixed and the yellow highlighted field is conditioned by the fieldVyberova_Skupina_SluzbaAlsoVyberova_Skupina_Sluzbais conditioned by the fieldVyber_Oblast I used the part of the code below, the fields are fixedVyber_OblastandVyberova_Skupina_Sluzbabut third column is not updated. function nastavSluzba(){ $('#Produktova_Skupina_Sluzba').find('select').val('Hypotekárne úvery'); $('#Vyber_Oblasti').find('select').val('Úverové produkty pre FO') $('#tableNapoveda').remove(); $("#Vyber_Oblasti").find('select').attr("disabled", true); $("#Produktova_Skupina_Sluzba").find('select').attr("disabled", true); $("#Vyber_Oblasti").find('select').css({"background-color": "white","color": "black"}); $("#Produktova_Skupina_Sluzba").find('select').css({"background-color": "white","color": "black"}); var allOptions = document.querySelectorAll("[title=Vyber_Oblasti] option"); [].some.call(allOptions, function(option) { if (option.innerHTML == "Úverové produkty pre FO") { option.selected = "Úverové produkty pre FO"; return true; } }); var allOption = document.querySelectorAll("[title=Produktova_Skupina_Sluzba] option"); [].some.call(allOption, function(option) { if (option.innerHTML == "Hypotekárne úvery") { option.selected = "Hypotekárne úvery"; return true; } }); Can you help me make sure that the third field is loaded automatically and that the user can select an option that falls underProduktova_Skupina_Sluzba?643Views0likes0CommentsCannot add new item to ECB Menu - SharePoint 2019
Hello, We just migrated from SharePoint 2013 to 2016, then 2019. We create items in the menu in JavaScript via the CAMOpt () function. In 2013 and 2016, everything is working perfectly, but not in 2019. The "m" parameter in the functionCAMOpt is constantly null and the item is not added. CAMOpt(m,"Add to...","AddTo('"+listName + "'," + currentItemID +");"); The issue is identical to the following topic (which has been closed and reported as a bug):Can't add element to ECB menu in Sharepoint 2019 I cannot use JSOM to add to the menu permanently because I want the item only appear on a particular page and "SP Callout actions" is not working for custom list / generic list. Do you know a solution or a workaround ? Thanks in advance Nathan914Views0likes0CommentsUpdate Group SharePoint Custom Field Collums after Fileupload with REST Graph API in Javascript
Hi, I've made an upload with Graph with the following JS code: async function uploadSingleFileMetaToSharepoint(file, name, metaData, groupId, graphAccessToken) { //console.log(file, name, metaData, groupId); //TODO get Filepath from config of App let pathToFiles = 'General' let apiurl = msgraph + `/groups/${groupId}/drive/root:/${pathToFiles}/${name}:/content`; if (debug) { console.log("uploading File: ", file); console.log(`API-URL: ${apiurl}`); } let header = { 'Authorization': graphAccessToken, } let body = file; //TODO catch errors let result = await fetch(apiurl, { "method": 'PUT', "headers": header, "body": body }); if (!result.ok) { console.error("upload file to sharepoint failed"); return } let res = await result.json(); //console.log(res); if (res === undefined || res.id === undefined) {console.error("Die DAtei wurde nicht hochgeladen"); return;} /... } which is working fine. But now i'm struggling to fill the values of the collumns from sharepoint : Does anybody know how to approach this?Solved1.5KViews0likes1CommentSharepoint putting extra "src" information in <img> tags
Hello, I'm trying to find a resolution to a problem i have never came across previously. I have created a quill rich text editor where i intend to put text and images that i can store as html in sharepoint lists in order to load it on a custom landing page instead of updating the html code itself every time there is new content. While storing formatted text works perfectly, i am facing an issue whereas <img> tags get altered by sharepoint by adding an extra URL in them before the actual URL of the image. This makes the <img src="" property incorrect and the image doesnt load. I tried with reading the element from the DOM and altering the property with javacript.replace, but whenever i load the corrected code back to the DOM, sharepoint puts the extra (wrong) link snippet back to its place. example: URL of the image i upload as html code into a list: <div class=""><p><img class="class" src="https://company.sharepoint.com/sites/PortalName/DocumentLibraryname/image.jpg" data-themekey=""></p></div> Then what comes out when rendering the DOM is: <div class=""><p><img class="class" src="https://company.sharepoint.com/pages/%22https://company.sharepoint.com/sites/PortalName/DocumentLibraryname/image.jpg" data-themekey=""></p></div> Notice the addition of an extra url part in bold. I tried replacing the parts i dont need in "src" with javascript, and even though console.log-ing displays the corrected value, when i put it back as innerHTML to its place, the wrong link gets added back. The process of reading the content of a sharepoint list item, putting it into a var and replacing stuff is connected to an onClick event, therefore document.ready shouldn't be an issue. Has anyone face this issue before? Any help would be much appreciated! Thanks!2KViews0likes0CommentsRetrieving list data from multiple sub-sites using same site content type with JavaScript
Dear all, I'm running a SharePoint site for projects where every project is created as a sub-site with a number of lists. Each sub-site has a list with one list item including the most important project data. This list is using a Site Content Type. I'd like to pull the data from all those lists and write it to one list on the parent site, e.g. by a weekly run of a workflow or manually. Can this task be done by using JavaScript, Rest API, etc.? Has anybody done something similar? Thanks for your tips.1.8KViews0likes2CommentsBest JS framework(Angular/React/Vue) to use in SharePoint 2013
Hi, We have tools (Basically CRUD operations in multiple lists across sites/site collections. Handles large amount of data and has lots of business functionalities/logic) that were built using jQuery and Datatables.js. We are planning to rebuild in 2013. Visual Studio/ server side coding is not allowed. Can anyone suggest which JavaScript framework (Angular Js1.x, Angular 2+, React, Vue/ Others) is best to use in SharePoint 2013? Difficult to get Node.JS/NPM/CLI on DEV environment. we have tried a PoC in Angular 4 using SystemJs-Manual mapping concept. But not sure how bundling and future upgrade will be if CLI/NPM is not used. Any suggestions please? Thanks, Puli2KViews1like1Comment