Zdenek Vais
Zdenek Vais

Reputation: 64

Microsoft CRM plugin - Lookup is missing its name

I'm working on a CRM 2011 plugin that should create new equipment entity with lookup to a vehicle entity:

var vehicle = (Entity)context.InputParameters["Target"];
var entity = new Entity("equipment");
// Fill other attributes

// Create lookup
var reference = vehicle.ToEntityReference();                 
entity.Attributes["new_vehiclelink"] = reference;
entity.Attributes["new_vehiclelinkname"] = name;

service.Create(equipment);

Equipment is created correctly unfortunately the lookup is missing its name.

When I click on the lookup it works. Please can you advice me how to fill its name?

Upvotes: 2

Views: 773

Answers (1)

Greg Owens
Greg Owens

Reputation: 3878

I suspect that your vehicle record has no value in its Primary Attribute (i.e. name). It is the Primary Attribute that gets displayed in the Lookup control.

I'm also unsure what this line is trying to do:

entity.Attributes["new_vehiclelinkname"] = name;

You don't need to set the name of the lookup value separately, so unless you have an additional attribute called new_vehiclelinkname then this is not necessary.

Upvotes: 3

Related Questions