Managing teams and their members is a common requirement for organizations using Dynamics 365. If you’ve ever needed to retrieve the list of members in a specific team from the Dataverse, you’ve likely found that it isn’t as straightforward as you might expect. After a bit of research and trial-and-error, I’ve put together a simple solution using Power Automate, and I’m excited to share it with you. This blog post will walk you through the process step by step.

The Challenge

The Dataverse has a many-to-many relationship between teams and system users, managed through the hidden teammemberships table. This table links users (systemusers) to teams, but since it isn’t visible by default, you need to use Power Automate to query it effectively.

The Solution

By leveraging Power Automate’s Dataverse connector, we can build a flow to retrieve team members. Here’s how it works:

Step 1: Get the Team

The first step is to identify the team you’re working with. To do this:

  1. Add a Get Row action.
  2. Set the Table name to Teams.
  3. Specify the Row ID. If you’re dynamically retrieving this (e.g., based on the owner of a record), you can use the Owner (Value) field.

Step 2: Retrieve Team Memberships

Next, we’ll query the teammemberships table to find all users linked to the team:

  1. Add a List Rows action.
  2. Set the Table name to teammemberships.
  3. Use a Filter Query to specify the team ID:
    teamid eq '<TeamID>'

    Replace <TeamID> with the dynamic value retrieved from the previous step.

This will return all system users associated with the team.

Screenshot of list teammemberships in power automate

Step 3: Loop Through Team Members

The teammemberships table gives you the systemuserid values for all team members. To retrieve detailed information about each member:

  1. Add an Apply to Each loop.
  2. Set the input to the value array from the previous step.
  3. Inside the loop, add a Get Row by ID action:
    • Set the Table name to Users.
    • Set the Row ID to the systemuserid from the current item in the loop.

Looping through the list output from Team Membership

Step 4: Process the Results

Once you have the user details, you can process them further. For example:

  • Aggregate the results into an array.
  • Format the data into an HTML table for an email notification.
  • Save the data to a SharePoint list or Excel file.

Practical Use Case

Let’s say you want to send an email to a manager listing all the members of a specific team. Here’s how your flow might look:

  1. Retrieve the team and its members as described above.
  2. Collect each member’s name and email into an array.
  3. Use the Create HTML Table action to format the data.
  4. Add a Send an Email (V2) action and include the table in the email body.

Why This Solution is Helpful

Finding a way to retrieve team members in Dataverse is a common challenge, and there’s limited documentation on how to achieve it effectively. By using the teammemberships table in Power Automate, you can overcome this limitation and build powerful workflows tailored to your organization’s needs.

Final Thoughts

I hope this guide helps you streamline your Dataverse workflows. If you’re managing Dynamics 365 teams and need to automate team-related tasks, this approach can save you time and effort. Feel free to share this with your team or let me know if you have questions—I’d be happy to help!

AccessOrange is a leading Microsoft Partner that specializes in Microsoft 365, Dynamics 365 and Azure to help our customers work smarter.
If you need help with building this flow in your own environment, leave your contact information below, and we will contact you as soon as possible.

"*" indicates required fields

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.
This field is for validation purposes and should be left unchanged.

We are proud to share a significant milestone in AccessOrange’s journey: being awarded the SME Cyber Security Excellence Award 2024 in Singapore! This prestigious accolade highlights our unwavering dedication to empowering businesses with robust cybersecurity solutions, helping them navigate today’s complex digital landscape. 

A Testament to Excellence in Cybersecurity 

The SME Cyber Security Excellence Award is a mark of distinction, recognizing small and medium enterprises that demonstrate exemplary efforts in implementing innovative and effective cybersecurity practices. Receiving this award affirms AccessOrange’s commitment to providing top-tier solutions that prioritize security, reliability, and trust for our clients. 

Our Journey Toward Cybersecurity Excellence 

At AccessOrange, we understand the critical importance of cybersecurity for businesses of all sizes. Over the past year, we have: 

  • Strengthened our advanced monitoring and support services using cutting-edge tools like Azure Monitor and Azure Sentinel. 
  • Expanded our suite of proactive solutions to mitigate cyber risks, including 24/7 monitoring and customized support plans. 
  • Collaborated with our clients to implement tailored cybersecurity strategies, ensuring their systems remain resilient against evolving threats. 

