Skip to main content

Dynamics Set IFrame URL - D365 v8 vs. D365 v9

While doing client work, I came across a problem with setting an IFrame URL dynamically.  The underlying issue was that the sandbox instance is on v8 of Dynamics 365 and production is on v9 of Dynamics 365.  The reason for this was because this client was setup around the time that Microsoft rolled out v9.  Anyways, JavaScript that I wrote to dynamically set the URL of the IFrame wasn't working in the v9 instance.  This was because of changes that Microsoft made to how IFrames are loaded on the form and also changes to JavaScript.

Here is my v8 setup:
  1. JavaScript runs OnLoad of contact form.  This works because of how IFrames are loaded in v8.  You can also run it on either a tab change (hide / show) or OnReadyStateComplete event of the IFrame.  Depending on your setup you will need to choose which is best for you.  For me in this case it was the OnLoad event.
  2. Here is the JavaScript:
 function OnLoad()  
 {  
      //Get memberid  
      var value = Xrm.Page.data.entity.attributes.get("new_memberid").getValue();  
      //Get the default URL for the IFRAME, which includes the   
      // query string parameters  
      var IFrame = Xrm.Page.ui.controls.get("IFRAME_NAMEofIFRAME");  
      var Url = IFrame.getSrc();  
      //Append the parameters to the new page URL  
      newTarget = Url + "history?member=" + value;  
      // Use the setSrc method so that the IFRAME uses the  
      // new page with the existing parameters  
      IFrame.setSrc(newTarget);  
 }  

Here is my v9 setup:
  1. JavaScript runs on OnReadyStateComplete event of the IFrame.  I had to add extra code to prevent constant refresh of the IFrame.  This is because on this event every time we update the URL if causes the OnReadyStateComplete event to fire.  To prevent this we have to use an If/Else so we only update the URL if it hasn't been updated yet.
  2. Here is the JavaScript:
 function OnReadyStateComplete(executionContext)  
 {  
      var formContext = executionContext.getFormContext();  
      var value = formContext.getAttribute("new_memberid").getValue();  
      //Get the default URL for the IFRAME, which includes the   
      // query string parameters  
      var IFrame = formContext.ui.controls.get("IFRAME_NAMEofIFRAME");  
      var Url = IFrame.getSrc();  
      var newTarget = "";  
      //Append the parameters to the new page URL  
      if(Url.includes(value))  
      {  
           newTarget = Url;  
      }  
      else  
      {  
           newTarget = Url + "history?member=" + value;  
           // Use the setSrc method so that the IFRAME uses the  
           // new page with the existing parameters  
           IFrame.setSrc(newTarget);  
      }  
 }  

As you can see in my v9 code I have to pass in the execution context so I can create the form context.  To do that you have to check the box next to, "Pass execution context as first parameter" when adding the JavaScript to the form.


Microsoft has not yet deprecated Xrm.Page yet but it is coming, so it is best to plan for it.  Here are some important links I used when solving my problem of the JavaScript not running:

Important Change (deprecations) coming
OnReadyStateComplete
Execution Context
Form Context
Walkthrough: Write your first client script
Client API Reference

