Skip to content

Instantly share code, notes, and snippets.

View IAMIronmanSam's full-sized avatar
🎯
Focusing

Tony Stark IAMIronmanSam

🎯
Focusing
View GitHub Profile
@IAMIronmanSam
IAMIronmanSam / CSOM.js
Last active June 20, 2023 14:30
CSOM to update and create & update list item
function CSOMOperations(columnData,listName,action,itemID){
var context = SP.ClientContext.get_current();
var web = context.get_web();
var list = web.get_lists();
var targetList = list.getByTitle(listName);
var item;
switch(action){
case 'create':
var listItemCreation = new SP.ListItemCreationInformation();
item = targetList.addItem(listItemCreation);
@IAMIronmanSam
IAMIronmanSam / stackModalDialog.js
Created June 6, 2016 21:42
Stack more than one bootstrap modal dialog
function stackBootstrapModal(){
$(document).on('show.bs.modal', '.modal', function (event) {
var zIndex = 1040 + (10 * $('.modal:visible').length);
$(this).css('z-index', zIndex);
setTimeout(function() {
$('.modal-backdrop').not('.modal-stack').css('z-index', zIndex - 1).addClass('modal-stack');
}, 0);
});
$(document).on('hidden.bs.modal', '.modal', function () {
$('.modal:visible').length && $(document.body).addClass('modal-open');
@IAMIronmanSam
IAMIronmanSam / userFieldInt.js
Created May 18, 2016 22:51
Intialize User field from Client side [Javascript]
// Render and initialize the client-side People Picker.
function initializePeoplePicker(peoplePickerElementId) {
// Create a schema to store picker properties, and set the properties.
var schema = {};
schema['PrincipalAccountType'] = 'User,DL,SecGroup,SPGroup';
schema['SearchPrincipalSource'] = 15;
schema['ResolvePrincipalSource'] = 15;
schema['AllowMultipleValues'] = true;
schema['MaximumEntitySuggestions'] = 50;
schema['Width'] = '280px';
@IAMIronmanSam
IAMIronmanSam / getUserProperties.js
Created May 10, 2016 07:56
Get complete user profile data by user email
function getUserInfo(alias){
$.ajax({
url: "/sites/_api/sp.userprofiles.peoplemanager/GetPropertiesFor(@v)?@v='"+encodeURIComponent('i:0#.f|membership|'+alias)+"'",
type: "GET",
headers: { "Accept": "application/json;odata=verbose" },
success: function(data) {
var dataResults = data.d;
debugger;
},
error: function (err) {
@IAMIronmanSam
IAMIronmanSam / clone.js
Last active March 16, 2016 16:51
Clone Div
// Do this on $(document).ready(function() { ... })
var divClone = $("#some_div").clone();
// Change the content temporarily
$("#some_div").html("Yeah all good mate!");
// Use this command if you want to keep divClone as a copy of "#some_div"
// Restore element with a copy of divClone
$("#some_div").replaceWith(divClone.clone());
@IAMIronmanSam
IAMIronmanSam / peoplePicker.aspx
Last active March 14, 2016 07:25
People Picker in custom aspx page
<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=16.0.0.0, Culture=neutral, PublicKeyToken=your page token here" %>
<asp:Content ContentPlaceHolderId="PlaceHolderMain" runat="server">
<fieldset>
<div class="form-group">
<label class="col-md-4 control-label" for="textinput">Owner</label>
<div class="col-lg-7">
<div class="input-group">
<SharePoint:ClientPeoplePicker
Required="true"
AllowEmailAddresses="true"
@IAMIronmanSam
IAMIronmanSam / getUserProperties.js
Last active March 10, 2016 13:52
Get User Profile data
var userProfileProperties = [];
function getUserProperties()
{
// Replace the placeholder value with the target user's credentials.
var targetUser = '[email protected]';
// Get the current client context and PeopleManager instance.
var clientContext = new SP.ClientContext.get_current();
var peopleManager = new SP.UserProfiles.PeopleManager(clientContext);
@IAMIronmanSam
IAMIronmanSam / sp-csom.js
Last active March 7, 2016 15:59
Create list item using CSOM
function createItemCSOM(listName){
var context = SP.ClientContext.get_current(); //gets the current context
var web = context.get_web();
var list = web.get_lists();
var targetList = list.getByTitle(listName);
var listItemCreation = new SP.ListItemCreationInformation();
var newItem = targetList.addItem(listItemCreation);
newItem.set_item("owner",SP.FieldUserValue.fromUser('[email protected]'));
newItem.update();
context.load(newItem);
@IAMIronmanSam
IAMIronmanSam / datatable_clear.js
Last active March 2, 2016 09:15
Clear & Destroy data table
//Re-Intialize datatable
var myTable = $('#result').DataTable({"destroy": true});
//Before Adding Data [if you dont want new data append to exisinting data]
myTable.clear();
@IAMIronmanSam
IAMIronmanSam / PlaceHolder.js
Created March 2, 2016 07:01
For browser which doesn't support HTML5
/*For browser which doesn't support HTML5*/
function placeHolderPolyFill(){
$("input[placeholder]").each(function () {
var $this = $(this);
if($this.val() == ""){
$this.val($this.attr("placeholder")).focus(function(){
if($this.val() == $this.attr("placeholder")) {
$this.val("");
}
}).blur(function(){