Search

LookupProperty in a plugin

 

This is the code to create a lookup property for my custom entity

Lookup salesPersonLookup = new Lookup(“new_salesperson”, crmkey.Value);
LookupProperty lookupProperty = new LookupProperty(“new_salespersonid”, salesPersonLookup);

first you need to create a lookup, this has the syntax of

new Lookup(“entity name”, guid of entity to lookup) 

then you need to add the lookup into a LookupProperty

new LookupProperty(“field name”, Lookup) 

You then add this property to your property bag and you will be able to update that property