Comments

  1. There are a few apparatuses where you can get even data on inbound connections and outbound connections, yet in this article we will concentrate on Spam Score. access the darknet

    ReplyDelete
  2. Seattle Software Developers : This blog consistently delivers valuable information that's hard to find elsewhere. The articles are well-researched and cover a wide range of topics. Highly recommended!

    ReplyDelete
  3. Establish clear rules and guidelines for your server and appoint responsible moderators to ensure a safe and welcoming environment.

    discord online member kaufen

    ReplyDelete
  4. The ethics surrounding buying Discord members can be a contentious topic. Critics argue that artificially inflating member counts can lead to inauthentic interactions, potentially undermining the integrity of the community. However, proponents contend that it can act as a catalyst, attracting genuine members who join after observing a thriving community.

    discord online member kaufen

    ReplyDelete
  5. TikTok has become a global sensation, capturing the attention of millions with its engaging short videos and rapidly growing user base. With the promise of fame and fortune, the competition to stand out on the platform is fierce. In this quest for popularity, a controversial trend has emerged: "TikTok Live Zuschauer Kaufen," which translates to buying live viewers on TikTok. In this article, we will delve into this contentious practice, exploring its motivations, potential consequences, and ethical considerations.

    tiktok live zuschauer kaufen

    ReplyDelete
  6. Karaoke has been a beloved pastime for music enthusiasts around the world. With karaoke backing tracks, aspiring singers can take their performances to the next level. These tracks often include lyrics and background vocals, allowing singers to feel like they're performing with a live band. It's the perfect way to showcase your vocal skills and have a blast at the same time.


    karaoke backing tracks

    ReplyDelete
  7. Ecological Surveys
    For projects that may affect local ecosystems, ecological surveys are conducted to assess the impact and develop mitigation strategies. This includes studying flora, fauna, and habitat dynamics.

    phase 1 desk study report

    ReplyDelete
  8. What does the future hold for the English wine industry? Delve into emerging trends and projections for the growth and development of English wines.

    English Red Wine

    ReplyDelete
  9. The UAE's multicultural society has a profound influence on interior design. It encourages a fusion of design styles, resulting in eclectic and vibrant spaces that resonate with a global audience.


    interior design companies in business bay

    ReplyDelete
  10. Slot88 and Slot Maxwin boast an extensive selection of themed slot games, from ancient civilizations to modern pop culture. This variety ensures that players always have something new and exciting to explore. Megajudi303's dedication to responsible gaming is reflected in their self-exclusion and deposit limit options, which allow players to set boundaries and play within their means.

    Slot maxwin

    ReplyDelete
  11. Full-screen timers have revolutionized the way we manage time and maintain focus in an era filled with distractions. Their immersive nature and visual countdowns make them powerful tools for staying on track and accomplishing tasks efficiently.

    fullscreen timer

    ReplyDelete
  12. Advanced Topics in Data Analytics at APTRON offer an exciting opportunity for individuals looking to deepen their understanding of this dynamic field. In today's data-driven world, the demand for skilled data analysts is skyrocketing, and APTRON is at the forefront of providing cutting-edge education in this domain.

    ReplyDelete
  13. The Translation Company UK landscape is typified by a symphony of linguistic mastery and cultural finesse, pivotal for individuals and enterprises navigating the complex tapestry of global communication.

    Translation Agency UK

    ReplyDelete
  14. Translation agencies in the UK play a pivotal role in bridging communication gaps, fostering international collaboration, and supporting businesses in their global expansion endeavors. These agencies offer an array of services, including document translation, interpretation, localization, and language consulting, among others.

    Translation Services UK

    ReplyDelete
  15. Big timers come in various forms, including physical devices, software applications, and online tools. They are designed to provide a visual representation of time passing, helping you stay focused and manage your time effectively.

    fullscreen timer

    ReplyDelete
  16. While no foolproof method guarantees identifying a Gacor slot, seasoned players often rely on observation, research, and a touch of intuition. Engaging with online communities, tracking recent jackpot winners, or even just trusting your gut can sometimes lead you to that winning streak.

    Slot Gacor

    ReplyDelete
  17. From movies to music, the allure of a winning streak at a slot machine has been immortalized in various forms. Slot Gacor, with its captivating narrative, has found its way into the heart of pop culture.

    Slot Gacor Hari Ini

    ReplyDelete
  18. Dreadlocks can be seen as a celebration of natural hair texture. People with various hair types can create dreadlocks, emphasizing the beauty of embracing one's natural self. This journey often involves letting go of chemicals and heat treatments, promoting hair health and self-acceptance.

    Dreadlocks

    ReplyDelete
  19. Cultivating locs involves allowing hair to naturally mat and form into distinctive, rope-like strands. Ongoing maintenance, which can include twisting, palm rolling, or interlocking, ensures that locs remain healthy and well-groomed.

    Locs

    ReplyDelete
  20. Olivia Rodrigo's poignant lyrics resonate with many, and they have inspired a wave of fashion choices that reflect the emotions and stories she tells through her music. Fans often find themselves connecting deeply with Olivia's lyrics, and this emotional connection extends to their fashion choices. From vintage-inspired looks to edgy streetwear, Rodrigo's words influence outfits that tell a story.

    BTS Jungkook's Golden Concept Tattoos

    ReplyDelete
  21. Australia's breathtaking landscapes have inspired artists for generations. Learn how Australian landscape calendars showcase the country's diverse geography, from the rugged Outback to pristine coastal vistas, through stunning artwork and photography.

    Australian Calendars

    ReplyDelete
  22. If you're environmentally conscious, you'll appreciate our guide to eco-friendly wall planners. We showcase planners made from sustainable materials and provide tips on reducing paper waste while staying organized.

    Magnetic Calendar

    ReplyDelete
  23. Take your guitar playing to the next level with our user-friendly rock backing tracks. Whether you want to practice your improvisation skills or simply enjoy jamming along, our tracks provide the perfect rhythm and groove for every rock subgenre.






    rock backing tracks

    ReplyDelete
  24. Belize property for sale presents a plethora of investment opportunities in a rapidly growing market. From vacation rentals to commercial properties, Belize offers diverse options for investors seeking high returns. Explore the various regions and property types available for purchase, and unlock the potential for long-term financial growth through Belizean real estate.

    Remax Belize

    ReplyDelete
  25. Singers can take their vocal performances to the next level with backing tracks that provide harmonies, instrumentation, and accompaniment. These tracks not only enhance the overall sound but also allow singers to focus on their delivery and connect with their audience.

    backing tracks

    ReplyDelete
  26. For musicians, delivering a flawless live performance is crucial, and backing tracks have become indispensable tools in achieving this goal. They ensure consistent sound quality, enable complex arrangements, and grant artists the flexibility to bring studio-quality music to the stage, captivating audiences worldwide.

    backing tracks

    ReplyDelete

