Question

Problem adding FSSODet records programmatically on Service Order screen

  • 4 February 2022
  • 6 replies
  • 138 views

Hoping someone can point me in the right direction here.

I created a custom action on the Service Contract screen that opens up the Service Order screen and auto-fills a number of fields through parameters.  I also need to automatically add a number of detail lines (FSSODet) to the order when it opens, so that the service order already has the correct information without the user having to change much.

I’ve used a code example from the Customization Guide, but am having a problem.  In the service order RowUpdating event, I am trying to add a line to the Details grid, but I am getting the following error: 

“error CS0103: The name 'FSSODets' does not exist in the current context”

I thought Acumatica instantiated the required data views, but I must be missing something.

Any input would be appreciated.

Thanks.

Dan

(Code sample below)

namespace PX.Objects.FS
{
  public class ServiceOrderEntry_Extension : PXGraphExtension<ServiceOrderEntry>
  {
    #region Event Handlers
  
  protected virtual void _(Events.RowUpdated<FSServiceOrder> e)
   {
     FSSODet row = new FSSODet();
     row.InventoryID = 10401;
     row.EstimatedQty = 5;
     row.BillableQty = 5;
     FSSODets.Insert(row);
   }
    #endregion
  }
}


6 replies

Userlevel 7
Badge +11

Hi @DanNixon 

We need to insert records by using views. In the extension graph, we can get the Views by using the Base graph. Can you please try like below,

               FSSODet row = new FSSODet();
                row.InventoryID = 10401;
                row.EstimatedQty = 5;
                row.BillableQty = 5;
                Base.ServiceOrderDetails.Insert(row);

Hi Jini

Thanks for this.  I made the change published my customization.  I did not get a compile error, but once published, the website basically came to a halt.  Most pages were timing out, and those that did load took minutes to load instead of seconds.

Is there another way to access the Views besides using Base?  I’ve spent hours trying various methods, but not having any luck.

Thanks.

Dan

Userlevel 7
Badge +11

Hi @DanNixon 

I think you can write the logic inside the custom action itself, If we write the code in the Row_Updated event, it will trigger whenever any field is updated on the screen and face the performance issue.

Can you please share the custom Action code to review?

Hi Jini

The custom action is on a different form - Route Service Contracts (FS.30.08.00) - and I haven’t added any code for it.  Everything is set up through “Action Properties” (see screenshot below).

When the user selects this action, it opens up a new “Service Orders” screen (FS.30.01.00) and auto fills the fields in the service order with parameters from the Route Service Contract (per parameter list in screenshot below).

When the “Service Order” form is opened, the specified fields are auto filled (based on the action), and what gets loaded into the “Description” field will determine the service order lines and items that I want to auto populate on the “Details” tab grid.  I’m using the service order “Rowupdated” event in FS.30.01.00 to try to insert the service order detail lines that are required.  We want to auto populate as much as possible in order to reduce data entry time and error.

 

 

I’ve looked into doing this through a “Paste from <template>”, but have not found a way to programmatically trigger that action.  I’ve also spent time looking into whether or not I coiuld use business events or workflows to insert the detail lines, but have not found any way using those either.

The only other option I could come up with is through code.  That is what led to the original code I provided above.  It is only test code at this point - I still need to add the condition, fill some other fields, and add more than one detail record.  If I can get the above test code working, then I’ll expand on the code to do all that is required.

Do you know if there is a way I can tigger the “Add Item” action on the “Details” tab?  It triggers the “AddInvBySite” method, which looks like it might work, but I get quite figure out how to set up the adapter for the call:

     PXAdapter adapter1 = new PXAdapter( Base.ServiceOrderDetails.View );
     adapter1.InventoryID = 10401;
     adapter1.EstimatedQty = 1;
     PX.Objects.FS.ServiceOrderEntry.AddInvBySite(adapter1);

I’m doing something wrong setting up the adapter, as I am getting the following error on the AddInvBySite call:

error CS0120: An object reference is required for the non-static field, method, or property 'ServiceOrderEntry.AddInvBySite(PXAdapter)'

If you know of any other method I can use to auto populate a detail grid, let me know and I’ll give it a try.

Thanks.

Dan

 

 

 

 

 

Userlevel 7
Badge

Hi @jinin  - Do you have any further ideas for @DanNixon ? Thanks!

Hi Chris

Thanks for following up on this.  I was going to try to reconnect with Jini myself, or see if someone else on the board had any suggestions.

Cheers,

Dan Nixon

 

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