Announcements
Hi
I have a requirement of updating the Email address field of contact information for each store number in Retail module , i tried with different jobs but i am not getting the Expected result.
Job that i created in AX2012:
DirPartyTable dirparty;
DirPartyLocation dirPartyLocation;
LogisticsElectronicAddress elecAddress;
LogisticsElectronicAddressRole elecAddressRole;
LogisticsLocationRole locRole;
RetailChannelTable rct;
RetailStoreTable rst;
CustTable cust = CustTable::find('9999999');
//while select cust
// where cust.AccountNum != " "
//{
select forUpdate firstOnly elecAddress
where elecAddress.Location == DirPartyLocation::findOrCreate(cust.Party, 0).Location
&& elecAddress.Type == LogisticsElectronicAddressMethodType::Email
//&& elecaddress.IsPrimary==NoYes::Yes
join rct where rct.DefaultCustAccount==Cust.AccountNum
join rst where rst.RecId==rct.RecId
&& rst.StoreNumber=="6903";
if (elecAddress.RecId)
{
info(strFmt("%1 , %2 - email - %3", rst.StoreNumber, cust.name(),elecAddress.Locator));
ttsBegin;
elecAddress.Type = LogisticsElectronicAddressMethodType::Email;
elecAddress.Locator = 'apr@xxx.com';
elecAddress.update();
ttsCommit;
info(strFmt("%1 , %2 - email - %3", rst.StoreNumber, cust.name(),elecAddress.Locator));
}
Hi mahiims18,
Can you tell what is currently wrong with this attempt? Do you get an error? What is the current behavior? Did you use the debugger to find out where you possibly need to adjust the script?
Your requirement is about updating email addresses for all stores, but you are selecting only one.
Moved to the AX2012 forum.
André Arnaud de Cal...
294,120
Super User 2025 Season 1
Martin Dráb
232,871
Most Valuable Professional
nmaenpaa
101,158
Moderator