How do you find a user's last used printer in SysLastValue

眉间皱痕 提交于 2020-01-13 06:39:10

问题


I've been trying to find where a user's last used printer is stored so that I can clear this usage data (as a few users have an issue where the remembered printer keeps defaulting to the XPS writer, despite us having KB981681 installed & the printer being available; just not defaulted on certain AX forms).

I know this data's somewhere in the Usage Data, which I can browse via AX:

Microsoft Dynamics AX > Tools > Development Tools > Application Objects > Usage Data

AOT > System Documentation > Tables > SysLastValue > (right click) > Add-Ins > Table Browser

Or through SQL:

use AXDB
go

select *
from SysLastValue 
where userid in 
(
    select id 
    from userinfo 
    where networkalias in ('userid1','userid2')
)
and elementname like '%print%'
and iskernel = 1

However so far I've not been able to guess which setting holds the last used printer information. Since the value field is of type image (i.e. a blob) I also can't search based on value.

Any advise on how to find this setting would be helpful.


回答1:


Unfortunately there really isn't one "last used printer" stored, as much as each process packs and stores the last used print settings. Here is an example of how you can pull the last used print settings after posting a picking slip from the sales form.

static void JobGetPrinterSettingsPickList(Args _args)
{
    container                       lastValues;
    SalesFormLetter_PickingList     pickList = new SalesFormLetter_PickingList();
    SRSPrintDestinationSettings     printSettings;

    lastValues = xSysLastValue::getValue(curext(), curUserId(), UtilElementType::Class, classStr(SalesFormLetter_PickingList), formStr(SalesTable));

    pickList.unpack(lastValues);

    printSettings = new SRSPrintDestinationSettings(pickList.printerSettingsFormletter());
    info(strFmt("%1", printSettings.printerName()));
    info(strFmt("%1", printSettings.printerType()));
}

Edit: Ah I see you're having a specific issue. Check the pack/unpack and version of whatever object is having the issue. That is likely where the issue is. Or if it's on several things, check if they're all extended classes and you need to look at the parent class.



来源:https://stackoverflow.com/questions/28724212/how-do-you-find-a-users-last-used-printer-in-syslastvalue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!