These efforts have not only safeguarded our clients’ operations but also reinforced our position as a trusted partner in the cybersecurity space. 

Gratitude and Forward Momentum 

“Our mission has always been to empower businesses with secure and reliable IT solutions,” said Roald Andersen, CEO of AccessOrange. “Winning this award validates the dedication of our team and the trust our clients place in us as we navigate the ever-evolving cybersecurity landscape.” 

This achievement wouldn’t have been possible without the trust of our clients, the collaboration of our partners, and the relentless dedication of our team. Winning the SME Cyber Security Excellence Award motivates us to continue raising the bar for cybersecurity in Singapore and beyond. 

Looking ahead, we remain committed to: 

  • Innovating our services to address emerging cyber challenges. 
  • Advocating for greater awareness and adoption of cybersecurity best practices among SMEs. 
  • Supporting businesses in their digital transformation journeys without compromising on security. 

Join Us in Celebrating This Achievement 

We are deeply grateful to the Cyber Security Agency of Singapore and the Association of Trade and Commerce for recognizing our efforts. This award is not just a reflection of our past achievements but also a beacon guiding us toward a more secure and resilient digital future. 

Stay connected with us as we continue to champion cybersecurity excellence. Whether you’re looking for guidance, solutions, or a trusted partner to enhance your business’s digital security, AccessOrange is here to help. 

Let’s build a safer digital world together! 

For more information on our cybersecurity solutions, visit our website at www.accessorange.com or contact our team today. 

On December 4, 2024, AccessOrange held an impactful seminar exploring Microsoft Azure, its capabilities, and how it empowers businesses to embrace the cloud era. This comprehensive event brought together experts from Microsoft, AccessOrange, and Ingram to discuss Azure’s role in modernizing IT infrastructure, enhancing security, and enabling seamless migration. Here’s a consolidated summary of the key topics covered, offering a glimpse into the insights shared during the sessions.

Watch Video Recording


Understanding Azure: Your Gateway to Innovation

Microsoft Azure, a leading cloud platform, provides businesses with a broad array of services including computing, storage, networking, and advanced AI capabilities. With over 60 regions and 200+ data centers worldwide, Azure offers unparalleled global coverage and flexibility. The platform operates on a pay-as-you-go model, ensuring cost efficiency by charging only for the resources you consume.

Azure’s strengths include:

  • Unmatched Cost Savings: Save up to 80% on cloud costs with Azure Reserved Instances and Hybrid Benefits.
  • Industry-Leading Security: A robust, multi-layered defense system supported by a $20 billion security investment over five years and 65 trillion monitored daily signals.
  • Seamless Hybrid Operations: Azure facilitates hybrid cloud and multicloud strategies, enabling businesses to operate seamlessly across environments.

Attendees gained clarity on how Azure outperforms competitors like AWS, offering up to 93% lower costs for SQL workloads, while maintaining compatibility with legacy systems.


Migrating to Azure: Simplifying the Journey

The seminar detailed how businesses can transition from on-premises infrastructure to Azure with minimal disruption, leveraging the Azure Migrate and Modernize Program (AMMP). This program provides end-to-end support, from assessments and migration planning to execution and optimization. Key benefits include:

  • Automated Migration Tools: Streamlined processes for moving Windows, Linux, and VMware workloads.
  • Cost Optimization: Use of tools like Reserved Instances and Azure Hybrid Benefit to reduce expenses significantly.
  • Holistic Support: Access to centralized tracking tools and expert guidance for a seamless migration journey.

Why Azure is the Smart Choice for Your Business

Azure is designed to address critical challenges faced by modern businesses:

  • Scalability: Easily scale operations up or down based on demand.
  • Security: Microsoft Defender for Cloud and Sentinel provide advanced protection against emerging threats.
  • Cost Efficiency: Businesses can save up to $400,000 annually by avoiding on-premises infrastructure maintenance, as noted in a Forrester study.

The platform also provides powerful tools for modernization, such as Azure SQL Managed Instance, enabling businesses to transition from traditional databases to a fully-managed, cloud-based environment with minimal effort.

Your Azure Transformation Awaits

