Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics 365 | Integration, Dataverse...
Answered

How to Populate Global Option Sets With Data In the Middle of an AppSource Deployment?

Posted on by 1,579

I have a D365 App that I need to deploy via AppSource.

I have an AppSource Visual Studio Project.

I am currently at the step “Create an App Source Package for your software” as detailed here: https://docs.microsoft.com/en-us/powerapps/developer/data-platform/create-package-app-appsource

I have the package and it deploys without error using the Package Deployment Tool.

However, at the end of the deployment, several workflows do not start because they are dependent on DATA being present in the global option sets that get installed as part of deployment package.

I need to understand how I can populate data into the global option sets as part of the deployment process.  

In Exhibit 1A below, which shows the ImportConfig.xml file in the deployment package, there are a series of pre-requisite solution files that get installed during the deployment process.

The 13th solution contains only the option sets.

    

The 14th solution (final solution) contains the rest of the application including the workflows that are dependent on the values existing in the option sets installed above.


My questions are:

  1. How exactly can I insert data into these option sets so that they contain all the values required after the 13th solution is installed and BEFORE installing the 14th solution to ensure the data is present?
  2. Can this all be done in the ImportConfig.xml file?
  3. If yes, what specifically must I change in the ImportConfig.xml file in Exhibit 1A below?
  4. If I need to do something in the PackageTemplate.cs file, what exactly must I do and where must I do it?

It would be great if someone could provide some code to help get me started.

I have provided a copy of my PackageTemplate.cs file in Exhibit 2A below.

EXHIBIT 1A


  
    
    
    
    
    
    
    
    
    
    
    
    
    
    
  

EXHIBIT 2A

using Microsoft.Uii.Common.Entities;
using Microsoft.Xrm.Tooling.PackageDeployment;
using Microsoft.Xrm.Tooling.PackageDeployment.CrmPackageExtentionBase;
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ACEServiceTechAppSource
{
    /// 
    /// Import package starter frame. 
    /// 
    [Export(typeof(IImportExtensions))]
    public class PackageTemplate : ImportExtension
    {
        /// 
        /// Called When the package is initialized. 
        /// 
        public override void InitializeCustomExtension()
        {
            // Do nothing.  

            // Validate the state of the runtime settings object.  
            if (RuntimeSettings != null)
            {
                PackageLog.Log(string.Format("Runtime Settings populated.  Count = {0}", RuntimeSettings.Count));
                foreach (var setting in RuntimeSettings)
                {
                    PackageLog.Log(string.Format("Key={0} | Value={1}", setting.Key, setting.Value.ToString()));
                }

                // Check to see if skip checks is present.  
                if (RuntimeSettings.ContainsKey("SkipChecks"))
                {
                    bool bSkipChecks = false;
                    if (bool.TryParse((string)RuntimeSettings["SkipChecks"], out bSkipChecks))
                        OverrideDataImportSafetyChecks = bSkipChecks;
                }
            }
            else
                PackageLog.Log("Runtime Settings not populated");
        }

        /// 
        /// Called Before Import Completes. 
        /// 
        /// 
        public override bool BeforeImportStage()
        {
            return true; // do nothing here. 
        }

        /// 
        /// Called for each UII record imported into the system
        /// This is UII Specific and is not generally used by Package Developers
        /// 
        /// App Record
        /// 
        public override ApplicationRecord BeforeApplicationRecordImport(ApplicationRecord app)
        {
            return app;  // do nothing here. 
        }

        /// 
        /// Called during a solution upgrade while both solutions are present in the target CRM instance. 
        /// This function can be used to provide a means to do data transformation or upgrade while a solution update is occurring. 
        /// 
        /// Name of the solution
        /// version number of the old solution
        /// Version number of the new solution
        /// Solution ID of the old solution
        /// Solution ID of the new solution
        public override void RunSolutionUpgradeMigrationStep(string solutionName, string oldVersion, string newVersion, Guid oldSolutionId, Guid newSolutionId)
        {

            base.RunSolutionUpgradeMigrationStep(solutionName, oldVersion, newVersion, oldSolutionId, newSolutionId);
        }

        /// 
        /// Called after Import completes. 
        /// 
        /// 
        public override bool AfterPrimaryImport()
        {
            return true; // Do nothing here/ 
        }

        #region Properties

        /// 
        /// Name of the Import Package to Use
        /// 
        /// if true, return plural version
        /// 
        public override string GetNameOfImport(bool plural)
        {
            return "ACE Service Tech App";
        }

        /// 
        /// Folder Name for the Package data. 
        /// 
        public override string GetImportPackageDataFolderName
        {
            get
            {
                // WARNING this value directly correlates to the folder name in the Solution Explorer where the ImportConfig.xml and sub content is located. 
                // Changing this name requires that you also change the correlating name in the Solution Explorer 
                return "ACEServiceTechApp";
            }
        }

        /// 
        /// Description of the package, used in the package selection UI
        /// 
        public override string GetImportPackageDescriptionText
        {
            get { return "Aloye Computer Enterprises - ACE Service Tech App for D365"; }
        }

        /// 
        /// Long name of the Import Package. 
        /// 
        public override string GetLongNameOfImport
        {
            get { return "Aloye Computer Enterprises - ACE Service Tech App for D365"; }
        }


        #endregion

    }
}

Any help, including some code to get me started would be greatly appreciated as I am diving into brand new territory here. 

  • LuHao Profile Picture
    LuHao 40,872 on at
    RE: How to Populate Global Option Sets With Data In the Middle of an AppSource Deployment?

    Glad it was resolved.

  • Verified answer
    ACECORP Profile Picture
    ACECORP 1,579 on at
    RE: How to Populate Global Option Sets With Data In the Middle of an AppSource Deployment?

    Apparently, the global option sets install fully populated.

    I supposed in my haste I have jumped-the-gun. 

    This is a non-issue.

    Problem solved!

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!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans