Tuesday, June 18, 2019

How to use Filter with JSON Data

// JSON Data

var jd = JSON.parse('[{"status":"Pass","Marks":98,"subject":"English"},{"status":"Pass","Marks":99,"subject":"Math"},{"status":"Fail","Marks":32,"subject":"Science"},{"status":"Fail","Marks":30,"subject":"History"},{"status":"Pass","Marks":95,"subject":"Computer"}]')


// use filter property to get each item with the condition match as Status as PASS (we are using === to validate they type and return if condition get true.)

var fd = jd.filter(function(item){
      return (item.status === "Pass");
});

result will be.

fd = [{"status":"Pass","Marks":98,"subject":"English"},{"status":"Pass","Marks":99,"subject":"Math"},{"status":"Pass","Marks":95,"subject":"Computer"}]

Tuesday, June 11, 2019

Integer value with leading zero using JavaScript



prefix_zero(10,4) // output 0010

function prefix_zero(num, size) {
    var s = num+"";
    while (s.length < size) s = "0" + s;
    return s;
}


Tuesday, May 28, 2019

10 Excel Skills and Top 10 Sites

10 Excel Skills that can help you analyze data like a pro:
  1. Sparkline
  2. Power Pivots
  3. Conditional Formatting
  4. Text Formulas
  5. Slicers
  6. Flash Fill
  7. Charts
  8. Vlookup
  9. IF Formulas
  10. Quick Analysis

Thursday, May 16, 2019

SharePoint Designer 2010 - Set Variable [Today]-x Days



To set a DateTime field to [Today] + 5 days using a SharePoint Designer 2010 Workflow, this is what I did:


1) Create a Local Variable (ETA Date) of type Number
2) Use a Do Calculation task in the workflow and set:

value: Workflow Context:Date and Time Last Run (As Double)
operation: plus
value: 432000 (number of seconds in 5 days or 60*60*24*5)
Output to: Variable: ETA Date


3) Finally, set the value of the respective field of the current item to the ETA Date variable
In your case, use the subtract operation and the second value is 2419200 (60*60*24*28).


Note: Compare the Date in Workflow, Current Item:ReminderDate equals (ignoring time) Today


Reference Link

Friday, May 10, 2019

Handel Multiple Click on Elements JQuery

I have experience that user on the page try to click multiple time on the button, in case of page delay, this is a short way to handle such issue.


This will remove all event handlers:

$(element).off().on('click', function() {
    // function body
});

To only remove registered 'click' event handlers:

$(element).off('click').on('click', function() {
    // function body
});

Wednesday, May 8, 2019

Send E-mail from javascript using REST API - SharePoint

In SharePoint 2013 we can send emails using REST API where we can utilize SP.Utilities.Utility.SendEmail for doing the job. 

Note: The recipient is limited to a valid SharePoint user for security reasons.



Note: You can add 'CC' and 'BCC' property also to send email, property 'results' having array.

Friday, April 5, 2019

Remove a specific class from all child elements, and add new class



$('#parentDiv').find("*").removeClass("old-class").addClass("new-class");