1

Good Day,

This is my first time to post here in site, please bear with me. :)

One of the requirements of our project is to duplicate an existing screen (Customer Contracts) into a new screen (Vendor Contracts) imitating the source screen. The client don't want us to customize the screen but to duplicate it. I already saw one approach that the asp files can be copied and renamed but that is possible only for the ASP files: Is it possible to copy existing screens?

  1. Could this be possible?
  2. If so, are there other things to consider (graphs, DACs of the existing screen to be duplicated as well?)
  3. Are there other ways to achieve this?

I'm still new to acumatica btw. Thanks and stay safe.

Jess
  • 13
  • 2
  • Something to try in a DEV instance. I have no idea if it will work or not, but it is where I would start experimenting. I don't work with any screens for contracts, but you could try creating a graph that inherits from the one used by your desired screen. Then create a new screen as a placeholder. Then copy the ASPX from the original screen and replace the contents of the ASPX of your new screen. Keep in mind that you will need to replace the screen name and graph names defined in your new ASPX file. Then you can try overloading what you want to change. – Brian Stevens Jul 06 '21 at 20:57
  • Keep in mind that the DAC's will still point to the other screen by default, so any GI's that you use to front-end this will need to have custom navigation defined to direct the user to your new screen. Again, no idea if any of this will work, but it's worth a try if you don't find any other suggestions. IMO, it is better to find a way to do something than to just walk away and say it can't be done. You may learn it can't be done or shouldn't be done "that" way, but either way you will learn something in the process. – Brian Stevens Jul 06 '21 at 20:59
  • @BrianStevens, Thanks for the response, I'll try what you've mention. – Jess Jul 08 '21 at 01:39

1 Answers1

2

You can start by making a new graph derived from the graph used by the screen you need to copy (Customer Contracts).

Then you should copy the aspx file of the screen but change the graph being used from the old graph to your graph. Look for px:PXDataSource in the copy of aspx file and change the TypeName attribute to the full name (with namespace part) of your graph.

All business logic, like graph events, graph extensions, views, actions that applies to the base graph will apply to the derived graph as well. Additionally you may introduce your own business logic to the derived graph which will apply only to it. There are some Acumatica screens that use this approach (AR301000 and SO301000).

Note that it may be hard to write and support something complex with it if you do not control the code of the base graph. The derived graph will also be a subject to every change done to the base graph. Therefore in general it is recommended to introduce your own independent graph. But in your case when you need a complete copy of the screen's logic you can try this approach,

DACs are not specific to a particular graph, they can be used by another graph. If you need to change an existing field in DAC you can use DAC extensions to do it independently of all graphs. You can also use them to add a new field to DAC: https://help-2021r1.acumatica.com/Help?ScreenId=ShowWiki&pageid=114ae5af-8667-4933-b53d-c4c8667c85ac

Or you can use graph's cache attached events to change attribute's on the existing DAC field for particular graph (for example, change the label displayed for the field by changing PXUIFieldAttribute.DisplayName): https://help-2021r1.acumatica.com/Help?ScreenId=ShowWiki&pageid=80e817bd-e70b-45b9-a9b1-2d2d0e2f8ee2

If you have a need to change a lot of things in the DAC declaration you can use the following trick supported by the Acumatica platform. Make a copy of the DACs declaration and change the namespace to your custom namespaces. Then this will count as a separate class/DAC from the C#/Acumatica Framework point of view. However it will be still mapped to the same database table. You can change attributes on the DAC property fields or remove some properties that you don't use. This won't affect the original DAC and the business logic in graphs that use it.

UPDATE:

I forgot about an important moment. Thanks to @brian-stevens for pointing this out.

If you need to change the default navigation in the system to go to your screen instead of an existing one (for example, the navigation from GI) then you will need to do some extra work. The navigation is defined via PXPrimaryGraphAttribute which is declared on a DAC like this:

[PXPrimaryGraph(typeof(MyGraph))]
public class MyDac : IBqlTable
{
   ...
}

You need to pass the type of the graph used by the screen to which you want to navigate by default. The declaration of PXPrimaryGraphAttribute may include several graph types and conditions to allow navigation to different screens depending on different conditions. For instance, you can navigate to different screens depending on the type of the document. You can look at PX.Objects.AP.APRegister for an example.

However, PXPrimaryGraphAttribute is declared not on a DAC field property but on the DAC itself. Therefore it is impossible to customize it with the approach used to change attributes of DAC properties. If you don't own the source code of the DAC then it is impossible to change its PXPrimaryGraphAttribute declaration.

In this case I would try the following approach. You can declare PXPrimaryGraphAttribute on your graph and pass the type of the primary DAC to its constructor. According to the documentation this should override the navigation for this DAC.

[PXPrimaryGraph(typeof(PrimaryDac))]
public class MyCopyOfGraph : BaseGraph
{}

Here are links to the documentation and related SO question:

UPDATE 2

After checking the code I discovered that Acumatica platform actually provides you an ability to override DAC's default navigation by declaring PXPrimaryGraphAttribute attribute on a DAC extension like this:

[PXPrimaryGraph(typeof(MyCopyOfGraph))]
public class MyDacExtension : PXCacheExtension<MyDac>
{
   ...
}

UPDATE 3 Another concern that was recently mentioned by my colleague is the workflow of the screen. You will need to override the existing workflow and define your own.

SENya
  • 1,083
  • 11
  • 26
  • 1
    Nice detail. One clarification though... a DAC is not limited to use by a single graph, but it should be given a PrimaryGraph definition. When done, access of the DAC, such as in GI's will carry a default navigation to whichever graph was specified by PrimaryGraph. Likewise, features such as "Allow Edit" on a field will also use the primary graph by default. As such, any such customization will require overriding the default navigation should you want the record going to your custom graph (screen). – Brian Stevens Jul 13 '21 at 05:00
  • Thanks, updated the answer with details on how to override the navigation. – SENya Jul 14 '21 at 00:44
  • I can see from the code that placing the PXPrimaryGraphAttribute on DAC extension should work too. I'll try to confirm it and then update the answer with this option. – SENya Jul 19 '21 at 22:09