Thursday, August 4, 2011

How to change a customer's party type

I often see customers that are created wrong in client's systems.  They will have a party type of "organization" when they should really have "person" or vice versa.  The difference between the two, as far as I can tell, is that organizations are permitted to have multiple contacts, and other little things like that, while person types are supposed to be simpler.

Here is a little static method I wrote to change their party type.  One thing to worry about, when you go from Organization to Person, you may want to check if there are multiple contacts before you make the change.  Not exactly sure what it will do.

static server boolean changeCustPartyType(CustTable _custTable, DirPartyType _dirPartyType)
    CustTable       custTable;

    if (_custTable && _custTable.PartyType != _dirPartyType)


        custTable.PartyType = _dirPartyType;


        DirParty::updatePartyFromCommon(custTable.PartyId, custTable, DirSystemPrivacyGroupType::Public, true);




        smmTransLog::initTrans(custTable, smmLogAction::update);


        return true;

    return false;


  1. What does the three last method calls before ttscommit do?

    1. Great Article IoT Projects for Students

      Deep Learning Projects for Final Year

      JavaScript Training in Chennai

      JavaScript Training in Chennai

      The Angular Training covers a wide range of topics including Components, Angular Directives, Angular Services, Pipes, security fundamentals, Routing, and Angular programmability. The new Angular TRaining will lay the foundation you need to specialise in Single Page Application developer. Angular Training

  2. Hi Alex..

    I'm have a same problem with your posting but my problem is at dynamics ax 2012. while your method for ax 2009.

    Please your advice
    method change party for dynamics ax 2012.

    Thanks before and best regards,


  3. The is missing something, because after executed, there is not record in the tabla DirOrganizationDetail...

    I added the following lines to create the record there:

    dirParty = DirParty::constructFromCommon(custTable);
    dirOrganizationDetail = DirOrganizationDetail::find(custTable.PartyId,true);
    if (!dirOrganizationDetail)

    //Add before the following line
    DirParty::updatePartyFromCommon(custTable.PartyId, custTable, DirSystemPrivacyGroupType::Public, true);

    best regards,

  4. Hi Alex,

    Thanks for your suggestion, it pointed me in the right way to go for my scenario. Taking a look at the MSDN documentation here

    you realise that you need to create a new DirPartyTable record with the new type that you want. So you can use the following code:

    newDirPartyTable = DirPartyTable::createNew(DirPartyType::Organization, _customerName);

    Once you have created your new DirPartyTable record with the correct type, you need to assign and modify all of the original values you had from your old DirPartyTable record:
    Taking the example of primary address:

    newDirPartyTable.PrimaryAddressLocation = oldDirPartyTable.PrimaryAddressLocation
    custTable.Party = newDirPartyTable.RecID
    DirPartyLocation.Party = newDirPartyLocation.RecId


    Thus, with the above model, you can modify contact information and anything else you have configured on your customer.


    1. Thanks for the feedback Sid. This blog post was a method for AX 2009 and it's been ~4 years since I've looked at it, but good info, and hopefully your comments will help someone else.

  5. This is my first time i visit here and I found so many interesting stuff in your blog especially it's discussion, thank you. Walmart Customer Service

  6. This is my first visit to your web journal! We are a group of volunteers and new activities in the same specialty. Website gave us helpful data to work. Oyo Customer Care

  7. Awesome blog. I enjoyed reading your articles. This is truly a great read for me. I have bookmarked it and I am looking forward to reading new articles. Keep up the good work! Sentiment Analysis

  8. Doing this will allow the caller know what the customer service representative is about to do. outsource customer service philippines

  9. With so many super hero and comic book movies being made it only seems a matter of time before the market becomes over saturated. And it seems that time could be sooner than we imagine as even those in the movie industry start to question when the super hero bubble will burst. Miamisuperhero reviews

  10. many vendors who earlier specialized in on site CRM only are now selling customized web based CRM tools and CRM software applications to improve their sales figures. Find Out More