Post a Comment

Popular posts from this blog

Validating User Input In CRM Portals With JavaScript

When we are setting up CRM Portals to allow customers to update their information, open cases, fill out an applications, etc. We want to make sure that we are validating their input before it is committed to CRM.  This way we ensure that our data is clean and meaningful to us and the customer. CRM Portals already has a lot validation checks built into it. But, on occasion we need to add our own.  To do this we will use JavaScript to run the validation and also to output a message to the user to tell them there is an issue they need to fix. Before we can do any JavaScript, we need to check and see if we are using JavaScript on an Entity Form or Web Page.  This is because the JavaScript, while similar, will be different.  First, we will go over the JavaScript for Entity Forms.  Then, we will go over the JavaScript for Web Pages.  Finally, we will look at the notification JavaScript. Entity Form: if (window.jQuery) { (function ($) { if (typeof (entityFormClientVali

Navigating Microsoft Dynamics 365 Customization: Plugins vs. Azure Functions

Embarking on the Microsoft Dynamics 365 customization journey offers numerous opportunities to enhance your business processes. However, deciding between the available options, such as Plugins and Azure Functions, can be challenging. This engaging post will serve as your trusty guide, helping you choose the best option for your Dynamics 365 customization needs! The Two Customization Pathfinders: Plugin and Azure Function The Agile Plugin 🏃‍♂️ Reference: Microsoft Docs - Write a plug-in Plugins are like the swift trail runners of the Dynamics 365 customization world. They're the go-to choice for quick, real-time (synchronous), or background (asynchronous) operations that occur within the platform. They can intercept events and modify data before it's saved or displayed to the user. Choose Plugins when: You need real-time processing (synchronous) or background processing (asynchronous). You want to ensure data integrity. You need tight integration with Dynamics 365. Plugins mig