what about EntityReferenceFactory method?

Mar 29, 2012 at 10:13 AM

Hi,

 

could you explain hte usage of EntityReferenceFactory method?

 

Thanks,

 

Vince

Coordinator
Mar 29, 2012 at 4:09 PM

Hi, 

this util-method helps you when you need to populate a "EntityReference" property. 

Instead of creating an object with the meta-data property set you could use this util-methode:

// demo_ParentSegmentId is a EntityReference
var entity = {
    'demo_name': segment.Description,
    'demo_ParentSegmentId': CrmRestKit.EntityReferenceFactory(parentSegmentId),
    'demo_Code': 12
};

// without the util-method
var entity = {
    'demo_name': segment.Description,
    'demo_ParentSegmentId': { Id: parentSegmentId, __metadata: { type: "Microsoft.Crm.Sdk.Data.Services.EntityReference" } },
    'demo_Code': 12
};

Hope this makes sense

 

Daniel