Skip to content

Commit

Permalink
Added FXB view integration
Browse files Browse the repository at this point in the history
  • Loading branch information
rajyraman committed Mar 16, 2023
1 parent c5454fb commit 44e3a3f
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
11 changes: 10 additions & 1 deletion app/pages/options.html
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@
<button data-category="Grid" data-category="quickFindFields" id="quickFindFields" class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--accent">
<i class="material-icons">more_horiz</i>
<span>Quick Find fields</span>
</button data-category="">
</button>
<div class="mdl-tooltip" data-mdl-for="quickFindFields">
Displays the quick find columns for the current view.
</div>
Expand All @@ -459,6 +459,15 @@
Resets blurred fields back to initial state
</div>
</div>
<div class="mdl-cell mdl-cell--4-col">
<button data-category="Grid" data-category="sendToFXB" id="sendToFXB" class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--accent">
<i class="material-icons">code</i>
<span>Open View in FetchXML Builder</span>
</button>
<div class="mdl-tooltip" data-mdl-for="sendToFXB">
Opens the FetchXML query in FetchXML Builder.
</div>
</div>
</div>
</div>
</section>
Expand Down
24 changes: 21 additions & 3 deletions app/scripts/inject/levelup.grid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,25 @@ export class Grid {
this.utility.messageExtension(resultsArray, 'quickFindFields');
});
} else {
alert('The current page is not a grid');
alert('The current page is not a view');
}
}

sendToFXB() {
//@ts-ignore
if (this.utility.Xrm.Utility.getPageContext) {
const view = <Xrm.EntityListPageContext>this.utility.Xrm.Utility.getPageContext().input;

this.utility.fetch('savedqueries', 'fetchxml', `savedqueryid eq ${view.viewId}`).then((view) => {
if (view && view[0].fetchxml) {
window.open(
`xrmtoolbox:///plugin%3A"FetchXML Builder" /data%3A"${view[0].fetchxml.replaceAll('"', "'")}"`,
'_blank'
);
}
});
} else {
alert('The current page is not a view');
}
}

Expand Down Expand Up @@ -71,7 +89,7 @@ export class Grid {
viewUrl = `${this.utility.clientUrlForParams}etc=${etc}&viewtype=${viewType}&viewid=${viewId}&newWindow=true&pagetype=entitylist`;
window.open(viewUrl, '_blank');
} else {
alert('The current page is not a grid');
alert('The current page is not a view');
}
}

Expand All @@ -85,5 +103,5 @@ export class Grid {
}

function setFilter(formDocument: Document, filter: string) {
formDocument.querySelectorAll('.wj-row[aria-label="Data"]').forEach((e: HTMLElement) => (e.style.filter = filter));
formDocument.querySelectorAll('div[role="gridcell"]').forEach((e: HTMLElement) => (e.style.filter = filter));
}

0 comments on commit 44e3a3f

Please sign in to comment.