我有一个奇怪的问题。我正在尝试添加与潜在客户相关的任务。我写了下面的代码,它工作正常,并出现在活动的领导下。但是,当我浏览任务时,"相关实体描述"字段是空白的。我查看了它背后的代码,似乎应该从Acumatica 6中的RefNoteId自动计算相关的实体描述。如果我在主管/活动下手动创建项目,那么所有其他主管/活动都会更新相关的实体描述& #34;正常。查看源代码,看来这个字段是myTask.Source,它是一个字符串值,我不确定应该设置什么,因为它应该用noteid自动计算。我查看了SQL数据库以及手动创建的任务中的所有字段,我自动创建的任务(包括NoteID)都是正确的,所以看起来我错过了某种"更新"命令。任何洞察我缺少什么来获得"相关实体描述"正确计算?感谢。
private void followuphelper(int daysToFollowUp)
{
#region Event Handlers
Contact curLead = Base.LeadCurrent.SelectSingle();
CRTaskMaint graph = CRTaskMaint.CreateInstance<CRTaskMaint>();
CRActivity myTask = new CRActivity();
myTask.Subject = String.Format("FollowUp Lead");
myTask.ClassID = 0;
DateTime dueDate = DateTime.Now;
myTask.StartDate = dueDate;
myTask.EndDate = dueDate.AddDays(daysToFollowUp); //2 weeks
myTask.RefNoteID = curLead.NoteID;
myTask.ContactID = curLead.ContactID;
CRActivity task = (CRActivity)graph.Tasks.Insert(myTask);
Base.Actions.PressSave();
graph.Actions.PressSave();
}
答案 0 :(得分:1)
我刚刚验证了以下代码,它确实显示了相关实体:
public class LeadMaintPXExt : PXGraphExtension<LeadMaint>
{
public PXAction<Contact> FollowUpTask;
[PXUIField(DisplayName = "FollowUp Task")]
[PXButton()]
private void followUpTask()
{
CRTaskMaint graph = PXGraph.CreateInstance<CRTaskMaint>();
CRActivity myTask = new CRActivity();
myTask.Subject = String.Format("FollowUp Lead Test");
myTask.ClassID = 0;
DateTime dueDate = DateTime.Now;
myTask.StartDate = dueDate;
myTask.EndDate = dueDate.AddDays(10);
myTask.RefNoteID = Base.Lead.Current.NoteID;
myTask.ContactID = Base.Lead.Current.ContactID;
CRActivity task = (CRActivity)graph.Tasks.Insert(myTask);
graph.Actions.PressSave();
}
}
相关实体说明正在NoteID
表中查找匹配的Note
记录。在需要时,可以按需创建此记录。对于New Lead,如果您希望继续使用上述代码,则需要通过调用PXNoteAttribute的GetNoteID来请求创建注释,并保留记录。
实施例:
PXNoteAttribute.GetNoteID<Contact.noteID>(Base.Lead.Cache, Base.Lead.Current);
Base.Actions.PressSave();
开箱即用的活动操作(添加任务,添加事件等),在内部处理此问题。如果使用以下方法,则所有初始化都在内部完成。
public class LeadMaintPXExt : PXGraphExtension<LeadMaint>
{
public PXAction<Contact> FollowUpTask;
[PXUIField(DisplayName = "FollowUp Task")]
[PXButton()]
private void followUpTask()
{
try
{
//out-of-box Activities -> "New Task" Action
Base.Actions["NewTask"].Press();
}
catch (Exception ex)
{
if (ex is PXRedirectRequiredException)
{
CRTaskMaint graph = (ex as PXRedirectRequiredException).Graph as CRTaskMaint;
if (graph != null)
{
CRActivity myTask = graph.Tasks.Current;
myTask.Subject = String.Format("FollowUp Lead Test");
myTask.ClassID = 0;
DateTime dueDate = DateTime.Now;
myTask.StartDate = dueDate;
myTask.EndDate = dueDate.AddDays(10);
CRActivity task = graph.Tasks.Update(myTask);
graph.Actions.PressSave();
}
}
}
}
}