Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics 365 | Integration, Dataverse...
Suggested answer

AppSource Package Deployment, AfterPrimaryImport, How do I get the Organization Service.

Posted on by 10

Does anybody have example code for AfterPrimaryImport code.  I want to perform CRUD on entity rows.  I cannot find a way to get the Organization Service that is not null.

With the following code I get error thrown, the CrmSvc is OK but the CrmSvc.OrganizationServiceProxy is null.

Is there another way to get the service?  The service I have declared below has all the functions I need, Update, Delete, Execute,.. and compiles.

public override bool AfterPrimaryImport()
{
if (CrmSvc == null)
throw new Exception("CrmSvc is null");

if (CrmSvc.OrganizationServiceProxy == null)
throw new Exception("CrmSvc.OrganizationServiceProxy is null");

var service = CrmSvc.OrganizationServiceProxy;

Entity entity = new Entity("contact");
entity.Id = new Guid("e8f466d4-64ff-ea11-a815-000d3a3ab828");
entity.Attributes["lastname"] = "Smith";
service.Create(entity);

return true;
}

  • Suggested answer
    Nya Profile Picture
    Nya 29,056 on at
    RE: AppSource Package Deployment, AfterPrimaryImport, How do I get the Organization Service.

    Hi,

    Since the code snippet you provided are about the exceptions and other handling after the connection instead of the connection itself, it is difficult to pinpoint the problem.

    I searched the keyword and found an article which may help you:

    Unable to Connect Dynamics CRM OrganizationWebProxyURL is null – Friyank Parikh Blog (wordpress.com)

     

    Most of the similar issues are caused by the support to TLS 1.2 in Visual Studio 2015. You may check your code to find out if you have the same problem.

    (+) Unable to Login to Dynamics CRM online via a Console application - Microsoft Dynamics CRM Forum Community Forum

     

    If this helped you, I'd appreciate it if you'd mark this as a Verified Answer, which may in turn help others as well.

    Best Regards,

    Nya

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,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans