最近遇到这样一个需求,在实施的时候把系统现有的三个纬度前两个分别用于记录分公司和部门,在做财务凭证或者销售采购订单的时候,需要给这些表相应的Dimension字段的前两个纬度赋值,用户要求根据当前用户所属的分公司和部门直接赋值,而不想自己去选择。
[分析] 最直观的想法就是修改各个表的InitValue()方法,给相应的表赋初值,不过这样的工作量有些大,要修改多个表,并且当需要赋初值的表增加时还需要继续修改相应的表。
AX中用Map实现表方法的共享,于是考虑用Map来实现这个功能。
只有Map还是不行的因为InitValue()这个方法还是在各个表上的,好在AX为了使用模板,所有的initValue()方法都会调用类classFactory的CreateRecord()方法,所以可以把代码添加到这里。
[解决方案]1.创建DimensionMap
创建名为DimensionMap的Map,添加字段Dimension,设定其EDT属性为Dimension,然后把需要设定初始值的表与该Map用Dimension字段建立影射。
2.写一个工具类SysUtility,添加根据当前用户获取部门和分公司的方法
http://www.cnblogs.com/Farseer1215/archive/2007/04/20/721585.html





































































没有评论:
发表评论