This seminar showcased how businesses across industries are leveraging Azure to drive innovation, improve security, and reduce costs. By partnering with AccessOrange, companies can simplify their cloud migration journey and unlock the full potential of Microsoft Azure.

For those who missed the seminar, we’ve shared part of the recording below, offering a chance to explore Azure’s possibilities in-depth.

Ready to start your journey? Contact AccessOrange for a free Azure assessment and begin transforming your IT infrastructure today.

"*" indicates required fields

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.
This field is for validation purposes and should be left unchanged.

In today’s fast-paced digital world, staying ahead of the curve is essential. That’s why we’re excited to introduce the Copilot Academy, a comprehensive learning platform designed to help you master the use of Microsoft Copilot across various applications.

What is Copilot Academy?

The Copilot Academy is an innovative educational platform integrated within Viva Learning. It offers structured educational content to help users learn about, discover, and effectively use Microsoft Copilot. Whether you’re looking to enhance your productivity, streamline your workflows, or simply get the most out of your Microsoft 365 applications, Copilot Academy has got you covered.

How to Access Copilot Academy

To access the academy in Viva Learning, Users must have a Microsoft M365 Copilot license, in addition to a Viva Learning seeded or premium license.

There are two ways to access Copilot Academy – directly through the Viva Learning webapp, or from the Viva Learning Teams app by using the Academies dropdown navigation menu. Copilot Academy is available in 8 languages: English, French, German, Italian, Spanish, Portuguese, Japanese and Chinese.

Why Join Copilot Academy?

Joining Copilot Academy offers a unique opportunity to elevate your digital skills and stay competitive in today’s technology-driven workforce. By enrolling, you gain access to a wealth of resources tailored to enhance your understanding and usage of Microsoft Copilot, allowing you to maximize the potential of your Microsoft 365 suite. With expertly crafted training materials, practical exercises, and real-time support, the academy equips you with the knowledge and confidence to utilize Copilot to its fullest, ultimately transforming the way you work and collaborate.

  • Comprehensive Training: The academy provides in-depth training on how to use Copilot effectively across various Microsoft 365 applications. You’ll learn how to leverage Copilot to improve your productivity and efficiency.
  • Interactive Learning: Featuring interactive modules, hands-on exercises, and real-world scenarios, the academy ensures you gain practical experience.
  • Expert Guidance: Learn from industry experts and Microsoft-certified trainers who will share their insights and best practices.
  • Community Support: Join a community of like-minded professionals and share your experiences, tips, and success stories.

Join The Copilot Academy Today!

Don’t miss out on the opportunity to elevate your skills and transform the way you work. Join the Copilot Academy today and start your journey towards becoming a Microsoft Copilot expert.

Microsoft 365 Copilot — Apply Now —

Apply today to make your work easier and smarter.

"*" indicates required fields

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.
This field is for validation purposes and should be left unchanged.

On September 25, 2024, AccessOrange had the privilege of hosting a dynamic seminar at the Microsoft office in Hong Kong, focusing on two critical areas for businesses in the modern digital landscape: Microsoft Copilot for Microsoft 365 and Cybersecurity in Phishing Attacks. This event attracted professionals from various industries, all eager to learn how to integrate cutting-edge AI tools into their work environments and safeguard their businesses from the growing threat of cyberattacks.

Photo of the September 25 seminar, held at the Microsoft Hong Kong Office.

Session Highlights:

The seminar was divided into two insightful sessions:

  1. Leveraging Microsoft Copilot in Microsoft 365 Apps:
    • Participants explored the incredible potential of Microsoft Copilot, which integrates AI capabilities into Microsoft 365 apps such as Word, Excel, PowerPoint, and Teams.
    • Nero Wong, Customer Success Manager at AccessOrange, delivered a compelling demonstration on how Copilot uses ChatGPT to help users work smarter and faster by generating content, organizing information, and providing valuable insights.
    • Attendees learned the difference between free AI tools and Microsoft Copilot, which ensures better security and seamless integration with organizational data.
    • Key discussions focused on the ROI of Copilot, with case studies highlighting significant time and cost savings. For instance, Wilhelmsen Ship Management saw a 100% adoption of Teams Phone, enhancing cross-border communication between Taiwan and Hong Kong.
  2. Cybersecurity in Phishing Attacks:
    • With phishing attacks becoming more sophisticated, we focused on the trends and dangers associated with this type of cybercrime. Attendees were educated on different types of phishing attacks, such as email phishing, smishing, vishing, and spear phishing.
    • The session also provided practical tips on how to identify phishing emails and solutions to mitigate the risks. Solutions discussed included Microsoft 365 Business Premium, which offers advanced security features like Multi-Factor Authentication (MFA), Safe Links & Attachments, Data Loss Prevention, and Intune Device Management to protect businesses from phishing and ransomware attacks.

