Uncategorized

Since 3.4, MongoDB now supports specifying collation, which basically means that sorting case insensitive can now be done by the DB natively.

Here’s how to do it in an example method:

public static MongoCursor getDatatableIterator(final String collection, final Bson query, Object sort, final Integer skip, final Integer limit) {
if (sort != null && !sort.getClass().equals(Bson.class)) {
sort = makeSortList(sort);
}
Collation caseInsensitive = Collation.builder().collationStrength(CollationStrength.SECONDARY).locale("en").build();
if (query == null) {
return getDocuments(collection).collation(caseInsensitive).sort((Bson)sort).skip(skip).limit(limit).iterator();
}
return getDocuments(collection).collation(caseInsensitive).sort((Bson)sort).filter(query).skip(skip).limit(limit).iterator();
}

 

Don’t want to have to import your root certificates in Firefox in addition to IE? With this setting you can just set Firefox to use Windows’ native certificate store. I seem to need to do this frequently, with all of my reinstalls of Firefox.

Go to Firefox, type about:config in the address bar and hit Enter, agree to the disclaimer, then search for
security.enterprise_roots.enabled and set it to True.

Recently I found myself migrating, again, my cloud hosting provider.  I like to keep a complete backup of all files so that in case I miss something it’s not forever lost in the ether.

This command comes in handy to rsync everything from one host to a backup location, which I can then use to migrate to the new cloud provider. This command skips the docker device mapper along with the other non-FS files in /dev /proc and /sys. Worked for me!

rsync -av --numeric-ids --exclude='/dev' --exclude='/proc' --exclude='/sys' --exclude='/var/lib/docker/devicemapper/' --progress --inplace --rsh='ssh -p22221' / [email protected]:/backups/backupdirectory

Enabling HSTS and SSL Redirection for Tomcat 9.x

This document details how to enable HSTS and SSL redirection (by default port 80 to 443) on a Tomcat 9.x instance. This will not work on 8.x versions of Tomcat because they changed some of the keywords for some reason.

Enable HSTS

Enabling HSTS (to include maxAgeSeconds = 31536000, includeSubDomains, and preload) requires two modifications of the Tomcat’s conf/web.xml file:
1. First, to enable HSTS support, Continue Reading

Merging directories in command line in Linux is a pain because the native mv command will not allow recursive overwriting.  So if we want to merge two directories, a lot of people like to suggest either using cp or rsync to copy over files and then delete the source files. Another way is to use a shell command to recursively run the move operation on each file in the source directory and mv it to the destination directory/subdirectory. I like this approach more because then you can add in arbitrary rules for which files to copy.
Continue Reading

You can use this SQL QUERY to find all the forms for the entities in your CRM database. If you keep having duplicate Quick Create or Information forms come up, you can just look at this and see which forms have duplicate Type forms.

SQL Query:
USE YOURORGHERE_MSCRM
SELECT form.Type, form.ObjectTypeCode, e.Name, form.Name, IsDefault, form.IsCustomizable, form.PublishedOn, form.IntroducedVersion
FROM SystemForm as form
INNER JOIN Entity e ON form.ObjectTypeCode = e.ObjectTypeCode
WHERE FormPresentation = 1 AND FormActivationState = 1 AND Form.CanBeDeleted = 1 AND form.IsManaged = 0 -- just get unmanaged ones
ORDER BY form.ObjectTypeCode DESC

Backstory:
I recently switched web hosts from Digital Ocean to OVH. I decided to go the Docker route and hopefully make migration less of a pain in the future. I run 4 websites off of the host, 3 of which are WordPress and 1 Koken site for photography. I don’t think it was less of a pain to do this, but I had to finish it once I started it.

Continue Reading

Go directly to Customizations page in new window:
javascript:window.open($(‘#crmContentPanel iframe:not([style*=\”visibility: hidden\”])’)[0].contentWindow.Xrm.Page.context.getClientUrl() + “/tools/solution/edit.aspx?id=%7bfd140aaf-4df4-11dd-bd17-0019b9312238%7d#”);

Go to Solutions in new window:
javascript:window.open($(‘#crmContentPanel iframe:not([style*=\”visibility: hidden\”])’)[0].contentWindow.Xrm.Page.context.getClientUrl() + “/main.aspx?Origin=Portal&page=Settings&area=nav_solution”);

Go to Security in new window:
javascript:debugger;window.open($(‘#crmContentPanel iframe:not([style*=\”visibility: hidden\”])’)[0].contentWindow.Xrm.Page.context.getClientUrl() + “/tools/AdminSecurity/adminsecurity_area.aspx”);

Get a Solution’s Dependencies in new window:
javascript: try { var cont = frames[1] || frames[0]; window.open(cont.Xrm.Page.context.getClientUrl() + “/tools/dependency/dependencyviewdialog.aspx?objectid=” + cont.APP_SOLUTION_ID.substring(1,37) + “&objecttype=7100&operationtype=dependenciesforuninstall”); } catch (e) { if (console && console.log) { console.log(“Error occured: ” + e); }}

Get a Record’s ID:
javascript:var thisXrm; for (var i = 0; i<5; i++) { try {var wf = window.frames; if (wf[i] && wf[i].Xrm && wf[i].Xrm.Page && wf[i].Xrm.Page.data != null) {thisXrm = wf[0].Xrm; var id = thisXrm.Page.data.entity.getId(); if (id) { clipboardData.setData(“Text”, id.toString()); alert(id); } else { alert(‘No id yet!’); } }} catch (e) { }}

Get a form’s type code:
javascript: var typeCode = frames[0].Xrm.Page.context.getQueryStringParameters().etc; if (typeCode) { clipboardData.setData(“Text”, typeCode.toString()); alert(typeCode); }

Setting a value on a rollup field is impossible in JavaScript in CRM 2015. You can’t refresh the field individually without clicking the Refresh button — which can be a pain for users if you have several rollup fields to recalculate.

function setValueOnRollup(field, value) {
//unsupported way of putting a value in the calculated field
//DOES NOT update the value in CRM, only on the display
$('#' + field).find('.rollup').find('span')[0].textContent = value;
}

So if you wanted to use it on a form, put setValueOnRollup(‘yourfieldhere’, ‘100.00’)

It’s best used when you have the values you want to show (preferably the real values) which can be retrieved with a query you can make with CRM REST Builder (https://crmrestbuilder.codeplex.com/).

These also might come in handy to manage the rollups and processes:

Process.js – CRM 2013/2015 Call Action, Workflow, or Dialog from JavaScript (https://processjs.codeplex.com/) is a cool tool to run a process from your custom JavaScript.

Dynamics CRM 2016 Workflow Tools (https://msdyncrmworkflowtools.codeplex.com/), specifically the “Force Calculate Rollup Field” feature to update the value in CRM.