Acumatica:根据字段的初始值或字段值更改时设置按钮的初始标签
Acumatica : Set Initial Label of Button based on initial value of a Field or when field value changes
我在机会定制工作。我有自定义按钮,我想根据用户的操作重复使用它。
第一次通过,如果他们点击按钮,我会在 Google 驱动器中创建一个文件夹。
如果已经完成,当他们单击按钮时,我将在新浏览器中打开之前创建的 GDrive 文件夹 window。为了知道要采取什么行动,我使用了 ExternalRef 字段。
我希望按钮的显示名称显示用户单击它时会发生什么,以便他们知道会发生什么。
但是,我无法更改 Delegate 中的显示名称,也看不到如何在初始化时更改值。
我想我需要为此构建一个函数?但是从示例中不清楚如何做到这一点,而且我找不到培训课程中描述的这个用例。
这是自定义按钮的委托存根:
public PXAction<CROpportunity> OpportunityInGDRIVE;
[PXButton(CommitChanges = true)]
[PXUIField(DisplayName = "SETUP QUOTE", MapEnableRights = PXCacheRights.Select)]
public virtual void opportunityInGDRIVE()
{
// I can VIEW the caption, but cannot SET it
var _Caption = OpportunityInGDRIVE.GetCaption();
if (Base.Opportunity.Current.ExternalRef.ToUpper().Contains("GDRIVE"))
{
// GOOGLE API info gets inserted here...
// I WANT to SET Caption here, but not allowed
Base.Opportunity.Current.ExternalRef = "GDRIVE";
Base.Opportunity.UpdateCurrent();
}
else
{
// send to google drive... this is a place holder
var redirectException =
new PXRedirectToUrlException("https://www.cepro.com/wp-content/uploads/2019/04/BuildersNoSmartHomes_large-1100x650.jpg",
PXBaseRedirectException.WindowMode.New, "Acumatica.com");
throw redirectException;
}
}
所以,我需要知道如何:
A) 根据ExternalRef的初始值更改初始化中的标签显示
B) 当我在 Google 驱动器中创建文件夹回来时更改标签显示(虽然我再次更改 ExternalRef 的值,所以也许可以在该字段的更改属性委托中处理? IDK.)
您可以在 CROpportunity(主 DAC)的 RowSelected 事件处理程序中设置标题。
public virtual void _(Events.RowSelected<CROpportunity> e, PXRowSelected baseHandler)
{
baseHandler?.Invoke(e.Cache, e.Args);
CROpportunity row = e.Row;
if (row == null) return;
this.OpportunityInGDRIVE.SetCaption((Base.Opportunity.Current.ExternalRef.ToUpper().Contains("GDRIVE")) ? "GDRIVE" : "DROPBOX");
}
我在机会定制工作。我有自定义按钮,我想根据用户的操作重复使用它。
第一次通过,如果他们点击按钮,我会在 Google 驱动器中创建一个文件夹。
如果已经完成,当他们单击按钮时,我将在新浏览器中打开之前创建的 GDrive 文件夹 window。为了知道要采取什么行动,我使用了 ExternalRef 字段。
我希望按钮的显示名称显示用户单击它时会发生什么,以便他们知道会发生什么。
但是,我无法更改 Delegate 中的显示名称,也看不到如何在初始化时更改值。
我想我需要为此构建一个函数?但是从示例中不清楚如何做到这一点,而且我找不到培训课程中描述的这个用例。
这是自定义按钮的委托存根:
public PXAction<CROpportunity> OpportunityInGDRIVE;
[PXButton(CommitChanges = true)]
[PXUIField(DisplayName = "SETUP QUOTE", MapEnableRights = PXCacheRights.Select)]
public virtual void opportunityInGDRIVE()
{
// I can VIEW the caption, but cannot SET it
var _Caption = OpportunityInGDRIVE.GetCaption();
if (Base.Opportunity.Current.ExternalRef.ToUpper().Contains("GDRIVE"))
{
// GOOGLE API info gets inserted here...
// I WANT to SET Caption here, but not allowed
Base.Opportunity.Current.ExternalRef = "GDRIVE";
Base.Opportunity.UpdateCurrent();
}
else
{
// send to google drive... this is a place holder
var redirectException =
new PXRedirectToUrlException("https://www.cepro.com/wp-content/uploads/2019/04/BuildersNoSmartHomes_large-1100x650.jpg",
PXBaseRedirectException.WindowMode.New, "Acumatica.com");
throw redirectException;
}
}
所以,我需要知道如何:
A) 根据ExternalRef的初始值更改初始化中的标签显示
B) 当我在 Google 驱动器中创建文件夹回来时更改标签显示(虽然我再次更改 ExternalRef 的值,所以也许可以在该字段的更改属性委托中处理? IDK.)
您可以在 CROpportunity(主 DAC)的 RowSelected 事件处理程序中设置标题。
public virtual void _(Events.RowSelected<CROpportunity> e, PXRowSelected baseHandler)
{
baseHandler?.Invoke(e.Cache, e.Args);
CROpportunity row = e.Row;
if (row == null) return;
this.OpportunityInGDRIVE.SetCaption((Base.Opportunity.Current.ExternalRef.ToUpper().Contains("GDRIVE")) ? "GDRIVE" : "DROPBOX");
}