Why It Matters: With the digital transformation accelerating, leveraging AI tools like Copilot is no longer just an option but a necessity for companies looking to stay competitive. At the same time, safeguarding business data from cyber threats, including phishing, is crucial to ensure operational continuity and protect sensitive information.

Our seminar aimed to equip businesses with the knowledge and tools they need to excel in both productivity and cybersecurity, ensuring that they are well-prepared to face the future.

Thank You to Our Attendees: We would like to extend a special thank you to all attendees who joined us for this informative event. Your participation and engagement were invaluable, and we look forward to supporting your business with innovative solutions that drive success.

For more information on Microsoft Copilot, cybersecurity, or how AccessOrange can help your business grow securely, feel free to contact us via the form below.

"*" indicates required fields

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.
This field is for validation purposes and should be left unchanged.

Unlocking Productivity and Value with Generative AI

Microsoft Copilot for Microsoft 365 promises to transform productivity by embedding generative AI into the daily tools we use for work. This innovation presents an exciting opportunity for businesses worldwide to streamline operations and enhance efficiency. But what is the actual return on investment (ROI) of adopting Copilot for Microsoft 365 in a global context?

Evaluating the Value of Copilot for Microsoft 365

For businesses considering the adoption of Copilot, the upfront cost is USD 360 per employee annually, or USD 30 per month when billed yearly. This may appear to be a significant investment, especially for larger organizations. However, it is essential to understand the potential savings and productivity boosts that can justify this expense.

The flexibility in purchasing licenses—without a minimum requirement—allows businesses to start with focused rollouts. This approach enables companies to measure the impact and ROI before scaling up the deployment.

Calculating the ROI of Copilot for Microsoft 365

The break-even point for investing in Copilot can be achieved with just 54 minutes of time savings per month for an employee earning an annual total cost of USD 70,000 (approximately USD 5,833 per month). This total cost includes not just the base salary but also overheads, payroll taxes, and other ancillary costs.

Here’s how to calculate the ROI:

  1. If an employee costs the company USD 70,000 per year (about USD 5,833 per month), the company needs to see if the employee can save enough time to cover the monthly cost of Copilot, which is USD 30.
  2. If this employee saves just 1 hour per month using Copilot, the company gets a 12% return on investment (ROI).
  3. If the employee saves 1.5 hours per month, they get a 68% ROI.
  4. Saving 2 hours per month translates to a 124% ROI.
  5. And saving 2.5 hours per month results in a 180% ROI.

So, essentially, even small-time savings can significantly justify the cost of Copilot, especially for employees with higher costs to the company.

The Higher the Annual Cost of an Employee – The Higher the ROI

Copilot’s value becomes even more apparent for higher-paid employees who save more time on routine tasks. For example, an employee with an annual total cost of USD 150,000 (hourly cost of approximately USD 75):

– 140% ROI if they save 1 hour a month.

– 261% ROI if they save 1.5 hours a month.

– 381% ROI if they save 2 hours a month.

– 501% ROI if they save 2.5 hours a month.

Are the Time Savings Realistic?

Research from the Boston Consulting Group (BCG) and Harvard, along with early adoption reports from Microsoft, supports the significant time savings Copilot can bring. Key findings include:

  • Consultants at BCG completed 12.2% more tasks on average and 25% quicker using AI.
  • The quality of work was 40% higher compared to those who did not use AI.
  • Early adopters within Microsoft reported:
  • 87% increased productivity.
  • 79% focused more on important tasks.
  • 81% reduced time spent searching for information.
  • 1 in 3 saved more than 30 minutes per day.

Additional research highlights Copilot’s impact across various business environments:

  • Email Management:

