Change default address “Purpose” when adding a new address to existing Customer
-
Change default address “Purpose” when adding a new address to existing Customer
Posted by DSC Communities on March 15, 2017 at 12:50 pm-
Rudy Salcedo
MemberMarch 15, 2017 at 12:50 PM
When adding a new address to an existing customer, our users want the default address Purpose to be changed in the following manner:
- When adding a new address to the customer while in the customer record, the default Purpose should be changed from Business to Jobsite.
- When adding a new address to a customer while in a Sales Quotation or a Sales Order, the default Purpose should be changed from Delivery to Jobsite.
How can this be accomplished? I have searched through the LogisticsPostalAddress form, but can’t find where the Business & Delivery address Purposes are currently being specified. I don’t see anything in the Setup for Sales and marketing parameters either.
Thanks in advance.
——————————
Rudy Salcedo
LaForce, Inc
Green Bay WI
—————————— -
Matt Alford
MemberMarch 16, 2017 at 7:46 AM
Rudy,I assume this requires development to alter the default value. A developer could confirm whether or not they could simply change the default value on the field enum or if they have to change the logic used when creating the address.
——————————
Matt Alford
Sr. Manager of Information Technology
Delta Apparel
Duluth GA
——————————
——————————————- -
Dale Berta
MemberMarch 16, 2017 at 9:23 AM
I’m on 2009; looks like your address Purpose is my Address Type.The default for an enum is where the enum item value is 0. Renumbering the items for this enum is not really practical.
It should be relatively simple for your developer to do a customization in the form. When creating a new address for a customer, check to see if they have any other addresses. If not, set the address Purpose to Business. I’d probably start with the form data source’s initValue() method.
——————————
Dale Berta
Dynamics AX Technologist
Computer Aid Inc
Allentown PA
——————————
——————————————- -
I believe you will need a code mod to accomplish the change to the defaults.
As a starting point, I would suggest looking in the AOT at Data DictionaryMapsLogisticsEntityLocationMap.
Check the method LogisticsEntityLocationMap.addEntityLocation() and you will see it calls addEntityLocationRoles() at the bottom.
This uses the getEntityLocationRoleTableId() to figure out which table is used for the particular location type (Site Address, Warehouse Address, Party Address, Electronic Address, or Carrier Address).
You are interested in the Party Address, which leads you to table DirPartyLocationRole.A quick look at all the methods on that table turns up a likely candidate called createPartyLocationRoles().
Using the cross reference to see where that is used turns up an interesting option in ClassesDirPartyaddLocation()
Inside that method you’ll see it performing logic to populate the role object if it’s empty with either Business or what I assume is a delivery address.
This is probably what you need to change.
However, the hoops I’ve jumped thru here show that this is not a simple mod, and it may well be worth it to have the users do the update manually.——————————
Tony Zeigler
Strategic Solutions NW, LLC
Beaverton OR
——————————
——————————————- -
Rudy Salcedo
MemberMarch 17, 2017 at 11:18 AM
Tony, thanks for your analysis of all of the objects that are involved in the process of creating new customer addresses. It’s amazing to see how many objects are needed and how much code is involved in populating a default value on a form control. As usual, something that seems like it should be a quick/easy change is much more complicated than it really seems.I think for this specific user request, we actually want to make the code changes at the form level. I’m able to determine if the Caller of the form was CustTable, SalesTable, or SalesQuotationTable by checking the value of callerObject.name() within the updateControls() method of the LogisticsPostalAddress form. So now I just have to figure out how to “short-circuit” the form’s built-in logic when the Caller is one of the aforementioned table forms, and override the Purpose control’s default value with “Jobsite”. I’m still learning how to program in X++, so a simple change like that will take a little longer for me to figure out.
Thanks!
——————————
Rudy Salcedo
Senior Programmer/Analyst
LaForce, Inc
Green Bay WI
——————————
——————————————- -
Lloyd Dehn
MemberMarch 16, 2017 at 10:05 AM
This can be accomplished by checking the calling form in the ‘LogisticsPostalAddress’ form. We have a modification that forces the user to use One-Time address for project quotations. There’s a method on the form called ‘updateControls’ that were we did the modification. This could also be done in the init method. Using a similar method you could change the default purpose.Here’s a snippet of code:
// BIC_CR448_SiteAddress_LDehn_03/07/2015 –>
// Force One-time address when adding an address on a Quotation
if (callerObject is FormRun && !location)
{
callingForm = callerObject;
if (callingForm.name() == formStr(SalesQuotationProjTable))
{
oneTime.value(true);
oneTime.modified();
oneTime.allowEdit(false);
}
}
// BIC_CR448_SiteAddress_LDehn_03/07/2015 <–——————————
Lloyd Dehn
Dynamics AX Lead Developer
Braun Intertec
Bloomington MN
——————————
——————————————- -
Just a word of caution – You want to consider if the code should really go on the form…
Standard pattern for initializing fields would be to put the code on the insert method of the table, or on a class that assists in the operations on that table. Microsoft was following that pattern in this case, which is why he was not able to find the values being set in the init method of the form.Placing business logic on the form means it can only be run and accessed by using that specific form.
DMF, AIF, and other features would end up skipping the logic if placed on the form. That can be ok in specific cases – but you’ll want to carefully consider those cases….——————————
Tony Zeigler
Strategic Solutions NW, LLC
Beaverton OR
——————————
——————————————- -
Rudy Salcedo
MemberMarch 16, 2017 at 1:06 PM
Thank you all for the suggestions.
Lloyd, I added the code that you suggested to the updateControls method of the LogisticsPostalAddress form. I wasn’t sure where to add it, but I wanted to see the effect. When I tried adding a new address, the Purpose was blank, and I am unable to access the dropdown to select a Purpose. I understand why we would not want the user to modify the Purpose field, but how do I default a specific value in that field?
Also, when I try to edit an existing address that has a Purpose in the customer addresses fasttab, the Purpose field is also blank and the dropdown cannot be accessed. Did you have to add code so existing addresses would display their Purpose and could be modified?
——————————
Rudy Salcedo
LaForce, Inc
Green Bay WI
——————————
——————————————- -
Yannis Ferber
MemberMarch 17, 2017 at 1:03 PM
We have done a similar modification (changing the default purpose code based on the origin – Sales order creation or sales order).
We modified the method relatedLocationRole on the class LogisticsLocationEntity. We just reordered the case statement to fit our needsserver static LogisticsLocationRoleType relatedLocationRole(TableId _tableId)
{
LogisticsLocationRoleType roleType;
switch (_tableId)
{
case tableNum(SalesCreateReleaseOrderTableTmp) :
case tableNum(SalesCreateReleaseOrderLineTmp) :
case tableNum(PurchTable) :
case tableNum(PurchLine) :
case tableNum(SalesQuotationTable) :
case tableNum(SalesQuotationLine) :
case tableNum(PurchRFQCaseTable) :
case tableNum(PurchRFQCaseLine) :
case tableNum(PurchReqTable) :
case tableNum(PurchReqLine) :
roleType = LogisticsLocationRoleType::Delivery;
break;
case tablenum(SalesTable) :
case tableNum(SalesLine) :
roleType = LogisticsLocationRoleType::DropShip;
break;
case tableNum(CustInvoiceTable) :
roleType = LogisticsLocationRoleType::Invoice;
break;
case tableNum(SMAServiceOrderTable) :
roleType = LogisticsLocationRoleType::Service;
break;
}
return roleType;
}
——————————
Yannis Ferber
Biamp Systems
Beaverton OR
——————————
——————————————- -
Rudy Salcedo
MemberMarch 17, 2017 at 5:21 PM
Yannis, thanks for your suggestion. I added this code to the method you specified, but for some reason it wasn’t working:
case tableNum(CustTable) :
case tableNum(SalesTable) :
case tableNum(SalesLine) :
case tableNum(SalesQuotationTable) :
case tableNum(SalesQuotationLine) :
roleType = LogisticsLocationRoleType::Jobsite;
break;I removed the above code and added this code to the getDefaultLocationRoleFromEntity() method of the LogisticsLocationEntity class:
case tableNum(CustTable) :
case tableNum(SalesTable) :
case tableNum(SalesLine) :
case tableNum(SalesQuotationTable) :
case tableNum(SalesQuotationLine) :
locationRole = LogisticsLocationRole::findBytype(LogisticsLocationRoleType::Jobsite);
break;This is giving the desired result of the address Purpose defaulting to “Jobsite” when creating a new address from the specified table forms.
Thanks everyone, I appreciate your help!
——————————
Rudy Salcedo
Senior Programmer/Analyst
LaForce, Inc
Green Bay WI
——————————
——————————————-
DSC Communities replied 8 years, 6 months ago 1 Member · 0 Replies -
-
0 Replies
Sorry, there were no replies found.
The discussion ‘Change default address “Purpose” when adding a new address to existing Customer’ is closed to new replies.