Wednesday, March 20, 2019

Upload Attachment to SharePoint Site List Item

Application Form Window

Replace "Tab Character" in Excel Active Sheet

TAB - horizontal tab Decimal Value is 9


Private Sub Workbook_SheetActivate(ByVal Sh As Object)
Dim lRow As Long
Dim lCol As Long
   
    'Find the last non-blank cell in column A(1)
    lRow = Cells(Rows.Count, 1).End(xlUp).Row
   
    'Find the last non-blank cell in row 1
    lCol = Cells(1, Columns.Count).End(xlToLeft).Column

For i = 1 To lRow
    For j = 1 To lCol
        t = Cells(i, j).Value
        If (Len(t) > 0) Then
            If (Asc(Left(t, 1)) = 9) Then
                str1 = Mid(t, 2, Len(t))
                Cells(i, j).Value = str1
            End If
        End If
    Next
Next

End Sub

Thursday, March 14, 2019

Rest API to check field value contains...

[site url]/_api/Web/Lists/GetByTitle('myList')/items/?$filter=substringof('ABC',Title)

Filter Unique Value in Array


var items = ['abc','pqr','abc','xyz','pqr','abc'];
var result = items.filter(UniqueElement); 

//result ['abc', 'pqr','xyz']


function UniqueElement(value, index, self) { 
    return self.indexOf(value) === index;
}

Saturday, March 9, 2019

Simple way to Check if JSON is correct or not..

function IsJsonString(str) {
    try {
        JSON.parse(str);
    } catch (e) {
        return false;
    }
    return true;
}

Remove control characters from a string

function removeCC(s) {
  /* Remove NewLine, Carriage Return and Tab characters from a String  */

  r = "";
  for (i=0; i < s.length; i++) {
    if (s.charAt(i) != '\n' &&
        s.charAt(i) != '\r' &&
        s.charAt(i) != '\t') {
      r += s.charAt(i);
      }
    }
  return r;
  }

Same thing with regular expression


function removeCC(s){ 
  return s.replace(/[\n\r\t]/g," "); 
}

Friday, March 1, 2019

Custom button in DataTable

DataTable Example:

(1)Add custom button

"buttons": [{"text": ' Custom Button',
        "action": function () {
                                alert("Custom Button Clicked");
}
        },
]


(2) Button Menu

"buttons":[
                {
                extend: 'collection',
                text: 'Menu',
                className: "menuMain",
                autoClose: true,
                buttons: [
                    {
                        text: 'Item 1',
                        action: function () {
                            alert("Item 1 Selected");
                        }
                    },
                    {
                        text: 'Item 2',
                        action: function () {
                            alert("Item 2 Selected");
                        }
                    }
                ]                           
                             },
                  ]