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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Address not saved in contact

(0) ShareShare
ReportReport
Posted on by

Hi,

I have created a plugin such that whenever an account created, a default contact will be created. It created successfully, but below red marked fields are not saved. Can you please tell me why ?

public void Execute(IServiceProvider serviceProvider)

{
try
{
IPluginExecutionContext _context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
IOrganizationServiceFactory _servieFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
IOrganizationService _organizationService = _servieFactory.CreateOrganizationService(_context.UserId);
if (_context.InputParameters.Contains("Target") && _context.InputParameters["Target"] is Entity)
{
Entity entityAccount = (Entity)_context.InputParameters["Target"];
Entity entityContact = new Entity("contact");
entityContact["firstname"] = "abc";
entityContact["lastname"] = "xyz";
entityContact["jobtitle"] = "Consultant";
entityContact["emailaddress1"] = "abc@gmail.com";
entityContact["address1_line1"] = "new address1";
entityContact["address1_line2"] = "new address2";
entityContact["address1_line3"] = "new address3";
entityContact["address1_city"] = "new city";
entityContact["address1_postalcode"] = "123456";
entityContact["parentcustomerid"] = new EntityReference("account", entityAccount.Id); ;
_organizationService.Create(entityContact);
}
}
catch (Exception ex)
{
throw ex;
}
}

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    RaviKashyap Profile Picture
    55,410 Moderator on at

    Hi Anandh,

    There is nothing wrong in your code. If the contact record is getting created then it will have the address fields.

    1) Try creating a contact manually and see if address fields are visible. There may be some other process which is setting the these values as well.

    2) Is it possible that you are looking for these values in some other address fields say address2_line1?

    Hope this helps.

  • Mahendar Pal Profile Picture
    45,095 on at

    In addition to that make sure there is not client side code which is making these fields null in case it's blank when you open this record, did you check these fields under advanced find ?? in case these fields are blank on the form check if these values available over advanced find or not.

  • Suggested answer
    Aric Levin - MVP Profile Picture
    30,190 Moderator on at

    Try the following:

    1. You can also add tracing to your code to validate values. Make sure that values exist in what you are placing in the address1_line1/2/3/city fields (as I am pretty sure you are not putting "new_address..." in the fields.

    2. After you create the contact record, call the retrieve function on it, and check the values of those fields (prior to the plugin finishing the exection).

    3. You can also try this from a console application, and see if you are getting the same results. Get the Guid of an account, and create a contact record that is associated with it. See if the address is there.

    4. Enable Audit History on the Contact entity, and check for value changes in those fields.

    Hopefully one of these will work.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
ScottDurow Profile Picture

ScottDurow 2

#2
GJones Profile Picture

GJones 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans