Change Dimension Display

Source: Internet
Author: User
Tags unpack
Ax has a very good function to hide or display a dimension, such as a warehouse, a warehouse location, and a batch number. Such operations are available in almost all forms that involve services, for example, the sales, purchase order line, inventory log, item quantity, and Other forms can all be set by the inventory-> Dimension Display button. This function is okay in most cases, but sometimes users want to display specific dimensions each time they enter. This is a bit confusing, of course, we can ask the user to select the Save settings in the Dimension Display form, but because ax's function relies on the syspackable interface, its implementation mechanism is the same as that of the runbase storage user, so all users must perform similar actions on each form. In fact, some companies have similar material dimensions. For example, they only have warehouse dimensions. It is really cool to require every user to perform the same actions on every form, several colleagues have discussed this issue with me and I will record it here.

We know that in the runbase framework, if the syslastvalue table does not save the user's SELECTION record, that is, if the user is operating on a form or report for the first time, ax uses initparmdefault to initialize some values. In ax, whether to control dimension display is implemented through inventdimctrl and a series of its sub-classes. The direct sub-class inventdimctrl_frm implements the syspackable interface to save user input. Like saving user input in the runbase framework, inventdimctrl_frm also reserves the initparmdefault method. Because the implementers at the Sys layer do not know which dimensions the companies that use ax need to display, so he cannot write in this method either.CodeSo this method is not implemented.VoidInitparmdefault ()
{

}

If we know which dimensions need to be displayed during implementation, we can write code here, such as the following code: Void Initparmdefault ()
{
;
// Add the inventdim to display
Dimparmvisiblegrid. inventcoloridflag = Noyes: yes;
Dimparmvisiblegrid. inventlocationidflag = Noyes: yes;
Dimparmvisiblegrid. inventbatchidflag = Noyes: yes;
Dimparmvisiblegrid. wmslocationidflag = Noyes: yes;
}

Note that here is a difference from runbase. In runbase, The initparmdefault method is called only when the user has not performed any operation on the form. Once the operation is completed, records are recorded in syslastvalue, in this case, the initparmdefalut method will not be called. This is because if the syslastvalue table has a corresponding value, the Unpack method returns true when it is restored through the Unpack method, in the get method of xsyslastvalue, the system determines whether to call the initparmdefault Method Based on the return value of the Unpack method. Generally, the system returns false only when the corresponding record is not found in the syslastvalue table, therefore, initparmdefault is called, but the Unpack method of the class inventdimctrl_frm is called.

Public Boolean unpack (container packedclass)
{
Int Version;
Container C;

If (Overrideusersetup)
Return   False ;

If ( ! Packedclass)
Return   False ;

// Is 5 for version 2.5 and earlier
If (Conlen (packedclass) =   5 )
{
If (Inventdimfixedclass: inventdimparm2inventdimfixed (dimparmvisiblegrid) = Conpeek (packedclass, 1 ))
Return   False ;

Inventdimfixedclass: inventdimfixed2inventdimparm (conpeek (packedclass, 1 ), Dimparmvisiblegrid );
Dimparmvisiblegrid. configidflag = Conpeek (packedclass, 2 );
Dimparmvisiblegrid. itemidflag = Conpeek (packedclass, # itemidflag );
Dimparmvisiblegrid. closedflag = Conpeek (packedclass, # closedflag );
Dimparmvisiblegrid. closedqtyflag = Conpeek (packedclass, # closedqtyflag );
Return   True ;
}

Version = Runbase: getversion (packedclass );

Switch (Version)
{
Case # CurrentVersion:
[Version, C] = Packedclass;
If ( ! C)
Return   False ;

Inventdimctrl_frm: unpackdimparm (dimparmvisiblegrid, C );
Break ;

Default :
Return   False ;
}

Return   False ;
}

We can see that the final returned false of this method will always call initparmdefault, so if you want to display a dimension in the initparmdefalut method, it is displayed based on the union of the dimension specified in initparmdefault and the dimension saved by the user last time. I am not sure whether the buddy who wrote the Sys-Layer Code intentionally did it or did it by mistake, it doesn't matter. If it is strange, let the Unpack return true. Once the user has operated the form and selected the Save setting, the initparmdefault method will not be called.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.