JavaScript

Call jQuery Functions from Dart

The standard documentation for Dart and JavaScript interoperability isn’t great. It refers to the ‘dart:js’ library which although works is a bit verbose to get things done.

For instance, to call a jQuery function, you would need

import 'dart:js';
 
...
context.callMethod(r'$', ['.some.class.selector']).callMethod('someFunction');
...

The dart team has since then released the js package with which you can simply call

import 'package:js/js.dart';
 
...
context.$('.some.class.selector').someFunction();
...

Basically native syntax. Of course you have to add it to the yaml and pub get again.

Validate and Format Addresses using Google API

Suppose you want to make some web app that lets users input addresses. I would be nice to

  1. Weed out minor misspelling
  2. Standardise format (proper capitalisation, abbreviated province/state or full name etc)
  3. Input in freeform but store civic number, street name, city etc separately
  4. Verify the address exists of course

Some governmental entities provide this information via public APIs but if you want a uniform service, why not use Google? Read More…

CRM 4.0 Read-Only / Disable / Hide Fields Based on Security Role

Suppose you want to make some fields editable for only some users in CRM forms, there is a great and simple MSDN blog that outlines how to do it.

Here’s a copy of ┬átheir code. Just change _roles and _fields to the fields’ names that you want to disable for _roles. Flip it around and enable it only for those users by changing line x to false.

Put it in your form’s onLoad event at Customization->your entity->Forms and Views->Form->Form Properties->Event, OnLoad->Edit Read More…

 Scroll to top