Axapta 将 RecId 存储为 AnyType

发布于 2024-08-14 10:21:01 字数 948 浏览 2 评论 0原文

当我将 RecId 存储在任意类型对象中时,该数字已损坏。在我的实现中,我将 RecId 存储在树视图项的数据值字段中。每当我检索数据值时,我保存的数字总是发生很大的变化。有什么建议吗?

这是一个示例:

void fillTree()
{
    ABC_Menus _ABC_Menus;
    TreeItemIdx parentItemIdx;
    ;
    while select Prompt, RecId from _ABC_Menus
    {
        parentItemIdx = SysFormTreeControl::addTreeItem(formTreeControl, _ABC_Menus.Prompt, FormTreeAdd::Root, _ABC_Menus.RecId, 0, true);
    }
}

public void endLabelEdit(int _idx, str _text, anytype _data)
{
    FormTreeItem formTreeItem = this.getItem(_idx);
    ;
    formTreeItem.text(_text);
    this.setItem(formTreeItem);
    info(_data);     //this number comes out all wrong
    super(_idx, _text, _data);
}

我将 RecId 存储在树值字段中。但是,如果我稍后检索它,则会返回一个完全不同的数字。
- 表中的记录 ID:5637144588
- endLabelEdit 方法显示的 RecId:202520592908288

在将 RecId 存储在字段中时,我还尝试使用 num2str(ABC_Table.RecId, 0, 0, 0) 。以这种方式存储时,数字匹配,但会引发“分配/比较失去精度”警告。这样可以吗,或者有更好的方法吗?

谢谢

When I store a RecId in an anytype object, the number is corrupted. In my implementation, I am storing the RecId in a treeview item's data value field. Whenever I retrieve the data value, the number I saved is always greatly changed. Any suggestions?

Here is an example:

void fillTree()
{
    ABC_Menus _ABC_Menus;
    TreeItemIdx parentItemIdx;
    ;
    while select Prompt, RecId from _ABC_Menus
    {
        parentItemIdx = SysFormTreeControl::addTreeItem(formTreeControl, _ABC_Menus.Prompt, FormTreeAdd::Root, _ABC_Menus.RecId, 0, true);
    }
}

public void endLabelEdit(int _idx, str _text, anytype _data)
{
    FormTreeItem formTreeItem = this.getItem(_idx);
    ;
    formTreeItem.text(_text);
    this.setItem(formTreeItem);
    info(_data);     //this number comes out all wrong
    super(_idx, _text, _data);
}

I am storing the RecId in the tree value field. However, if I retrieve it later, a totally different number comes back out.
- RecId in table: 5637144588
- RecId displayed by the endLabelEdit method: 202520592908288

I also tried using num2str(ABC_Table.RecId, 0, 0, 0) when storing the RecId in the field. When stored that way, the number matches, but an "Assignment/Comparison loses precision" warning is thrown. Is that ok, or is there a better way?

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

雪化雨蝶 2024-08-21 10:21:01

在 Axapta 版本 3 之后,所有 RecId 都是 64 位整数。 strFmt() 函数能够将recId 从int64 转换为字符串,但您也可以使用int642str() 函数将recId 显式转换为字符串。

RecId recId = 5637144577;
anytype a;
int64 b;
;

a = recId;
b = a;

info(int642str(a));
info(int642str(b));
info(int642str(recId));

After version 3 of Axapta all RecIds are 64 bit integers. The strFmt() function is able to cast the recId from int64 to string for you, but you can also use the int642str() function to explicitly cast the recId to string.

RecId recId = 5637144577;
anytype a;
int64 b;
;

a = recId;
b = a;

info(int642str(a));
info(int642str(b));
info(int642str(recId));
横笛休吹塞上声 2024-08-21 10:21:01

请向我们提供完整的示例:

RefRecId   recid = 5637144577;
anytype    tmp;
;
info(strfmt('%1', recid));
tmp = recid;
info(strfmt('%1', tmp));
recid = tmp;
info(strfmt('%1', recid));

结果为:

5637144577

5637144577

5637144577

Please provide us full example:

RefRecId   recid = 5637144577;
anytype    tmp;
;
info(strfmt('%1', recid));
tmp = recid;
info(strfmt('%1', tmp));
recid = tmp;
info(strfmt('%1', recid));

The result is:

5637144577

5637144577

5637144577

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文