SharePoint 2010: Set field value from query triggered by choice box selection

别来无恙 提交于 2019-12-23 04:30:56

问题


How do you link a form field to a choicebox selection so that the field's value is set by the information referenced by the ID of the choicebox selection? I have a choicebox in a custom list form which is bound to a "Client" list which contains client names, IDs, reference numbers, addresses, etc. The choicebox displays the client name and has the selected value set to ID. I would then like to query the Client list by the selected ID to populate form fields with Client Name, Client Address, Client Phone, etc. Is there a way to do this without using custom code? I am using SharePoint 2010, SharePoint Designer 2010 and InfoPath for the forms.


回答1:


I have a feeling this is not supported, but I was able to get this working by creating fields as follows in the schema.xml of my custom list template:

<Field ID="{AB09A2D6-EBD4-4511-AE91-A8C54DC8442F}"
    Type="Lookup"
    Name="CustomItemIdLookup"
    DisplayName="Client"
    List="$Resources:core,lists_Folder;/Client"
    ShowField="Title"
    Hidden="FALSE"
    Required="TRUE"
    StaticName="CustomItemIdLookup">
</Field>
<Field ID="{E558933C-A03B-4932-85C9-6A786396AA78}"
    Type="Lookup"
    Name="CustomClientNameLookup"
    DisplayName="Client Name"
    List="$Resources:core,lists_Folder;/Client"
    ShowField="CustomClientName"
    Hidden="FALSE"
    JoinColName="tp_ID"
    JoinRowOrdinal="0"
    JoinType="INNER"
    FieldRef="CustomItemIdLookup"
    ReadOnly="FALSE"
    ShowInNewForm="FALSE"
    ShowInEditForm="FALSE">
</Field>
<Field ID="{5292CB52-80C7-4AFA-BA3E-93FDF22B37E3}"
    Type="Lookup"
    Name="CustomClientAddressLookup"
    DisplayName="Client Address"
    List="$Resources:core,lists_Folder;/Client"
    ShowField="CustomClientAddress"
    Hidden="FALSE"
    JoinColName="tp_ID"
    JoinRowOrdinal="0"
    JoinType="INNER"
    FieldRef="CustomItemIdLookup"
    ReadOnly="FALSE"
    ShowInNewForm="FALSE"
    ShowInEditForm="FALSE">
</Field>
<Field ID="{B3E22803-9A4B-4E7E-B05F-82221C182735}"
    Type="Lookup"
    Name="CustomClientPhoneLookup"
    DisplayName="Client Phone"
    List="$Resources:core,lists_Folder;/Client"
    ShowField="CustomClientPhone"
    Hidden="FALSE"
    JoinColName="tp_ID"
    JoinRowOrdinal="0"
    JoinType="INNER"
    FieldRef="CustomItemIdLookup"
    ReadOnly="FALSE"
    ShowInNewForm="FALSE"
    ShowInEditForm="FALSE">
</Field>

Note, Client Name, Client Address, Client Phone will not be editable and rich text/multiline fields do not work.



来源:https://stackoverflow.com/questions/2443551/sharepoint-2010-set-field-value-from-query-triggered-by-choice-box-selection

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!