Hello
I'm working on my first custom web resource. I would like to have an HTML web resource that displays information from a FetchXML query. This web resource is inside a tab on one of my forms. Right now, I have a javascript function embedded in the html page:
<script>
function loadMockAssetIntoTable() {
...
Right now this function is just testing that I can execute JS inside of the HTML web resource from another Javascript file that handles the event logic:
this.productTabLoad = function (executionContext) {
var formContext = executionContext.getFormContext()
var tabState = formContext.ui.tabs.get('tab_5').getDisplayState()
if (tabState === 'expanded') {
Xrm.Page.getControl('WebResource_ProductSelectionPage').getObject().contentWindow.loadMockAssetIntoTable()
}
...
Now, I need to add code so I can pass data from a fetchXML query in the Javascript event handler to the HTML web resource. It looks like there are a few different approaches to do that. I'm not sure which method to use. I'm also not sure if the structure of my code is correct either. Should I move all of this logic directly into the HTML web resource?
What would be a good design choice in this workflow? I would like to limit the amount of times my fetchXML query is executed to achieve good performance. This is why I have it inside the event handler JS file.