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) { ttsbegin; custTable.selectForUpdate(true); custTable.data(_custTable); custTable.PartyType = _dirPartyType; custTable.setNameAlias(); DirParty::updatePartyFromCommon(custTable.PartyId, custTable, DirSystemPrivacyGroupType::Public, true); custTable.doUpdate(); smmBusRelTable::updateFromCustTableSFA2(custTable); custTable.setAccountOnVend(custTable.orig()); smmTransLog::initTrans(custTable, smmLogAction::update); ttscommit; return true; } return false; }
What does the three last method calls before ttscommit do?
ReplyDeleteHi Alex..
ReplyDeleteI'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,
Toms
The is missing something, because after executed, there is not record in the tabla DirOrganizationDetail...
ReplyDeleteI added the following lines to create the record there:
dirParty = DirParty::constructFromCommon(custTable);
dirParty.parmOrganizationInfo(true);
dirOrganizationDetail = DirOrganizationDetail::find(custTable.PartyId,true);
dirOrganizationDetail.initFromDirParty(dirParty);
if (!dirOrganizationDetail)
{
dirOrganizationDetail.insert(false);
}
//Add before the following line
DirParty::updatePartyFromCommon(custTable.PartyId, custTable, DirSystemPrivacyGroupType::Public, true);
best regards,
Hi Alex,
ReplyDeleteThanks for your suggestion, it pointed me in the right way to go for my scenario. Taking a look at the MSDN documentation here
https://technet.microsoft.com/en-us/library/Hh208963.aspx
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
update()
Thus, with the above model, you can modify contact information and anything else you have configured on your customer.
Thanks
Sid
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.
DeleteThis 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
ReplyDeleteThis 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
ReplyDeleteAwesome 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
ReplyDeleteDoing this will allow the caller know what the customer service representative is about to do. outsource customer service philippines
ReplyDeletemany 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
ReplyDelete