– Professionals using Copilot to draft and respond to emails save 3-8 minutes per email, significantly reducing the time spent on daily communication.

  • Meeting Summarization:

– Copilot’s ability to summarize meetings allows employees to quickly review key points and action items, improving follow-up efficiency and reducing the need for extensive note-taking.

  • Report Generation:

– Financial analysts and project managers benefit from Copilot’s report generation capabilities, experiencing a 35% increase in the speed of financial forecasting and project updates, respectively.

  • Customer Service:

– Automated customer service responses powered by Copilot lead to a 50% reduction in call resolution times, enhancing customer satisfaction and freeing up representatives for more complex issues.

  • Data Analysis:

– Business analysts using Copilot for data analysis report a significant reduction in time spent on data manipulation and interpretation, allowing them to focus on strategic decision-making.

  • Administrative Tasks:

– Copilot helps reduce administrative workload, such as scheduling and document preparation, allowing employees to dedicate more time to core business activities.

These examples underscore Copilot’s versatility and effectiveness in enhancing productivity, accuracy, and efficiency across various business functions.

Conclusion

The data from early adopters of Copilot for Microsoft 365 and the broader use of Generative AI highlights a clear ROI for organizations. The greatest returns will come from leveraging the time savings to innovate and add value for customers. In these early stages, the personal productivity gains alone make Copilot a worthwhile investment, promising to revolutionize the way businesses operate.

In summary, here are the key advantages of using Copilot:

  • Time Savings: Copilot significantly reduces the time required to perform routine tasks such as summarizing meetings, creating reports, drafting emails, and more. This allows employees to focus on more strategic activities that add value.
  • Increased Efficiency: By automating repetitive tasks, Copilot helps streamline workflows and processes, leading to higher efficiency and better utilization of resources.
  • Enhanced Productivity: With routine tasks taken care of, employees can dedicate more time to creative and high-impact work, boosting overall productivity and job satisfaction.
  • Improved Accuracy: Copilot minimizes human errors by providing consistent and accurate outputs, ensuring higher quality work and reducing the need for revisions.
  • Seamless Integration: Copilot integrates seamlessly with existing Microsoft 365 tools, making it easy for employees to adopt and start benefiting from its capabilities immediately.

By leveraging these advantages, organizations can unlock new levels of performance and innovation, driving growth and success in today’s competitive landscape.

 

In Dynamics 365 Sales, duplicate detection exists but only works at an individual level, for example, when a lead is converted or a new account is created.

Unfortunately, there’s no out-of-the-box solution to automatically detect duplicates in bulk across the system. This limitation can lead to data inaccuracies, especially as your organization grows.

To overcome this challenge, I created a Power Automate flow that finds and merges duplicate accounts automatically.

In this article, I’ll walk you through how to create this flow, and you can adapt it for your own needs.

Flow overview:

(Apologies, I have not renamed some of the foreach and conditions, but I think you will understand 🙂 )

Step-by-Step Guide to Creating the Flow

Step 1: Set up the Trigger

The first step is to set up the trigger for the flow. We want this flow to run on a regular schedule to detect duplicates. Use the Recurrence trigger to specify how frequently the flow should run (e.g., daily or weekly).

Step 2: Query Accounts from Dataverse

Next, add an action to list all accounts from the Dataverse. This will retrieve all active accounts so that we can compare them and detect duplicates.

  • Action: Use List Rows from the Dataverse connector.
  • Filter: You can filter for only active accounts or specific criteria that make sense for your business.
  • Also initialize the variable Duplicates here as an array

Step 3: Identify Duplicate Accounts

Once the accounts are retrieved, you need to compare the names or other unique fields to detect duplicates.

  • Use a loop to go through each account and check for duplicate names.
  • Clear the array variable Duplicates
  • Implement a condition in the flow to identify if two or more accounts share the same name.

The Replace() is used to fix the acounts that have the character inside their name, to not break the odata filter.

Condition:

and(greater(length(outputs(‘List_rows_2’)?[‘body/value’]), 1))
If any duplicate is found (YES under condition), add the Account ID to the Duplicates array

Step 4: Merge the Duplicates

