从PXSmartPanel获取“非持久字段”值

时间:2018-06-28 17:16:16

标签: c# acumatica

我正在使用PXSmartPanel显示一个对话框,允许用户输入字符串。我想使用“非持久字段”,但是(我认为)这意味着我将必须通过在面板上调用该字段并提取其值来获取该字段的值。

文本字段的ID为cstFieldSSN,非持久字段的ID为UsrSSN

我的方法如下: (我在单击菜单项时调用对话框)

// Initialize 'myPanel'
public PXFilter<PX.Objects.CR.Contact> myPanel;

// Make the 'Letters' menu available to 'Automation Steps'
public PXAction<PX.Objects.CR.Contact> letters;
[PXUIField(DisplayName = "Letters", MapEnableRights = PXCacheRights.Select)]
[PXButton(SpecialType = PXSpecialButtonType.Report)]
protected virtual IEnumerable Letters(PXAdapter adapter, string reportID)
{
    if (myPanel.AskExt(true) != WebDialogResult.OK) return;

    PXReportRequiredException ex = null;

    Contact contact = Base.Caches[typeof(Contact)].Current as Contact;

    Dictionary<string, string> parameters = new Dictionary<string, string>();

    parameters["ContactID"] = contact.ContactID.ToString();

    /** Here's the issue **/
    parameters["SSN"] = myPanel.Current.UsrSSN;

    throw new PXReportRequiredException(parameters, reportID, "");

    if (ex != null) throw ex;

    return adapter.Get();
}

我要

  

“ PX.Objects.CR.Contact”不包含“ UsrSSN”的定义,并且找不到扩展方法“ UsrSSN”接受类型为“ PX.Objects.CR.Contact”的第一个参数(您是否丢失了? using指令还是程序集引用?)

有人可以帮我或向我指出资源吗?

1 个答案:

答案 0 :(得分:1)

感谢@Brendan,我的最终代码如下:

    // Initialize 'myPanel'
    public PXFilter<PX.Objects.CR.Contact> myPanel;

    // Make the 'Letters' menu available to 'Automation Steps'
    public PXAction<PX.Objects.CR.Contact> letters;
    [PXUIField(DisplayName = "Letters", MapEnableRights = PXCacheRights.Select)]
    [PXButton(SpecialType = PXSpecialButtonType.Report)]
    protected virtual IEnumerable Letters(PXAdapter adapter, string reportID)
    {
        // Launch the PXSmartPanel dialog and test result
        if (myPanel.AskExt(true) == WebDialogResult.OK)
        {
            PXReportRequiredException ex = null;

            Contact contact = Base.Caches[typeof(Contact)].Current as Contact;

            Dictionary<string, string> parameters = new Dictionary<string, string>();

            //*** Get the extended class
            var myExt = myPanel.Current.GetExtension<ContactExt>();

            parameters["ContactID"] = contact.ContactID.ToString();

            //*** Get the extended class's custom field value
            parameters["SSN"] = myExt.UsrSSN;

            throw new PXReportRequiredException(parameters, reportID, "");

            if (ex != null) throw ex;
        }

        return adapter.Get();        
    }

但是我还必须将文本字段上的CommitChanges属性设置为True,以便将值推回到缓存的联系人中,以便我使用它。