Skip to content

Commit

Permalink
Bugfix for issue pnp#1758
Browse files Browse the repository at this point in the history
Added missing references to webURL to service calls.
  • Loading branch information
IRRDC committed Feb 8, 2024
1 parent a089158 commit 45050da
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
12 changes: 7 additions & 5 deletions src/controls/dynamicForm/DynamicForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -915,11 +915,11 @@ export class DynamicForm extends React.Component<
try {

// Fetch form rendering information from SharePoint
const listInfo = await this._spService.getListFormRenderInfo(listId);
const listInfo = await this._spService.getListFormRenderInfo(listId, this.webURL);

// Fetch additional information about fields from SharePoint
// (Number fields for min and max values, and fields with validation)
const additionalInfo = await this._spService.getAdditionalListFormFieldInfo(listId);
const additionalInfo = await this._spService.getAdditionalListFormFieldInfo(listId, this.webURL);
const numberFields = additionalInfo.filter((f) => f.TypeAsString === "Number" || f.TypeAsString === "Currency");

// Build a dictionary of validation formulas and messages
Expand Down Expand Up @@ -1166,7 +1166,8 @@ export class DynamicForm extends React.Component<
const response = await this._spService.getSingleManagedMetadataLabel(
listId,
listItemId,
field.InternalName
field.InternalName,
this.webURL
);
if (response) {
selectedTags.push({
Expand Down Expand Up @@ -1233,7 +1234,7 @@ export class DynamicForm extends React.Component<
}

dateFormat = field.DateFormat || "DateOnly";
defaultDayOfWeek = (await this._spService.getRegionalWebSettings()).FirstDayOfWeek;
defaultDayOfWeek = (await this._spService.getRegionalWebSettings(this.webURL)).FirstDayOfWeek;
}

// Setup Thumbnail, Location and Boolean fields
Expand Down Expand Up @@ -1322,7 +1323,8 @@ export class DynamicForm extends React.Component<
listItemId,
file.fileName,
buffer,
undefined
undefined,
this.webURL
);
}
};
Expand Down
4 changes: 2 additions & 2 deletions src/services/SPService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -654,9 +654,9 @@ export default class SPService implements ISPService {
}
}

public async getSingleManagedMetadataLabel(listId: string, listItemId: number, fieldName: string): Promise<any> { // eslint-disable-line @typescript-eslint/no-explicit-any
public async getSingleManagedMetadataLabel(listId: string, listItemId: number, fieldName: string, webUrl?: string): Promise<any> { // eslint-disable-line @typescript-eslint/no-explicit-any
try {
const webAbsoluteUrl = this._context.pageContext.web.absoluteUrl;
const webAbsoluteUrl = !webUrl ? this._context.pageContext.web.absoluteUrl : webUrl;
const apiUrl = `${webAbsoluteUrl}/_api/web/lists(@listId)/RenderListDataAsStream?@listId=guid'${encodeURIComponent(listId)}'`;
const data = await this._context.spHttpClient.post(apiUrl, SPHttpClient.configurations.v1, {
body: JSON.stringify({
Expand Down

0 comments on commit 45050da

Please sign in to comment.