Solved

Updating a field from another DAC

  • 6 February 2023
  • 5 replies
  • 526 views

Userlevel 4
Badge

Hello Everyone,

I created a customization on the service order as shown below. When Mark for SO is active, CREATE SALES ORDER button appears. The button enable creation of a service management sales order.

The service management sales order is as follows;

 

Opening the sales order;

How do I get the  STATUS and ORDERNBR of  service management sales order created to be displayed on Servce order screen on the Details Line on my custom fields i.e SOStatus(UsrSOStatus). also have another custom field as SONumber(UsrSONumber).

Kindly Assist.

ALL RESPONSES WILL BE HIGHLY APPRECIATED.

icon

Best answer by Django 14 February 2023, 17:52

View original

5 replies

Userlevel 7
Badge +5

Are you storing the SO OrderNbr in the UsrSONumber field?  If you are then you can add the PXDBScalar attribute to your UsrSOStatus column so that it reads the status field value from SOOrder.

What does your DAC field declarations look like for your custom fields?

Userlevel 7
Badge +9

@development93

In addition to what @ddunn  has mentioned, you can use FieldSelecting Event to retrieve the desired value from a DAC and show it in your custom/standard field of the current DAC. For example, below I have added a custom field (UsrClassName) to my GLTran (Lines of GL Transaction Screen) and shown the Account Class from the Account table for it. If you have the fields and the reference/current table in a DAC Extension you can use dacAlias.GetExtension<>() (also I have put in my code for your reference). You need to replace the pieces as per your need to make it.

// ********************* Display GL Account Class in GLTran *********************

using HCL;
using PX.Data;

namespace PX.Objects.GL
{
// DAC Ext
[PXNonInstantiatedExtension]
public sealed class USRGLTranExt : PXCacheExtension<PX.Objects.GL.GLTran>
{
public static bool IsActive() => true;

#region UsrClassName
public abstract class usrClassName : PX.Data.BQL.BqlString.Field<usrClassName> { }
[PXString(60, IsUnicode = true)]
[PXUIField(DisplayName = "Account Class", Enabled = false, Visible = true)]
public string UsrClassName { get; set; }
#endregion
}

// Graph Ext
public class USRJournalEntryExt : PXGraphExtension<PX.Objects.GL.JournalEntry>
{
public static bool IsActive() => true;

protected void _(Events.FieldSelecting<GLTran, USRGLTranExt.usrClassName> e)
{
if (e.Row == null) return;

e.ReturnValue = "";

if (e.Row.AccountID != null)
{
Account account = PXSelect<Account,
Where<Account.accountID, Equal<Required<Account.accountID>>>>.Select(Base, e.Row.AccountID);

if (account != null && account.AccountClassID != null)
{
//Get any DAC Extension using below 1 line of code
MyAccountExt accountExt = accountExt.GetExtension<MyAccountExt>();

AccountClass accountClass = PXSelect<AccountClass,
Where<AccountClass.accountClassID, Equal<Required<AccountClass.accountClassID>>>>.Select(Base, account.AccountClassID);

if (accountClass != null)
{
e.ReturnValue = accountClass.Descr;
}
}
}
}
}
}

//Add the "UsrClassName" to the Transaction Grid (GLTranModuleBatNbr) in GL301000 and set the CommitChanges = True as follows:
// <px:PXGridColumn DataField = "UsrClassName" Width="220" CommitChanges="True" />

 

Userlevel 4
Badge

So from the information I got here, tried to implement it on my code as shown below;
Getting the value of SOOrder status to UsrSoStatus;

 

 

 

strstatus?

see below;

The following code is not able to retrieve the status from SOOrder;

I’m thinking the issue starts from here;

 

I’m I doing it correctly?
Kindly assists.
I’m really stuck here.

Userlevel 7
Badge +5

Are you wanting to update your FSSODet record or do you just need to display the current status value from the related SOOrder record at that moment in time?

I suspect that you want to display it and not store it because when the status of the order changes your custom field value will be out of sync.

I think you can change the declaration of your UsrSoStatus DAC field so that it pulls the status of the related SOOrder record directly without storing the value.

Using the PXDBScalar attribute on a field will allow you to essentially turn that field into a sub-select along the lines of (this isn’t exact - only for demonstration purposes):

(select Status from SOOrder where SOOrder.OrderNbr=FSSODet.UsrSONumber) UsrSoStatus

So when this record is selected or used in a GI/Report, the current SOOrder.Status value appears in your UsrSoStatus field with no further effort on your behalf.

This example from the Acumatica help shows a Vendor Name field that is showing the name of the vendor whose ID is in the RQRequestLine DAC. (Note that this field would be in the RQRequestLine DAC and also note that the field type is PXString and not PXDBString as you have no need to store the vendor name, you’re just pulling the existing name as it is at that point in time).

[PXString(50, IsUnicode = true)]
[PXDBScalar(typeof(
Search<Vendor.acctName,
Where<Vendor.bAccountID, Equal<RQRequestLine.vendorID>>>))]
public virtual string VendorName { get; set; }

 

Badge +11

I think @Django is right here, but it’s hard to give helpful code without seeing your field declaration. From what I can piece together, your PXDBScalar attribute might look like this:

[PXDBScalar(typeof(SearchFor<SOOrder.status>.
In<SelectFrom<SOOrder>.
Where<SOOrder.orderType.IsEqual<SOOrderTypeConstants.salesOrder>.
And<SOOrder.orderNbr.IsEqual<FSSODetExt.usrOrderNbr>>>>))]

This is F-Bql, which requires

using PX.Data.BQL.Fluent;

 

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