DimensionValuesLookup on my own EDT - axapta

I need to create an EDT that will use DimnesionValuesLookup.
So I've made an EDT with reference to my View that has DisplayValues for my specific dimension type, also I set formHelp property as DimnesionValuesLookup. And when I'm trying to open lookup on query search criteria I get an error:
Form should be called with parameters
I looked into the Init() method of DimnesionValuesLookup and found out that I need to pass DimensionAttribute as a record.
How can I do this?

Your comment did not answer my question, but I'm assuming you have a way to identify the name of the attribute for which you want to lookup values. Using the name you can select the DimensionAttribute record that you need to call the lookup form by using the findByName method of table DimensionAttribute. After that you can call the lookup form. Standard AX does something very similar in form DimensionValueInterval, take a look at the lookup method there.

Related

Posting new field to CustTrans

I created a new field in LedgerJournalTrans(General Ledger > General Journals menu), but click on Post but was unable to get my new field value in the CustTrans, is there any method i need to update to post my new field value to the CustTrans?.
Your question is not clear, but I think I can guess what you're trying to do? You've added a field to the table LedgerJournalTrans and when you post, you're expecting that data to carry over to the CustTrans table? You should work on asking clearer questions, but if my interpretation is correct, then you need to add code so that the posting process does something with that field.
Likely you'll need to modify \Classes\LedgerJournalTransUpdateCust, specifically you'll want to look at methods postNewCustomerVoucher and updateNow.
Find where \Data Dictionary\Tables\LedgerJournalTrans\Fields\CustTransId gets set, as that's the relation between the two tables, and try to write code that follows that Microsoft is doing.

How to copy the description value of a lookup to another field?

I have a grid called myGrid. The column A of myGrid is a lookup that shows 2 values: the code, and the description.
I would like to copy the selected item's description into a second column of myGrid.
What would be the best way to do this?
I have encountered this sometimes ago and the solution I found is a bit complicated but works fine.
I had to create a form from scratch which is currently used in the lookup.
When calling the form in the lookup() method, don't forget to put "element" in the arguments.
In the init method of the new form, use element.selectMode(YourTable.Code) to specify which field will be selected. Override the closeSelect() method of the new form and make it call a parm method located in the caller form. This parm method will set the YourTable.Description field of the current record. Send the Description related to the record from YourTable selected by the user in the lookup.
The new form should be a window of type Popup, with the toolbar hidden and always on top. Its datasource should be YourTable.
Call the new form from the lookup method (or better, from a method at the table level called from the lookup method) using ClassFactory.formRunClass(args).
I found a 'simple' solution: i've to simply override the method modifieldfield

How to describe (enumerate) picklist enties valid for a specific record type in Salesforce?

In apex code I want to enumerate the legal values for a picklist field. To do this I can just call Account.Foobar__c.getDescribe().getPickListValues() and I've got a list of Schema.PickListEntry values.
However it's possible to setup multiple record types for a given sObject. For example Account might have "Manufacturer", "Distributor" and "Retailer" record types. In the Salesforce setup it is possible edit (limit) the picklist entries for each field based on record type. So Retailer type accounts might only use a subset of the picklist values for the Foobar field.
So basically I want Account.Foobar__c.getDescribe().getPickListValues('Retailer') however this is not the syntax. The validFor method looks promising, but it seems like it is only for field dependent picklists - a picklist filtered only by record type returns false for isDependentPicklist.
I know this is an old post, but maybe the info below will help someone who still needs the answer.
I found here that one can actually get a list of record type specific picklist values by making a describeLayout() call.
Using your example (C#):
DescribeLayoutResult result = binding.describeLayout("Account", new string[] { "01230000000xxXxXXX" } );
PicklistEntry[] values = result.recordTypeMappings[0].picklistsForRecordType[12345].picklistValues;
Replace "01230000000xxXxXXX" with a RecordTypeId of your Retailer record type object. Use the query "SELECT Id FROM RecordType WHERE Name = 'Retailer'" to get the value.
Replace 12345 with an index of your picklist object that you would like to get values of.
You can't do it in pure Apex AFAIK, unfortunately. The metadata API does expose it.
Related opinions: http://boards.developerforce.com/t5/Apex-Code-Development/Any-way-to-obtain-picklist-values-by-record-type/td-p/287563

How to Create Custom Function for DevExpress XtraReports Calculated Field

I know how to create Custom Fields in a DataSet for a Report in DecExpress XtraReports.
But I need to Declare a Custom Function in available function list for Calculated Fields. I do not know how to solve this problem.
source type : Date
result : Date String In other Calendar Formats
source type : TinyInt (Enumeration)
result : Custom Enumeration Value Name
As per Q232469 and S132091 it isn't supported without using Scripts. However in saying that the Expression Editor does allow for Custom Functions as per Implementing Custom Functions I would look at this sample How to: Implement a Custom Criteria Language Operator and see if it does what you need.
Otherwise the suggestion is to add a Calculated Field then in your Script override the returned value of that Calculated Field see Calculated Fields
Hope this helps

Range on integer fields in Axapta/Dynamics Ax

Is there a way, in Axapta/Dynamics Ax, to create an Extended Data Type of type integer which only allows enering values in a specified range (i.e., if the extended data type is meant for storing years, I should be able to set a range like 1900-2100), or do I have to manage the range using X++ code?
And if I need to use X++ code to manage the range, which is the best way to do it?
I suggest you use the ''validateField'' of the corresponding table.
Search for the method in AOT\Data Dictionay\Tables to see many examples.
You can can't specify the range on the extended data type itself. If the type is used for a table field, you can add code to the insert and update methods of the table, in order to validate the value whenever the record is updated. This approach could however have a cost in terms of performance.
You can also choose to just add code the the validateWrite method of the table, if you are satisfied with the validation only taking place when the value is modified from the UI.

Resources