[QuickTip] How to use setVisible within TypeScript

One of my colleagues recently approached me and asked how one could use the function “setVisible” on a Dataverse control in TypeScript. The function is present in JavaScript but when trying to use it in TypeScript he got an error.

SetVisible error
SetVisible Error

Xrm type is not exposing setVisible, therefore the error is shown. Since it is there in JavaScript (as you can see in the docs), we can still use it from TypeScript using a workaround. We have to define the control as “any” which then will accept that we call a function that is not in the type definitions.

var control = formContext.getControl("telephone1");
(<any>control).setVisible(false);
+1
This is just 1 of 39 articles. You can browse through all of them by going to the main page. Another possibility is to view the categories page to find more related content.
You can also subscribe and get new blog posts emailed to you directly.
Enter your email address to receive notifications of new posts by email.

 

5 Comments

Add a Comment

Your email address will not be published. Required fields are marked *