1

I want to create a lookup field with the sharepoint ui which points to a field with a custom field type (parent field type is number). In visual studio with the object model this is not a problem but in the sharepoint ui i can't choos the field from the "in this column" drop down field.

Maybe someone can help

1

Unfortunately, it is not possible to create lookup where you have a Custom Field Type as a target field.

Basic reflector exploration leads to the following code:

      if (field.Type == SPFieldType.Counter || field.Type == SPFieldType.Text || (field.Type == SPFieldType.Number || field.Type == SPFieldType.DateTime) || (field.Type == SPFieldType.Computed && ((SPFieldComputed) field).EnableLookup || field.Type == SPFieldType.Calculated && ((SPFieldCalculated) field).OutputType == SPFieldType.Text))
        // ...

Thus, you can use only the following field types as a target for a lookup field:

  1. Counter (usually ID field)
  2. Text (Single line of text)
  3. Number
  4. DateTime
  5. Computed (only if SPFieldComputed.EnableLookups is set to true)
  6. Calculated (only if it's Output type is equal to Text)

And even using the SharePoint object model, most likely, you will get an exception if you try to create Lookup field with target field of the "forbidden" type.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.