Skip to content

Commit 7fb036d

Browse files
Merge pull request #24 from BeverCRM/feature/error
fixed bugs related to "error message" and "column width"
2 parents b383508 + 7baec11 commit 7fb036d

File tree

4 files changed

+14
-16
lines changed

4 files changed

+14
-16
lines changed

FetchToSubgrid/services/dataverseService.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,7 @@ export class DataverseService implements IDataverseService {
102102
const formParameters: { [key: string]: string } =
103103
{ [relationship.ReferencingAttribute]: JSON.stringify(lookup) };
104104

105-
this._context.navigation.openForm({ entityName }, formParameters)
106-
.then((success: unknown) => console.log(success))
107-
.catch((error: unknown) => console.log(error));
105+
this._context.navigation.openForm({ entityName }, formParameters);
108106
}
109107
else {
110108
this._context.navigation.openForm({ entityName });
@@ -176,7 +174,7 @@ export class DataverseService implements IDataverseService {
176174
fetch?.removeAttribute('count');
177175
fetch?.removeAttribute('page');
178176

179-
fetch.setAttribute('page', `${page}`);
177+
fetch?.setAttribute('page', `${page}`);
180178

181179
const serializer = new XMLSerializer();
182180
return serializer.serializeToString(xmlDoc);

FetchToSubgrid/utilities/d365Utils.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ const createColumnsForLinkEntity = (
7878
changedAliasNames, attr, index, i, linkEntityName);
7979

8080
const columnName: string = attr.attributeAlias ||
81-
linkentityMetadata[i].Attributes._collection[attr.name].DisplayName;
82-
const attributeType = linkentityMetadata[i].Attributes._collection[attr.name].AttributeType;
81+
linkentityMetadata[i].Attributes._collection[attr.name]?.DisplayName;
82+
const attributeType = linkentityMetadata[i].Attributes._collection[attr.name]?.AttributeType;
8383

8484
const isMultiselectPickList = attributeType === AttributeType.MultiselectPickList;
8585
const sortingIsAllowed = isMultiselectPickList || hasAggregate || changedAliasNames[index];
@@ -120,9 +120,9 @@ const createColumnsForEntity = (
120120

121121
let displayName = name === `${entityName}id`
122122
? 'Primary Key'
123-
: displayNameCollection[name].DisplayName;
123+
: displayNameCollection[name]?.DisplayName;
124124

125-
const attributeType: number = displayNameCollection[name].AttributeType;
125+
const attributeType: number = displayNameCollection[name]?.AttributeType;
126126
const hasAggregate: boolean = isAggregate(fetchXml ?? '');
127127
const aliasNames: string[] | null = getFetchXmlAttributesData(fetchXml, false);
128128
const isMultiselectPickList = attributeType === AttributeType.MultiselectPickList;

FetchToSubgrid/utilities/fetchXmlUtils.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export const changeAliasNames = (fetchXml: string) => {
1010

1111
attributeElements.forEach((attributeElement, index) => {
1212
const newAliasValue = `alias${index}`;
13-
attributeElement.setAttribute('alias', newAliasValue);
13+
attributeElement?.setAttribute('alias', newAliasValue);
1414
});
1515

1616
return xmlDoc.documentElement.outerHTML;
@@ -35,8 +35,8 @@ export const addPagingToFetchXml = (
3535
recordsPerPage = Number(top) % pageSize;
3636
}
3737

38-
fetch.setAttribute('page', `${currentPage}`);
39-
fetch.setAttribute('count', `${recordsPerPage}`);
38+
fetch?.setAttribute('page', `${currentPage}`);
39+
fetch?.setAttribute('count', `${recordsPerPage}`);
4040

4141
const newFetchChangedAliases = changeAliasNames(new XMLSerializer().serializeToString(xmlDoc));
4242

@@ -90,8 +90,8 @@ export const addOrderToFetch = (
9090
}
9191

9292
const newOrder: HTMLElement = xmlDoc.createElement('order');
93-
newOrder.setAttribute('attribute', `${sortingData.fieldName}`);
94-
newOrder.setAttribute('descending', `${!sortingData.column?.isSortedDescending}`);
93+
newOrder?.setAttribute('attribute', `${sortingData.fieldName}`);
94+
newOrder?.setAttribute('descending', `${!sortingData.column?.isSortedDescending}`);
9595

9696
if (sortingData.column?.className === 'linkEntity') {
9797
linkEntity?.appendChild(newOrder);

FetchToSubgrid/utilities/utils.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ export const hashCode = (str: string) => {
172172
for (let i = 0; i < str.length; i++) {
173173
const charCode = str.charCodeAt(i);
174174
hash = ((hash << 5) - hash) + charCode;
175-
hash |= 0; // Convert to 32bit integer
175+
hash |= 0;
176176
}
177177
return hash;
178178
};
@@ -229,7 +229,7 @@ export const generateItemsForEntity = (
229229
recordsData.attributesFieldNames.forEach((fieldName: any, index: number) => {
230230
const hasAliasValue = !!recordsData.entityAliases[index];
231231
const attributeType: number = recordsData.entityMetadata.Attributes.get(
232-
fieldName).AttributeType;
232+
fieldName)?.AttributeType;
233233

234234
if (recordsData.entityAliases[index]) {
235235
fieldName = recordsData.entityAliases[index];
@@ -258,7 +258,7 @@ export const generateItemsForLinkEntity = (
258258
recordsData.linkEntityAttributes[i].forEach((attr: any, index: number) => {
259259
const hasAliasValue = !!attr.linkEntityAlias;
260260
const attributeType: number = recordsData.linkentityMetadata[i].Attributes.get(
261-
attr.name).AttributeType;
261+
attr.name)?.AttributeType;
262262
const fieldName = getAttributeAliasName(attr, i, linkEntityName);
263263

264264
const attributes: IItemProps = {

0 commit comments

Comments
 (0)