Skip to content

Instantly share code, notes, and snippets.

View AshV's full-sized avatar
🌴
Coding @ Maldives Beaches

Ashish Vishwakarma AshV

🌴
Coding @ Maldives Beaches
View GitHub Profile
@AshV
AshV / Convert File to base64.markdown
Created April 10, 2016 09:46
Convert File to base64
@AshV
AshV / AngularJS ng-repeat with search.markdown
Created April 10, 2016 11:09
AngularJS ng-repeat with search

AngularJS ng-repeat with search

AngularJS lets you easily do a instant search if you say save your data as JSON. The elegant way that it is coded and the performance I find great. The JSON data I use, I have collected from Danish streaming TV service YouBio. I use bootstrap 3 to control the markup/layout.

Forked from Sten Hougaard's Pen AngularJS ng-repeat with search.

A Pen by Ashish Vishwakarma on CodePen.

License.

@AshV
AshV / fetchxml-to-c-js-formatter.markdown
Last active November 25, 2016 19:07
FetchXML to C# & JS Formatter
@AshV
AshV / index.html
Created February 9, 2017 07:14
replaceAll() in JavaScript
<b>1. Use Fail-Safe </b>
<br/> Using more replace() in chain than expected occurrences, this will not harm in anyway but it is not a good practice if because no. of occurrence is not predictable
<br/>
<b>Output : </b>
<div id="UseFailSafe"></div>
<br/>
<hr/>
<b>2. split() join() combination</b>
<br/> This approach will work for any number of occurrences, but more performance costly
@AshV
AshV / SetLookupViewByName.js
Last active December 10, 2018 19:10
Set Lookup View dynamically with JavaScript [ Dynamics CRM / 365 ]
// https://www.ashishvishwakarma.com/set-lookup-view-with-javascript-dynamics-crm-365/
function formOnLoad() {
setLookupViewByName("parentaccountid", "Customers", true);
}
function setLookupViewByName(fieldName, viewName, asynchronous) {
var req = new XMLHttpRequest();
req.open("GET", Xrm.Page.context.getClientUrl() + "/api/data/v8.2/savedqueries?$select=savedqueryid&$filter=name eq '" + viewName + "'", asynchronous);
req.setRequestHeader("OData-MaxVersion", "4.0");
// https://stackoverflow.com/questions/1879395/how-do-i-generate-a-stream-from-a-string
public static Stream GenerateStreamFromString(string s)
{
MemoryStream stream = new MemoryStream();
StreamWriter writer = new StreamWriter(stream);
writer.Write(s);
writer.Flush();
stream.Position = 0;
return stream;
}
@AshV
AshV / Execute-fetchXML-using-WebAPI-Dynamics-365.html
Created June 25, 2018 21:04
Execute fetchXML with WebAPI in Dynamics 365
<!DOCTYPE html>
<html>
<head>
<title>Execute fetchXML with WebAPI in Dynamics 365 using JavaScript</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/milligram/1.3.0/milligram.min.css" integrity="sha256-Ro/wP8uUi8LR71kwIdilf78atpu8bTEwrK5ZotZo+Zc=" crossorigin="anonymous" />
<style> button { width:100% } </style>
</head>
<body>
<h1>Testing : Execute fetchXML with WebAPI in Dynamics 365 using JavaScript</h1>
<button onclick="GetXHR()" id="GetXHR">Test using GET with XMLHttpRequest</button>
Xrm.WebApi.retrieveRecord(
"msdyncrm_customerjourney",
"945a02a0-b2db-e811-a967-000d3af29269",
"$select=msdyncrm_workflowdefinition").then(
function (result) {
debugger;
console.log(result);
var workflowdefinition = JSON.parse(result.msdyncrm_workflowdefinition);
// Retrieve nodes related to provided component.
@AshV
AshV / Microsoft-Dynamics-365-Server-2-Server-Authentication-Access-Token.cs
Created December 17, 2018 07:25
Microsoft-Dynamics-365-Server-2-Server-Authentication-Access-Token.cs
/// Required-Namespaces
using Microsoft.IdentityModel.Clients.ActiveDirectory;
using System.Threading.Tasks;
/// Method-to-generate-Access-Token
public static async Task<string> AccessTokenGenerator()
{
string clientId = "Azure AD App Id";
string clientSecret = "Client Secret Generated for App";
string authority = "https://login.microsoftonline.com/< your app tenant guid >";
@AshV
AshV / email.json
Last active December 24, 2018 10:58
Email with CRM records available or without(directly using email Id) | Microsoft Dynamics 365 Sample
{
"regardingobjectid_contact@odata.bind": "/contacts(<regarding contact record guid>)",
"subject": "Email Subject",
"description": "Email Description",
"email_activity_parties": [
{
"partyid_systemuser@odata.bind": "/systemusers(<from system user record guid>)",
"participationtypemask": 1
},
{