Elegant way to set a lookup – XrmMtl Skip to content

Elegant way to set a lookup

Hi folks,

I found out an elegant way to set a lookup. Here’s the old way:

var lookup = new Array();
lookup[0] = new Object();
lookup[0].id = 'fc62d5f4-a589-452d-b134-aaa080c0d75a';
lookup[0].entityType = 'contact';
lookup[0].name = 'Nick Plourde';

Here’s the nicer way:

var lookup = [{
id: 'fc62d5f4-a589-452d-b134-aaa080c0d75a',
entityType: 'contact',
name: 'Nick Plourde',
type: 'lookup'

And don’t forget you can still do this:


That’s all!

Published inJavascript