Skip to content

Commit

Permalink
Merge pull request #1479 from martinlingstuyl/fix-taxonomy-field-issue
Browse files Browse the repository at this point in the history
Fixes DynamicForm trying to load TaxonomyFields with wrong display name. Closes #1422
  • Loading branch information
joelfmrodrigues committed Mar 1, 2023
2 parents d20134a + 8c2f768 commit cd5a9ef
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/controls/dynamicForm/DynamicForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ export class DynamicForm extends React.Component<IDynamicFormProps, IDynamicForm
defaultValue = [];
}
} else if (fieldType === "TaxonomyFieldTypeMulti") {
const response = await this._spService.getTaxonomyFieldInternalName(this.props.listId, field.InternalName, this.webURL);
const response = await this._spService.getTaxonomyFieldInternalName(this.props.listId, field.TextField, this.webURL);
hiddenName = response.value;
termSetId = field.TermSetId;
anchorId = field.AnchorId;
Expand Down
4 changes: 2 additions & 2 deletions src/services/SPService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -578,10 +578,10 @@ export default class SPService implements ISPService {
}
}

public async getTaxonomyFieldInternalName(listId: string, fieldName: string, webUrl?: string): Promise<any> { // eslint-disable-line @typescript-eslint/no-explicit-any
public async getTaxonomyFieldInternalName(listId: string, fieldId: string, webUrl?: string): Promise<any> { // eslint-disable-line @typescript-eslint/no-explicit-any
try {
const webAbsoluteUrl = !webUrl ? this._context.pageContext.web.absoluteUrl : webUrl;
const apiUrl = `${webAbsoluteUrl}/_api/web/lists(@listId)/Fields/getByInternalNameOrTitle('${fieldName}_0')/InternalName?@listId=guid'${encodeURIComponent(listId)}'`;
const apiUrl = `${webAbsoluteUrl}/_api/web/lists(@listId)/Fields/getById(guid'${fieldId}')/InternalName?@listId=guid'${encodeURIComponent(listId)}'`;

const data = await this._context.spHttpClient.get(apiUrl, SPHttpClient.configurations.v1);
if (data.ok) {
Expand Down

0 comments on commit cd5a9ef

Please sign in to comment.