Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

Dynamics 365 Unified interface - Show web resource

Posted on by 505
I'm trying to show a web resource using the following code but it is not working.
var formContext = executionContext.getFormContext(); 
formContext.getControl("WebResouce_CopyAccountID").setVisible(true);

How can I accomplish this?

*This post is locked for comments

  • Suggested answer
    Priyank Bhavsar Profile Picture
    Priyank Bhavsar 505 on at
    RE: Dynamics 365 Unified interface - Show web resource

    Yes, finally debugged the Javascript and got this working.

    The code which worked is:

    formContext._ui._controls._collectionItem.WebResource_CopyAccountID.setVisible(true);

    Hope it helps someone.

  • Kokulan Profile Picture
    Kokulan 18,048 on at
    RE: Dynamics 365 Customer Engagement - Show web resource

    Hi

    Did you get this working?

  • Priyank Bhavsar Profile Picture
    Priyank Bhavsar 505 on at
    RE: Dynamics 365 Customer Engagement - Show web resource

    Sorry for the typo, I need to show the web resource which is by default visible false.

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Dynamics 365 Customer Engagement - Hide web resource

    Hi

    To hide web resource you have to set the setvisibility --> false

    formContext.getControl("WebResouce_CopyAccountID").setVisible(false);

  • Suggested answer
    Kokulan Profile Picture
    Kokulan 18,048 on at
    RE: Dynamics 365 Customer Engagement - Hide web resource

    I would do a publish all, Open in different browser session, incognito if possible and see if script can pick up, this way you can rule out its definitely not caching issue.

    When this script is executing, could it be its executing before the web resource control is rendered?

    If you still have the issue, could you share screenshot of the web resource properties on the form.

    Thanks

  • Priyank Bhavsar Profile Picture
    Priyank Bhavsar 505 on at
    RE: Dynamics 365 Customer Engagement - Hide web resource

    Hi Pravin,

    XRM.Page is deprecated and no longer works for Unified interface.

  • Priyank Bhavsar Profile Picture
    Priyank Bhavsar 505 on at
    RE: Dynamics 365 Customer Engagement - Hide web resource

    Hi Kokulan,

    The  context is not null but the control is null even though the ID is correct.

    The error says 'Unable to get property 'setVisible' of undefined or null reference'

  • Suggested answer
    Pawar Pravin  Profile Picture
    Pawar Pravin 5,227 on at
    RE: Dynamics 365 Customer Engagement - Hide web resource

    Hi Priyank,

    Did you tried using Xrm library ?

    Xrm.Page.getControl("WebResouce_CopyAccountID").setVisible(true);

    Also check visibility in JS after setVisible function

  • Suggested answer
    Kokulan Profile Picture
    Kokulan 18,048 on at
    RE: Dynamics 365 Customer Engagement - Hide web resource

    Hi

    Your code seems to be correct and it should work, please try the following

    01. Make sure the Web Resource name is correct - Copy and paste the name from the webresource properties.

    02. Add a "debugger;" line just above the formContext and open dev tool and step through the lines, make sure formContext is not null

    03. Also check formContext.getControl("WebResouce_CopyAccountID") is not null

    Above all, make sure you do Ctrl+F5 to flush the cache

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans