web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Suggested Answer

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

(0) ShareShare
ReportReport
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;
}

I have the same question (0)
  • Suggested answer
    Nya Profile Picture
    29,060 on at

    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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
Siv Sagar Profile Picture

Siv Sagar 93 Super User 2025 Season 2

#2
#ManoVerse Profile Picture

#ManoVerse 80

#3
Martin Dráb Profile Picture

Martin Dráb 64 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans