Reputation: 67
I'm making a button to create a SOOrder from the Project. I'd like to write the newly created number back to the project, so I've added a custom field for that. It's on the form and the whole process works great.
That said, at the end when I try to write back to the project I get the following error any time I try to reference PMProjectExt:
error CS0246: The type or namespace name 'PMProjectExt' could not be found (are you missing a using directive or an assembly reference?)
Ideally my update line looks like this Base.Caches[typeof(PMProject)].SetValue<PMProjectExt.usrTEKSOOrderNbr>(TheRow, header.OrderNbr);
But even something as simple as declaring a variable (eg PMProjectExt testExt;
with the PMProjectExt gets the same error.
I'm sure I'm doing something really stupid, but I can't seem to resolve it.
Upvotes: 0
Views: 127
Reputation: 67
So, turns out that Projects used to be Contracts. So to get the extension on Projects you need to use contracts like this:
PMProject TheRow = (PMProject)e.Row;
ContractExt TheExt = PXCache<Contract>.GetExtension<CT.ContractExt>(TheRow);
string refNbr = TheExt.UsrTEKSOOrderNbr;
Upvotes: 0
Reputation: 765
If you want to update a project, I recommend to instantiate the PMProject graph, assign the current record & update the user-field value. Finally persist the changes to the graph. Something like this.
ProjectEntry graph = PXGraph.CreateInstance<ProjectEntry>();
PMProject currentProject = graph.Project.Search<PMProject.contractCD>(Base,[your project nbr])
if (currentProject!=null)
{
graph.Project.Current = currentProject;
PMProjectExt projectExtension = PXCache<PMProject>.GetExtension<PMProjectExt>(currentProject);
projectExtension.usrTEKSOOrderNbr = "ABC123";
graph.Actions.PressSave();
graph.Clear();
}
Upvotes: 1