Once duplicates are identified, use Dataverse’s Unbound Action to merge the duplicate accounts. The unbound action allows you to merge records within Dataverse without having to handle the data manually.

  • Action: Use the Perform Unbound Action step from the Dataverse connector.
  • Target: The original account and the duplicate account.

Condition 3: (meaning one or more duplicates have been found)

length(variables(‘Duplicates’))
If YES, then take the first and the last account:
(Because you can only merge 2 accounts at the same time)
Get the first Account:
Get the last duplicated account:
Send me an email notification, and then do an Unbound Action (Merge):
That’s it, our entire flow is ready:
AccessOrange is a leading Microsoft Partner that specializes in Microsoft 365, Dynamics 365 and Azure to help our customers work smarter.
If you need help with building this flow in your own environment, leave your contact information below, and we will contact you as soon as possible.

"*" indicates required fields

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.
This field is for validation purposes and should be left unchanged.

In this blog post, I’ll show you how to create a solution in Dynamics 365 that automatically ensures the Opportunity currency matches the Account currency.

I wrote this solution as I got so frustrated that when you create an opportunity in Dynamics 365 Sales, that the currency is not automatically set to the correct currency. Instead it goes to the default currency as set in the system, which will create all sort of problems when you are working in a multi region sales team. (selection of wrong currencies, quote then cannot use the correct currency, etc)

This solution will use JavaScript to retrieve and compare these values, and if they don’t match, update the Opportunity currency to reflect the Account’s currency. Additionally, we’ll publish this solution and configure it to run seamlessly within Dynamics 365.

Prerequisites

Before you begin, ensure you have the following:

  • Administrator access to Dynamics 365.
  • Basic understanding of JavaScript and Dynamics 365 customization.

Let’s break down the process step-by-step.

Step 1: Create a New Solution in Dynamics 365

The first step is to create a solution to contain your custom JavaScript logic and publish it into Dynamics.

  1. Navigate to Power Platform Admin Center:
    • Go to your Dynamics 365 environment.
    • Click on the gear icon and select Advanced Settings.
    • In the settings area, click on Solutions.
  2. Create a New Solution:
    • Click New to create a new solution.
    • Enter details such as:
      • Display Name: Opportunity-Account Currency Sync.
      • Publisher: Select or create a new one.
      • Version: Start with 1.0.0.0.
  3. Add the Opportunity Entity to the Solution:
    • In the solution editor, click on Add ExistingEntityOpportunity.
    • This allows us to add custom logic to the Opportunity entity form.

Step 2: Write the JavaScript for Currency Sync

