static void CreatePhoneExample(Args _args) { CustTable custTable = CustTable::find('100013'); // TODO - Change to your customer LogisticsElectronicAddress logisticsElectronicAddress; container defaultRole = map2Con(LogisticsLocationEntity::getDefaultLocationRoleFromEntity(tableNum(DirPartyTable))); setPrefix(strFmt("Creating/Updating number for customer %1", custTable.AccountNum)); // This will find/create a number for a customer ttsBegin; logisticsElectronicAddress.Type = LogisticsElectronicAddressMethodType::Phone; logisticsElectronicAddress.Locator = '555-555-5555'; logisticsElectronicAddress.Location = DirPartyLocation::findOrCreate(custTable.Party, 0).Location; // This will find or create the new logisticsElectronicAddress // If it does not find it, it will do a .insert() which will only persist these fields (Location, Type, Locator, LocatorExtension) // so if you want to set the Description or if it's primary or not, you will need to update the record after this call logisticsElectronicAddress = LogisticsElectronicAddress::findOrCreate(logisticsElectronicAddress); // We re-select it for update in case this isn't a new number and it found an existing // because the "find" doesn't "select for update" logisticsElectronicAddress = LogisticsElectronicAddress::findRecId(logisticsElectronicAddress.RecId, true); logisticsElectronicAddress.Description = "New Primary Phone"; // If you set the number to primary, during the insert/update it will handle unassigning previously // marked primary numbers if they exist logisticsElectronicAddress.IsPrimary = NoYes::Yes; logisticsElectronicAddress.update(); // At this point, we need to mark the "purpose" of the number. I'm just using the default role, which should be "Business" LogisticsEntityLocationRoleMap::createEntityLocationRoles(tableNum(LogisticsElectronicAddressRole), logisticsElectronicAddress.RecId, conPeek(defaultRole, 1), true); info(strFmt("Created/updated phone number [%1] for customer %2.", logisticsElectronicAddress.Locator, custTable.AccountNum)); ttsCommit; }
This technical blog will be about my adventures with Microsoft Dynamics 365 for Operations (AX7/D3fo), AX 2012, and AX 2009.
Monday, May 11, 2015
How to create/update a phone number for a customer/vendor in X++ [AX 2012]
As a follow-up to my last post about finding phone numbers, here is sample code of how you can properly find/create/update a phone number for a customer/vendor.
Subscribe to:
Post Comments (Atom)
In my case it's not updating an existing entry, is creating a new.
ReplyDeleteHello Alex,
ReplyDeletecontainer defaultRole map2Con(LogisticsLocationEntity::getDefaultLocationRoleFromEntity(tableNum(DirPartyTable)));
How can get "Invoice Email" role in the purpose instead of defaultRole i.e. Business
Kindly advice
Thanks,
shankar :)
his is the exceptional component for the customer. It is exceptionally cutting-edge framework and that organization all inclusive instant to customers for phone number deciphering service.how expensive is a 0800 line?
ReplyDeleteComplete selection of telephone jack adapters are now being offered by retailers, compatible to your laptop and modem, for your worldwide travel. free business calls
ReplyDeleteThis is quite a new free SMS service, online in 2010 I think. It's free for india users only but you can send cheap SMS to other parts of the world if you buy credits bestmobilenumbertracker.com/free-sms
ReplyDeleteA regular phone directory is basically used to obtain the phone number of a certain individual through the use of his or her name or address while a reverse cell phone lookup service works the other way around. this contact form
ReplyDeleteSooner or later, you will probably need to utilize a turn around phone number look into; more often than not, individuals utilize this support of discover name from phone number, if the show on their phone does not demonstrate who is calling. free-lookup.net
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteThank you very much for this great post. Phone directory
ReplyDeleteWorked perfectly. Thanks for this man.
ReplyDeleteThis is not just a mere piece of work. This is ART.
ReplyDeleteyahoo finance
In the event that you are US national then you don't have to stress at all as there are a lot of online administrations that will give you tracking administrations to GPRS actuated PDAs. localiser un portable gratuitement grace a son numero
ReplyDeleteI really appreciate the kind of topics you post here. Thanks for sharing us a great information that is actually helpful. Good day! For more info click here about telephone number search...
ReplyDeleteHe is confident to the point that his arrangements and recommendations will accumulate constructive reaction and trust among the organization's key people.https://www.techpally.com/caller-name-announcer/
ReplyDeleteSuperb examining .Thanks for sharing. It's late finding this show up. https://callgear.com/product/calls-tag/
ReplyDeleteThanks for posting this info. I just want to let you know that I just check out your site and I find it very interesting and informative. I can't wait to read lots of your posts. Sony Xperia cases
ReplyDeleteWow! Such an amazing and helpful post this is. I really really love it. It's so good and so awesome. I am just amazed. I hope that you continue to do your work like this in the future also https://locateanumber.com
ReplyDeleteI haven’t any word to appreciate this post.....Really i am impressed from this post....the person who create this post it was a great human..thanks for shared this with us. legal entity identifier
ReplyDeleteVery informative post! There is a lot of information here that can help any business get started with a successful social networking campaign. https://www.phonenumber-track.com
ReplyDelete