Solved

Strange results opening File Maintenance graph with PXRedirectRequiredException

  • 16 March 2023
  • 4 replies
  • 110 views

Userlevel 6
Badge +3

I have a custom action on the Sales Orders screen.  If the order is a Quote and it has been saved, the user can click my custom action button and it will create a Quote PDF and attach it to the current record.  The customer uses Acumatica ESign.

The next step is to get the user over to the ESign screen.  I’ve tried two ways to do it. 

  1. Redirecting the user to the File Maintenance screen and populate it with the Quote file.  From there they could click the ESIGN button.
  2. Redirect the user directly to the ESign screen.  

The 2nd option is preferred.  

After the PDF is attached to the record on the Sales Orders screen, you CAN click Files at the top of the screen, then click the Edit link on the Files dialog.  That will take you to the File Maintenance screen where you can click ESIGN.

 

My customer want a “one click” operation.  That is why option 2 is preferred.  But if that cannot be done, I will take option 1.

At the end of my “Create PDF Quote” action, I have the following code to create an instance of the File Maintenance graph, set the key field for the screen, and redirect the user to the screen.

            PXGraph fm = PXGraph.CreateInstance<PX.SM.WikiFileMaintenance>();
            fm.UID = file.UID;
            throw new PXRedirectRequiredException(fm, true, "File Maint");

The File maintenance screen opens and the current file is some jpg file.  I’ve no idea how that is being selected as the current record for the screen.  In debug, I verified that the UID being assigned to the fm.UID is the actual Guid of the file that I can see when selecting it from the UploadFiles table.  So I am certain I am setting the correct Guid value.

This is what comes up on the File Maintenance screen:

I checked the UploadFile table and that indeed is a real record in the table.

My second option which would be preferred is to open the ESign screen directly and save a step.  I don’t know if this code would even work because I can’t get it to compile so I can test it.

I get the graph extension from the using AcumaticaESign.SM DLL. as follows: 

            PXGraph baseGraph = PXGraph.CreateInstance<WikiFileMaintenance>();
            var extGraph = baseGraph.GetExtension<WikiFileMaintenanceESExt>();
            UploadFileRevisionNoData rev = new UploadFileRevisionNoData();
            rev.FileID = file.UID;
            extGraph.RevisionsWithAction.Update(rev);
            throw new PXRedirectRequiredException(extGraph, true, "ESign");

The throw new exception has an error on the extGraph.  It says that it cannot convert from AcumaticaESign.SM.WikiFileMaintenanceESExt to PX.Data.PXGraph.

I’ve looked hard to see how to throw an exception to redirect the user to the “third party” screen but I cannot find anything.

In summary, is it possible to do a PXRedirectRequiredException to a graph extension?  If not, what can I do to get my PXRedirectRequiredException to the File Maintenance screen to work?

Thanks in advance!

 

 


 

icon

Best answer by Dioris Aguilar 16 March 2023, 21:25

View original

4 replies

Userlevel 5
Badge +2

@Joe Schmucker Have you tried initializing the WikiFileMaintenance graph using the main view (Files):

PXGraph fm = PXGraph.CreateInstance<PX.SM.WikiFileMaintenance>();
fm.Files.FileID = file.UID; //Not sure what class is the variable "file", so, maybe a FileID field is needed instead of UID.
throw new PXRedirectRequiredException(fm, true, "File Maint");


 

Userlevel 6
Badge +3

@Dioris Aguilar For some reason, when you create the graph, none of the views on that graph can be used like you would see ordinarily.

If you put that code into VS, fm.Files.FileID has an error. (I renamed to fm2 as i already have an fm :-)

In the Wiki graph, there is a view “CurrentFile”.  When you type fm. you get no intellisense to bring up any of the views from that graph.  I think CurrentFile is the view I need to get the “Current” of and set the file id on that view.

Normally, I would get the fm.CurrentFile.Current and set values to it then update the cache.  I cannot find any way to get a reference to ANY of the views on that graph.

If I debug this line, I can see the names of all the views   var joe2 = fm2.GetViewNames();

But I cannot get a reference to them.  It’s like the graph is hiding the views from me.

For example, this is code I have in another project that works.

    var fGraph = PXGraph.CreateInstance<UploadFileInq>();
    fGraph.Filter.Current = new FilesFilter();
    fGraph.Filter.Current.DocName = Base.Document.Current.RefNbr;

When I type fGraph. it brings up the views on that graph.

I am trying to do exactly what is done in the Acumatica training code:

                // create a new instance of the graph
                var graph = PXGraph.CreateInstance<RSSVWorkOrderEntry>();
                // set the current property of the graph
                graph.WorkOrders.Current = graph.WorkOrders.
                Search<RSSVWorkOrder.orderNbr>(order.OrderNbr);
                // if the order is found by its ID,
                // throw an exception to open the order in a new tab
                if (graph.WorkOrders.Current != null)
                {
                    throw new PXRedirectRequiredException(graph, true,
                    "Repair Work Order Details");
                }
But, no views are available.

I wish that one of my customizations would not have some quirk like this.  

Userlevel 5
Badge +2

@Joe Schmucker I forgot the .Current. Files view will not be found if the .CreateInstance<> is casted to PXGraph:

 

Userlevel 6
Badge +3

@Dioris Aguilar , you saved me.  I can’t thank you enough.

Even though the DAC for that graph only looks like the FileID is key, you have to supply FileID, Name and WikiLink or it will error out.

This was the code I ended up with to get it all working.

            WikiFileMaintenance fm = PXGraph.CreateInstance<PX.SM.WikiFileMaintenance>();
            UploadFileWithIDSelector uf = new UploadFileWithIDSelector();
            uf.FileID = file.UID;
            uf.Name = file.Name;
            uf.WikiLink = "[{up}" + uf.Name + "]";
            fm.Files.Current = uf;
            throw new PXRedirectRequiredException(fm, true, "File Maint");
 

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved