Skip to main content

public PXAction<PMProject> complete;
[PXButton, PXUIField(DisplayName = "Complete Project")]
public virtual IEnumerable Complete(PXAdapter adapter)
{
if (Project.Current != null)
{
//Project can only be completed if all task are completed.
PXResultset<PMTask> res = PXSelect<PMTask, Where<PMTask.projectID, Equal<Current<PMProject.contractID>>, And<PMTask.isCompleted, Equal<False>, And<PMTask.isCancelled, Equal<False>>>>>.Select(this);
if (res.Count > 0)
{
Project.Cache.RaiseExceptionHandling<PMProject.status>(Project.Current, Project.Current.Status, new PXSetPropertyException<PMProject.status>(Messages.UncompletedTasksExist, PXErrorLevel.Error, res.Count));
throw new PXException(Messages.UncompletedTasksExist, res.Count);
}
Project.Current.IsCompleted = true;
Project.Current.ExpireDate = Accessinfo.BusinessDate;
Project.Update(Project.Current);
}
return adapter.Get();
}

I’m trying to create a custom screen/graph that will have a Complete action (like the existing Project screen) but I can’t figure out how the actual Status column is getting changed on the existing or how it is persisting after this action runs.

In my custom screen/graph I am having to explicitly call Persist() and the status code itself does not change to Completed.  I wasn’t able to step any further or find any events that are setting the status and/or calling Persist()

UPDATE: I think the answer is Workflow (which I have not delved into much)  I see there is a transition from Active to Complete.  Does this implicitly cause the status to change from the action complete trigger?  And, if so, does this also fire Persist()?

Be the first to reply!

Reply