Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

How to use AfterPrimaryImport function present in Package Deployer

Posted on by 700

I have a requirement to update data in target environment after solution import using package deployer. Microsoft provided a method called "AfterPrimaryImport" which gets a call after solution import in the target environment. I want organisation proxy in this method to update my data. You can refer this post for your reference https://msdn.microsoft.com/en-in/library/dn688182.aspx  

*This post is locked for comments

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to use AfterPrimaryImport function present in Package Deployer

    Hi Mihir,

    The PackageTemplate class that contains the AfterPrimaryImport method has a property named CrmSvc which is of type CrmServiceClient and implements IOrganizationService.

    You can use this service to make whichever calls you need to make against your instance.

    One possible implementation follows:

    In your PackageTemplate class:

    public override bool AfterPrimaryImport()
    {
        return new PostDeployCommands(this).Execute();
    }

    Then in your PostDeployCommands class:

    public PostDeployCommands(PackageTemplate packageTemplate)
    {
        this._traceLogger = packageTemplate.PackageLog;
        this._organizationService = packageTemplate.CrmSvc;
    }
    
    public bool Execute(){
        // Do whatever you need to do here.
        // You now have access to logging and the organization service.
        ...
        return isSuccessful;
    }

    Hope this helps! :)

  • dpkr28 Profile Picture
    dpkr28 135 on at
    RE: How to use AfterPrimaryImport function present in Package Deployer

    Hi Mihir,

    I have the same requirement , could you please let me know any updates on this ??

    Thanks 

  • Suggested answer
    a33ik Profile Picture
    a33ik 84,323 Most Valuable Professional on at
    RE: How to use AfterPrimaryImport function present in Package Deployer

    Hello Mihir,

    We use this method and we get service in following way:

               var service = GetOrgService();

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

Featured topics

Product updates

Dynamics 365 release plans