Reputation: 1369
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
Upvotes: 1
Views: 5490
Reputation:
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));
Upvotes: 3
Reputation: 45295
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
Upvotes: 2