Skip to content

Instantly share code, notes, and snippets.

Import-Module Microsoft.Xrm.Data.Powershell
$conn = Connect-CrmOnlineDiscovery -InteractiveMode
$req = New-Object Microsoft.Xrm.Sdk.OrganizationRequest
$req.RequestName = "RetrieveSolutionMetadataForComponent"
# Entity "account"
[string[]]$colNames = "entityid"
[string[]]$colValues = "70816501-edb9-4740-a16c-6a5efbc05d84"
declare @n char(1)
set @n = char(10)
declare @stmt nvarchar(max)
-- procedures
select @stmt = isnull( @stmt + @n, '' ) +
'drop procedure [' + schema_name(schema_id) + '].[' + name + ']'
from sys.procedures
@peta
peta / README.md
Last active October 30, 2018 09:47
Testcase: Bug in Dynamics CRM Web API (OData 4.x) for RetrieveMultiple by FetchXML

Description

While migrating some form logic which used to execute a FetchXML query and react to the result accordingly, from XrmServiceToolkit to the native OData Web API in 8.2, I encountered some weird platform behaviour. Everytime the LIKE filter condition contained a part of the number series 123456789 beginning at number 1 (like for example %123%), the OData service yields a 500 server error for no obvious reason.

Outcome

This bug was solved in latest 9.1 version (or earlier), event in the Web API endpoint version 8.1

Steps to reproduce

@peta
peta / url_regex.js
Last active October 24, 2018 15:18
var urlParseRegex = /^(?:(?:(([^:\/#\?]+:)?(?:(?:\/\/)(?:(?:(?:([^:@\/#\?]+)(?:\:([^:@\/#\?]*))?)@)?(([^:\/#\?\]\[]+|\[[^\/\]@#?]+\])(?:\:([0-9]+))?))?)?)?((?:\/?(?:[^\/\?#]+\/+)*)(?:[^\?#]*)))?(\?[^#]+)?)(#.*)?/;
var results = urlParseRegex.exec('http://user:[email protected]:81/directory/file.ext?query=1#anchor');
// Variable "results" now contains the fragments in the following order
var keysInOrderTheyAppear = [
"href", // http://user:[email protected]:81/directory/file.ext?query=1#anchor
"origin", // http://user:[email protected]:81
"protocol", // http:
"username", // user
@peta
peta / snippet.cs
Last active September 5, 2018 09:00
Automatically adjust batch-size in ExecuteMultipleRequests
public static IEnumerable<ExecuteMultipleResponse> RunMultipleRequestInSteps(ICrmConnection crmConnection, IEnumerable<OrganizationRequest> organizationRequestList, ExecuteMultipleRequest executeMultipleRequest, bool retryOnBatchSizeLimit = true)
{
// Calculate totalElements, elementToProcess and steps
var totalElements = organizationRequestList.Count();
var steps = (totalElements <= MaxBatchRequestSize) ? 1 : Math.Ceiling((double) totalElements / MaxBatchRequestSize);
var responseList = new List<ExecuteMultipleResponse>();
for (int i = 0; i < steps; i++)
{
// Get current requests to process
using Microsoft.Xrm.Sdk;
namespace Foo.CRM.Integration.Data.Helper
{
public static class XrmSdkExtensions
{
/// <summary>
/// Retrieve formatted value for given key and optionally return default value when key was not found in collection. This method will
/// not yield any exceptions when a requested key was not found.
/// </summary>
@peta
peta / example-1.js
Created March 14, 2018 10:13
Some random examples showing simple JavaScript Promise usage patterns, I wrote together during a frontend dev course I gave back in 2015
// Example 1 -- Prom-what??!#
//===== Callback-style
// Nested async foo as we know and love it
// Output from previous async call becomes input of the one called next
giveBirthTo(function (peter) {
growUp(peter, function (grownUpPeter) {
travelTheWorld(grownUpPeter, function (culturedPeter) {
marryAndHaveKids(culturedPeter, function (seniorPeter) {
@peta
peta / gist-test.sparql
Created January 21, 2015 21:33
Gist linguist test
#QUERY <http://localhost:9090/test-rdf-fuseki/query>
#UPDATE <http://localhost:9090/test-rdf-fuseki/update>
PREFIX : <urn:example#>
INSERT DATA {
:instDefault :theLabel 'Hello from DEFAULT graph'
GRAPH :graph1 { :instDefault1 :theLabel 'Hello from graph1'. :instDefault1b :theLabel 'Hello from graph1'. }
GRAPH :graph2 { :instDefault2 :theLabel 'Hello from graph2'. :instDefault2b :theLabel 'Hello from graph1'.}
GRAPH :graph3 { :instDefault3 :theLabel 'Hello from graph3'. :instDefault3b :theLabel 'Hello from graph1'.}
@peta
peta / random-poweredby.js
Created July 17, 2014 18:51
Lustige Powered-By-Fußnote von der-postillon.com
// easter-egg
(function() {
var $random = $('#campudus-random');
var $randomClick = $('#campudus-random-click');
var a = [ 'attraktiven', 'beliebten', 'bescheidenen', 'coolen', 'epischen', 'erfahrenen', 'fröhlichen', 'guten', 'gnädigen', 'humorvollen', 'kaputten', 'klaustrophobischen', 'liebevollen', 'multidimensionalen', 'prämierten', 'tollen', 'verdorbenen', 'verschrobenen', 'zauberhaften' ];
var b = [ 'Designer', 'Freunde', 'Gorillas', 'Helden', 'Jungs', 'Kids', 'Kellerkinder', 'Knacker', 'Kollegen', 'Krieger', 'Männer', 'Nerds', 'Ninjas', 'Opas', 'Roboter', 'Tiere', 'Programmierer', 'Zauberer', 'Zebras' ];
$randomClick.click(function(e) {
$random.text(a[Math.floor(Math.random()*a.length)] + ' ' + b[Math.floor(Math.random()*b.length)]);
});
@peta
peta / dhcpd.conf
Created April 1, 2014 00:33
[blog] VMware Fusion configuration files
# Configuration file for ISC 2.0 vmnet-dhcpd operating on vmnet8.
#
# This file was automatically generated by the VMware configuration program.
# See Instructions below if you want to modify it.
#
# We set domain-name-servers to make some DHCP clients happy
# (dhclient as configured in SuSE, TurboLinux, etc.).
# We also supply a domain name to make pump (Red Hat 6.x) happy.
#