<script type="text/javascript"> function uploadFileAsAttachment(itemId, fileInput) { var file = fileInput.files[0]; if (file) { var context = SP.ClientContext.get_current(); var web = context.get_web(); var list = web.get_lists().getByTitle("Your List Name"); var listItem = list.getItemById(itemId); // Read the file data var reader = new FileReader(); reader.onloadend = function (evt) { if (evt.target.readyState == FileReader.DONE) { // Create a new file creation information object var attachmentInfo = new SP.AttachmentCreationInformation(); attachmentInfo.set_contentType(file.type); attachmentInfo.set_fileName(file.name); attachmentInfo.set_attachmentCon...
Posts
Showing posts from 2023
- Get link
- X
- Other Apps
By
Anandan M
-
<script type="text/javascript"> function uploadFile() { var fileInput = document.getElementById("fileInput"); var file = fileInput.files[0]; if (file) { var context = SP.ClientContext.get_current(); var web = context.get_web(); var list = web.get_lists().getByTitle("Your List Name"); var folder = list.get_rootFolder(); context.load(folder); // Read the file data var reader = new FileReader(); reader.onloadend = function (evt) { if (evt.target.readyState == FileReader.DONE) { // Create a new file creation information object var fileInfo = new SP.FileCreationInformation(); fileInfo.set_url(file.name); fileInfo.set_content(new SP.Base64EncodedBy...
Sample HTML
- Get link
- X
- Other Apps
By
Anandan M
-
<!DOCTYPE html> <html> <head> <title>SharePoint Layout with Glassy Look</title> <style> body { background-color: #800000; /* Maroon background color */ color: #FFFFFF; /* White text color */ font-family: Arial, sans-serif; margin: 0; padding: 0; } .container { max-width: 960px; margin: 0 auto; padding: 20px; background-color: rgba(255, 255, 255, 0.8); /* Semi-transparent white background */ box-shadow: 0 0 10px rgba(0, 0, 0, 0.3); /* Glassy box shadow */ } h1, h2, h3 { margin: 0; } .content { margin-top: 20px; } </style> </head> <body> <div...
Retrieve List Item Details
- Get link
- X
- Other Apps
By
Anandan M
-
function retrieveListItemDetails(listName, itemId) { // Get the current SharePoint context var context = SP.ClientContext.get_current(); // Get the list var list = context.get_web().get_lists().getByTitle(listName); // Get the list item var listItem = list.getItemById(itemId); // Load the list item properties context.load(listItem); // Execute the query context.executeQueryAsync( function () { // On success, retrieve the item values var title = listItem.get_item('Title'); var description = listItem.get_item('Description'); // Concatenate the values into a query string parameter var queryStringParam = 'title=' + encodeURIComponent(title) + '&description=' + encodeURIComponent(description); // Pass the query string parameter to another applicati...
Javascript function to populate from query string
- Get link
- X
- Other Apps
By
Anandan M
-
function populateFieldsFromQueryString() { // Get the query string from the URL const queryString = window.location.search; // Check if there is a query string if (queryString) { // Remove the leading "?" character const queryParams = queryString.substring(1); // Split the query string into key-value pairs const keyValuePairs = queryParams.split("&"); // Loop through the key-value pairs keyValuePairs.forEach((pair) => { // Split each pair into key and value const [key, value] = pair.split("="); // Decode the key and value (in case of URL encoding) const decodedKey = decodeURIComponent(key); const decodedValue = decodeURIComponent(value); // Find the corresponding field in the document const field = document.querySelecto...
- Get link
- X
- Other Apps
By
Anandan M
-
To convert a column of folder paths into a tree structure of rows, you can use a combination of Excel formulas and VBA code. Here are the steps to follow: Insert a new column to the right of the column with the folder paths. In the first cell of the new column, enter the formula =LEN(A1)-LEN(SUBSTITUTE(A1,"\","")) , where A1 is the first cell in the column with the folder paths. This formula calculates the number of backslashes in the folder path. Copy the formula down the entire column to calculate the number of backslashes in each folder path. Insert a new sheet in the workbook and name it "Tree". In the "Tree" sheet, create headers for the columns "Level 1", "Level 2", "Level 3", etc. up to the maximum number of levels in your folder paths. For example, if your folder paths have a maximum of 3 levels, create columns for "Level 1", "Level 2", and "Level 3". In the first cell of each co...
- Get link
- X
- Other Apps
By
Anandan M
-
async function getListItems(listUrl: string) { const apiUrl = `${listUrl}/items?$top=5000`; const items = []; let skipToken = null; do { const url = skipToken ? `${apiUrl}&$skiptoken=${encodeURIComponent(skipToken)}` : apiUrl; const response = await fetch(url, { headers: { Accept: "application/json;odata=nometadata" } }); const data = await response.json(); items.push(...data.value); skipToken = data["@odata.nextLink"] ? data["@odata.nextLink"].split("&$skiptoken=")[1] : null; } while (skipToken); return items; } const listUrl = "https://<your-site-url>/_api/web/lists/getByTitle('<your-list-title>')" ; const items = await getListItems(listUrl); const filteredItems = items. filter ( item => { return filters. every ( filter => item[filter. property ] ...