0

I'm working on a SharePoint Add In and some list provisioning code. I want to add a Person column to my list. I searched the docs and came up short.

list.get_fields().addFieldAsXml('<Field DisplayName="Responsible" Type="Lookup" List="?" Required="TRUE" Name="User" />', true, SP.AddFieldOptions.defaultValue);

The list would be kept in the host web, not the app web.

1 Answer 1

0

To add lookup column we have to specify list/library URL. like, List="lists/Country" or List="Share Documents". Please make sure for provisioning lookup column you have to set below parameter value.

<Field 
    ID="{0dd154e3-a30e-44ca-a158-c8808afd2327}" 
    Name="Responsible" 
    StaticName="Responsible"        
    DisplayName="Responsible" 
    Type="Lookup" 
    List="{Provide list Url}" 
    ShowField="{lookup field name}"
    Required="FALSE" 
    Group="Custom column" />

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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