<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 July, 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...