1
votes

i am trying to create a lookup inside a Content type.

Here is what i wrote in my column definitions.

<Field ID="{B8AC7868-A34D-4F2E-A259-BE9EA6EA578A}" 
     Name="NewsCategory" 
     Required="FALSE"
     DisplayName="NewsCategory" 
     Type="Lookup" 
     List="ListCategory"
     FieldRef="Title"
     ShowField="Title"
     Group="MyCustomGroup"/>

Here is what i wrote inside the Content Type i want to attach the said column too.

<FieldRef ID="{B8AC7868-A34D-4F2E-A259-BE9EA6EA578A}"
Name="NewsCategory"DisplayName="NewsCategory" Required="FALSE" />

Then i went on the site and created a list called "ListCategory" and it has a Title and thats it.

For some reason i have having alot of trouble deploying, but when i finally get it to deploy i get an error while creating a page with the said content type. Is my definition good ?

Thanks for any help !!

2
Found it ! stackoverflow.com/questions/1295050/… thanks to this. I now need to know how to edit it.Dr.Denis McCracleJizz

2 Answers

0
votes

You need 2 files: VS > SP 2010 project > Add item > Content Type has this code:

    <?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <!-- Parent ContentType: Todos los Documentos CiaContentTypes\00TodosLosDocumentos) (0x01010038bd2600185840119dfa3fe0c7b8b3d9) -->
  <ContentType ID="0x01010038bd2600185840119dfa3fe0c7b8b3d9005146d39cd2cf4d51b7ee2fc54bbe3215"
               Name="Archivo Historico"
               Group="05 Gestión Operativa"
               Description="Archivo Histórico"
               Inherits="TRUE"
               Version="0">
    <FieldRefs>
      <FieldRef ID="{709E337A-3FEF-4C96-8B00-8CF6723C969A}" Name="Empty" DisplayName="Empty"/>
    </FieldRefs>
  </ContentType>
</Elements>

Second file: Add item > SP 2010 > Empty element has this code:

    <Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <Field
    Type="Text"
    Description="Breve Descricpción del documento"
    Required="TRUE"
    MaxLength="255"
    Group="Archivo Histórico"
    ID="{709E337A-3FEF-4C96-8B00-8CF6723C969A}"
    StaticName="Empty" Name="Empty" DisplayName="Empty">
  </Field>

</Elements>

Good luck, ALEX

Create unique GUID

Content Type IDs

Creating Content Types for SharePoint 2010 in Visual Studio 2010

0
votes
<Field
   ID="{bb7754dc-0b4a-4851-bd05-f5d289414855}"
   Name="CustomerNameLookup"
   DisplayName="Customer Name Lookup"
   Type="Lookup"
   Overwrite="TRUE"
   EnableLookup="TRUE"
   IsRelationship="TRUE"
   ReadOnly="FALSE"
   List="Lists/Customers"
   ShowField="CustomerName"
   Required="FALSE"       
   Group="HRM Custom Site Columns">

Above one was my site column which I was adding through VS 2012 for a custom content type.

LookupTarget listName = Lists/Customers
LookupTarget colName = CustomerName

It was available in site collection as well as in subsites. It worked well without WebId etc.