MS Flow tips

Admin page: https://admin.flow.microsoft.com

 

Compare date with today in SQL Query:

select [UserId],[FullName],[MissingDays] from raw.tidsoptimists where CONVERT(varchar, RecordedDate, 23) = CONVERT(varchar, getdate(), 23)

Convert to JSON: Remember to use “Use sample payload to generate schema” to get Schema

Get current date (use expression):

utcNow(‘yyyy-MM-dd’)
Get JSON result as table (add a new step and use result from parse JSON step, then you will be able to see the result as table (including all rows)):
@{body(‘JSON_for_Tids_Optimists’)?[‘ResultSets’]?[‘Table1’]}
Find DateIff from today with another date in SQL Query:
SELECT DATEDIFF (day, CONVERT(date, ‘@{items(‘Apply_to_each_2’)?[‘Year’]}-@{items(‘Apply_to_each_2’)?[‘Month’]}-01′), GetDate()) AS TodayDiff
Get TodayDiff above:
1. Parse to JSON
2. Take value from JSON like this:
first(body(‘JSON_DateDiff’)?[‘ResultSets’]?[‘Table1’])?[‘TodayDiff’]
3. You can also compare it with another number, such as:
greater(first(body(‘JSON_DateDiff’)?[‘ResultSets’]?[‘Table1’])?[‘TodayDiff’], 35)
.

 

 

java script helper

Measure loading time of the page:
var loadTime = window.performance.timing.domContentLoadedEventEnd-window.performance.timing.navigationStart;
loadTime
function toCamel(o, khet=false) {
  var newO, origKey, newKey, value
  if (o instanceof Array) {
    return o.map(function(value) {
        if (typeof value === "object") {
          value = toCamel(value)
        }
        return value
    })
  } else {
    newO = {}
    for (origKey in o) {
      if (o.hasOwnProperty(origKey)) {
        newKey = (origKey.charAt(0).toLowerCase() + origKey.slice(1) || origKey).toString()
        value = o[origKey]
        if (value instanceof Array || (value !== null && value.constructor === Object)) {
          value = toCamel(value)
        }
        newO[newKey] = value
      }
    }
  }
  return newO
}