Next, we’ll write the JavaScript code to compare the Opportunity and Account currency and update the Opportunity currency if they don’t match.

  1. Create a Web Resource for JavaScript:
    • In the solution, navigate to Web Resources and click New.
    • Select JavaScript (JScript) as the type, and name it currencySync.js.
    • Paste the following JavaScript code into the web resource:
    • function getDetailsFromOpportunity(executionContext) {
      var formContext = executionContext.getFormContext();
      
      // Check if the Opportunity has been saved (i.e., it has an ID)
      var opportunityId = formContext.data.entity.getId();
      if (!opportunityId) {
      console.log("This is a new opportunity. The record has not been saved yet.");
      return; // Exit the function if it's a new, unsaved Opportunity
      }
      
      // Proceed with the currency check if the Opportunity is not new
      opportunityId = opportunityId.replace("{", "").replace("}", "");
      
      // Get the Account (Customer Field) from the Opportunity
      var accountLookup = formContext.getAttribute("parentaccountid"); 
      if (accountLookup != null && accountLookup.getValue() != null) {
      var account = accountLookup.getValue()[0]; 
      var accountId = account.id;
      
      // Retrieve the statuscode and compare currencies only if the opportunity is open
      Xrm.WebApi.retrieveRecord("opportunity", opportunityId, "?$select=statuscode").then(
      function success(result) {
      var opportunityStatus = result.statuscode; 
      if (opportunityStatus === 1) { 
      console.log("Opportunity is open. Proceeding with currency check.");
      
      // Retrieve the currency from the related Account
      Xrm.WebApi.retrieveRecord("account", accountId, "?$select=transactioncurrencyid&$expand=transactioncurrencyid($select=currencyname)").then(
      function success(result) {
      if (result.transactioncurrencyid != null) {
      var accountCurrencyId = result.transactioncurrencyid.transactioncurrencyid.toLowerCase(); 
      
      // Get the Currency field from the Opportunity
      var opportunityCurrencyLookup = formContext.getAttribute("transactioncurrencyid"); 
      if (opportunityCurrencyLookup != null && opportunityCurrencyLookup.getValue() != null) {
      var opportunityCurrency = opportunityCurrencyLookup.getValue()[0]; 
      var opportunityCurrencyId = opportunityCurrency.id.replace("{", "").replace("}", "").toLowerCase(); 
      var opportunityCurrencyName = opportunityCurrency.name; 
      console.log("Opportunity Currency Name: " + opportunityCurrencyName + " | Currency Id: " + opportunityCurrencyId);
      
      // Compare the Opportunity currency with the Account currency
      if (accountCurrencyId !== opportunityCurrencyId) {
      console.log("Currencies do not match. Updating Opportunity currency to match Account currency.");
      
      // Update the Opportunity currency to match the Account currency
      formContext.getAttribute("transactioncurrencyid").setValue([{
      id: accountCurrencyId, 
      name: result.transactioncurrencyid.currencyname, 
      entityType: "transactioncurrency"
      }]);
      
      // Save the form after the currency is updated
      formContext.data.entity.save();
      } else {
      console.log("Currencies match. No update required.");
      }
      } else {
      console.log("No currency is associated with this opportunity.");
      }
      }
      },
      function(error) {
      console.log("Error retrieving account currency: " + error.message);
      }
      );
      } else {
      console.log("Opportunity is not open. No currency update will be performed.");
      }
      },
      function(error) {
      console.log("Error retrieving opportunity status: " + error.message);
      }
      );
      } else {
      console.log("No account is associated with this opportunity.");
      }
      }
  2. Save and Publish the Web Resource:
    • Click Save and then Publish the web resource.

Step 3 : Add the JavaScript to the Opportunity Form for the Account Field onChange Event

In addition to loading the script when the form is loaded, we’ll also trigger it when the Account field is changed by the user.

1. Go to the Opportunity Form Editor:

  • In the solution editor, select the Opportunity entity, and click on Forms.
  • Open the Main form for editing.

2. Add the JavaScript Web Resource to the Form (if not already added):

  • If you’ve already added the currencySync.js web resource in the previous steps, you don’t need to do this again.
  • If not, click on Form PropertiesForm LibrariesAdd, and select the currencySync.js web resource.

3. Attach the Function to the Form Load Event (if not already done):

  • In the Event Handlers section under Form Properties, add the function as before for the OnLoad event.
  • Make sure to set the correct event handler details:
  • Do the same for On Save, so when the opportunity is saved, the function will check if the currency needs to be updated.

4. Attach the Function to the Account Field onChange Event:

  • In the Form Editor, locate the Account field (which is the parentaccountid field in Dynamics).
  • Double-click on the Account field, or select it and click Change Properties.
  • Go to the Events tab of the field properties.
  • Under Field Events, click Add.
  • In the Library dropdown, select the currencySync.js library (if not already added).
  • In the Function Name field, enter getDetailsFromOpportunity (the same function name as used for the onLoad event).
  • Uncheck the box that says “Pass execution context as the first parameter,” if it’s checked.
  • Click OK to save the event handler for the Account field’s onChange event.

5. Save and Publish the Form:

  • Save the changes made in the form editor.
  • Click Publish to make the changes live in Dynamics 365.

Testing the onChange Event

Now, your JavaScript function will be triggered both when the Opportunity form loads and when the Account field is changed.

Test the Functionality:

  1. Open an Opportunity in Dynamics 365.
  2. Change the Account value, and ensure that the script compares the Opportunity currency with the new Account currency.
  3. If the currencies don’t match, the Opportunity currency should update automatically.

Have any questions on this script, or happy that it worked for you? Leave a comment below!

AccessOrange is a leading Microsoft Partner that specializes in Microsoft 365, Dynamics 365 and Azure to help our customers work smarter.
If you need help with building this solution in your own environment, leave your contact information below, and we will contact you as soon as possible.

"*" indicates required fields

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.
This field is for validation purposes and should be left unchanged.