Hiding Country Specific Fields - axapta

I have the following problem.
The LogisticsPostalAddress form is displaying the StreetInKana field. (this holds special characters used in Japan". The underlying EDT extends an EDT which has 'JPN' in the CountryRegionCodes property. The company I am using has primary address with country'GBR'. My understanding is that this should mean the field would be hidden, but it is not. So far we have made very few changes to standard AX code, and nothing that would be related. So either I have set something up wrong, or these fields are meant to be displayed, which would surprise me. Any ideas?

You have to change the property CountryRegionContextField of the corresponding control to point to the field which has CountryRegionCodes value set (either on table level, or EDT level).
I guess you have to explicitly set this property because you can have different forms with the same table as data source, but restrict access only on some of them.

Related

Display label based on, field on one data-source (singular) being within another data-source fields many

I am still learning, and looking for help on how to display a label based on one data-sources field value, being within another data-sources field value list.
I have one calculated table, displaying rows of documents within a folder, and wish to use a field representing the document number in that data-source, so that if it's ANYWHERE within another tables field it displays my label.
I've been trying to use projection as I think this is how to achieve it.
I can get it working based on both the current #datasouce.item.fieldnames but need it to base the calculation on all possible numbers in that tables field (Image below should make it easier to understand).
I expect that it has something to do with projections, but can't find anything within the learning templates or anywhere else to resolve the issue.
I think the following should work for you. For the 'Reserved' label have the following binding for the text property:
(#datasources.project_quotes.items..quotenumber).indexOf(#widget.datasource.item.Qnumber) !== -1 ? 'Reserved' : ''
I would suggest alternatively just to include a field in your calculated datasource and making the determination in your server script.

Why does the `FetchMode` query property remove fields from the parent data source?

When opening the query SalesTableListPage from the AOT, you can choose the field MatchingAgreement (shown as "Agreement Header record ID (Record-ID)") in the field lookup. The same is not possible for query SalesUpdate, field MatchingAgreement and several others (which seem to be related to relation fields where the relation is built with a RecId) are not shown in the lookup.
After some research I found out that the reason seems to be the FetchMode property on the joined SalesLine data source. If it is 1:n, the fields are not shown in the lookup. If it is 1:1, the fields are shown in the lookup.
I have not tested this with other tables, but I suspect the same behavior. I also have only tested this with AX 2012 R2 and R3, but I suspect the same behavior in other 2012 versions.
Why does the FetchMode of a joined data source remove some fields from the parent data source in the query dialog?
TL;DR Field lookups in the query dialog do not always work for relation fields that define relations to tables where the AutoIdentification field group's property AutoPopulate is set to No. One case where they not work is when a data source is joined with FetchMode 1:n.
While Alex K's answer has some interesting suggestions, in my case the culprit is the AutoPopulate property on the AutoIdentification field group of table AgreementHeader. In sys layer, this property is set to No and the group contains the fields that are shown in the query dialog field lookup if the relation in the query is 1:1. If this property is switched is to Yes the lookup will show field Agreement header record ID (Record-ID) (and only this field, no matter how the FetchMode of the query relation is defined).
Basically, AX will use the information from the AutoIdentification field group to determine the information shown in the gui in case of surrogate key references/relations. If the AutoPopulate property of the field group is Yes, AX will use the alternate key of the table to determine the fields to use. If no alternate key exists (which is the case for table AgreementHeader), AX uses the relation field. If AutoPopulate is No, the fields defined in the group are used. But as described this option does not work if the relation in the query is not 1:1 (and unfortunately no fallback option like using the relation field seem to have been implemented).
FetchMode AutoPopulate Lookup
1:1 Yes AlternateKey (or Relation) fields
1:1 No AutoIdentification fields
1:n Yes AlternateKey (or Relation) fields
1:n No Nothing
Update:
I came upon this problem again, but with field SalesTaker this time. Turns out that the AutoPopulate property is only part of the story, because it did not solve the problem when set to Yes on table HcmWorker. This table (unlike table AgreementHeader) also has the property ReplacementKey set, which AX uses to populate the AutoIdentification field group. Only after I removed the ReplacementKey no fields appeared anymore in AutoIdentification and the lookup now showed "Sales taker (Record ID)". So bottom line is that the AutoIdentification field group must not contain any fields.
If the dynamic property of both query fields is set to yes, then I'd suspect it has something to do with the properties of one of these relations:
\Data Dictionary\Tables\SalesTable\Relations\Agreement
\Data Dictionary\Tables\SalesLine\Relations\SalesTable
Maybe try adjusting those, refreshing your cache (AOT changes to be picked up), clearing usage data (packed queries can cause problems), and updating XRef (Advanced querying uses XRef, so may not be necessary for standard query functionality)

adding field to the combo box in assest depreciation profile form

i am new to ax2012. I have a doubt in asset depreciation profile form.There is combo box called period frequency in that, i need to add a field called monthly. Can any one help me out ?
I have tried out by creating base enum for monthly filed but i didn't get the output required.
This field is an Enum of type AssetAccrualFiscal, therefore you need to add a monthly element to this AssetAccrualFiscal in the AOT.
Beware however, the field is controlled by an edit method, and changing the field triggers some business logic.
This can be found in the table method accrualFiscal() on the table AssetDepreciationProfile. You may need to decide which part of the existing logic needs to consider your new enum element when it is selected.
See my comment, but basically you need to find out which base enum the combo box uses (supposing it is an enum combo box) and add a new element "monthly" to that enum.
If it is a standard enum, please leave a gap between the last enum element index and the index of your new element. This leaves room for new elements from Microsoft and enables easier upgrades.
Did some digging, in AX 2012 R2 there already is an element "monthly" for the period frequency combo box. Please take a look at enum "AssetAccrualCalendar" and method "accrualCalendar" on table AssetDepreciationProfile.

How can I set a schema.Datetime field to None with Dexterity

I'm writing a simple content type with Dexterity to manage customers, beside the usuals fields, eg name, company, phone...
I've also added a Datetime field to store when the first meeting with
customers has been held, lets call it 'firstmeeting', which I defined
in my interface ICustomers as:
firstmeeting = schema.Datetime(
title=_(u"First Meeting"),
required=False,
)
Now, I notice that when I saved a new Customer document the firstmeeting
field has been filled with the current date even if I don't set any date
in the form, which is not what I want because no meeting with the
customer has been held yet. So I'd like to know how to set a None value
for this field so nothing will be displayed.
I've been trying to use a custom class has explained by Martin Aspeli in
http://plone.org/products/dexterity/documentation/manual/developer-manual/advanced/classes
but I don't know how to check the user input and set None value if nothing
was typed in.
Thanks
Have you tried default=None?
I found out what was happening in my code.
Actually the problem was in the template view.pt where I used toLocalizedTime() function,
which was converting the None value to the current date, so I added a tal:condition to print the date value.
<span id="form-widgets-firstmeeting" class="datetime-widget datetime-field"
tal:condition="context/firstmeeting"
tal:content="python:context.toLocalizedTime(context.firstmeeting)" />

What is the purpose and proper use of a textfields max-length property?

What is the purpose and proper use of the max-length property on text fields?
The application I'm working on limits numeric fields to 6 characters... which doesn't work very well for entering millions of dollars... which is why I'm "fixing" it.
MaxLength Sets or receives the maximum number of characters that a user can enter into a Text control.
EDIT: You do this to prevent having to process something that you know is guaranteed to be wrong.
If you have a text field in your database that is set to 10 characters and the user enters 11 and you don't handle it properly, you cause an exception.
So, just set the maxlength to 10 and you won't have any problems like this.
The Maximum length attribute of a text field and/or textarea effectively limits the user from entering data that is outside the bounds and constraints you have set for your database.
You can use this to make sure users enter in valid SKU numbers, blog titles, ISBN numbers, etc. It is a rudimentary form of data validation.
This doesn't always need to be tied to data validation though.
You could want to limit the length of a string that a user has entered for aesthetic reasons when displaying that data on a page in another location.

Resources