Skip to content

Instantly share code, notes, and snippets.

<script src="https://code.jquery.com/jquery-1.12.4.min.js" type="text/javascript"></script>
<script type="text/javascript">
function exportToExcel(){
var listName="CustomList";
$.ajax({
url: _spPageContextInfo.siteAbsoluteUrl + "/_api/web/lists/getByTitle('"+listName+"')/items",
type: "GET",
headers: {
"Accept": "application/json;odata=verbose",
},
SELECT proj.PROJ_NAME AS ProjectName
,proj.PROJ_UID as ProjectUID
,CT.Customer
,PCC.CostCenter
,PP.ProjectAccount
,pr_owner.RES_NAME AS ProjectOwner
,pr_owner.RES_UID as OwnerResourceNameUID
,CASE WHEN PPS.ProjectStatus IS NULL THEN 'Undefined' ELSE PPS.ProjectStatus END AS ProjectStatus
FROM (SELECT PROJ_UID
,PROJ_NAME
@tayram
tayram / BuildTeamPWA.js
Created July 27, 2023 19:26
PWA - Project Online - Build Team - Resources
//From Jimecox CSC-O365 Repo.
Below is my code which is not working . Please suggest alternate solution
function ChangeProject() {
var projContext= PS.ProjectContext.get_current();
var targetGuid = "fa3c752c-17cf-e511-80cd-00155d1c3214";
@tayram
tayram / SharepointModalPopup.js
Created July 11, 2023 13:14
Sharepoint Alter Modal Popup Pop-up
<html>
<head>
<script type="text/javascript" src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<style>
.hidden {
display: none;
}
</style>
</head>
<body>
@tayram
tayram / UserGroupRESTsharepoint.js
Created July 11, 2023 13:13
Check is specific User exists in a Group - REST - Sharepoint
function getCurrentUserSPMembershipGroups(groupnames, condition, callback) {
var checkUserInGroupsString = groupnames;
var checkUserInGroupsArray = checkUserInGroupsString.split(";");
var conditionToCheck = condition.toUpperCase();
var clientContext = new SP.ClientContext.get_current();
var currentUser = clientContext.get_web().get_currentUser();
clientContext.load(currentUser);
var userGroups = currentUser.get_groups();
clientContext.load(userGroups);
clientContext.executeQueryAsync(
@tayram
tayram / SPOendpointsREST.txt
Created July 11, 2023 12:56
REST api notes - Sharepoint endpoints
SharePoint-RESTAPIs-Collection
To get files in a folder
{SharePointSiteURL}/_api/web/GetFolderByServerRelativeUrl('DocumentsLibraryDisplayName/FolderName')?$expand=Folders,Files
To get all Lists and Libraries in a Site using _vti_bin/listdata.svc
{SharePointSiteURL}/_vti_bin/listdata.svc
@tayram
tayram / listItemAttachmentsSPO.js
Created July 11, 2023 12:54
Get List Item - Attachments (JS)
function getListItemAttachments(){
//use _spPageContextInfo.webAbsoluteUrl for dynamic site URL
var listtitle = "Entry";
var itemID = $("#ListItemID").val();
var currentSiteURLPath = "";
var webUrl = "";
if(itemID){
try {
webUrl = _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/GetByTitle('" + listtitle + "')/items('" + itemID + "')/AttachmentFiles";
}
@tayram
tayram / SharepointRenderPDF.js
Created June 30, 2023 15:14
Sharepoint Render PDF
$(document).ready(function(){
var linkToPdf = "";
var endpointUrl = _spPageContextInfo.webServerRelativeUrl + "/_api/web/Lists(guid'01c8ab2b-f1f0-4087-9765-a593a6a7750c')/Items?$filter=Category%20eq%20%27Bimonthly%20Safety%20Newsletter%27";
getJson(endpointUrl)
.done(function(data){
var itemsCount= data.d.results.length;
var items = data.d.results;
var itemFileURI = items[itemsCount-1].File.__deferred.uri;
getJson(itemFileURI).done(function(data){
linkToPdf = data.d.ServerRelativeUrl;
@tayram
tayram / HideFieldsBasedOnProjectStatus.js
Created June 30, 2023 15:12
Hide Form Fields depending on the Project Status value
<script src="/SiteAssets/js/jquery.min.js"></script>
<script>
$(document).ready(function(){
function hideShowElems(){
var fieldsToHide = ["Start Date", "Original End Date", "Original IT Effort", "Original IT Effort",
"Estimated IT Effort To Complete", "Project Cost", "IT Team Members", "Business Team Members", "Contractor Involvement"];
var projStatus = $(".ms-RadioText > input:eq(0)").is(':checked');
var formLabel = $(".ms-formtable tbody tr td.ms-formlabel span.ms-h3.ms-standardheader");
if(projStatus == true){
formLabel.each(function(){