RE: need to change document.getElementById to a supported method
Hi Mohammad,
Like I said before, use of getElementByID to access any DOM element within your web resource content is supported. If you have an html element lets say an input tag inside your web resource, you cannot use Xrm client side libraries to access that. You either have to use vanilla JavaScript function like getElementbyId or jquery or other libraries to access that element. Please see the following from the docs page
https://docs.microsoft.com/en-us/dynamics365/customerengagement/on-premises/developer/use-javascript
The error you are getting is pointing to the same paragraph and the rule that tirggers this error is :
{
"description": "Do not directly access the HTML Document Object Model (DOM) of CDS for Apps application pages or entity forms",
"include": true,
"code": "web-avoid-dom-form",
"summary": "Do not directly access the HTML Document Object Model (DOM) of CDS for Apps application pages or entity forms",
"componentType": 0,
"primaryCategory": 8,
"severity": 4
},
Clearly your script is not trying to access DOM element of CRM application pages or the entity form. You script is trying to access an element within your web resource content. This is in my view is a false negative. I assume you are not planing to submit your work to AppSource, and if thats the case, I would use the Solution Checker rule-set. I tried your webresource with solution checker rule-set and it does not complaint.
If your work has to be submitted to AppSource, you can still submit the package and the team that reviews code will ignore any false positives / negatives.
Just wanted to show you an example web resource code that is part of the CRM SDK does use document.getElementById to display content within the web resource
Hope this helps