How to Access Customer Location User Defined Field Defined in CR.Standalone.Location from Sales Order Graph ACUMATICA

I have a user defined field in customer screen (LocationExt.usrExpectedPaymentDate) as below,

User Defined Field in Customer Screen

I need to access this field for a calculation in the sales order entry graph but I get this error.

[2024-10-23 04:45:10.957] App_CodeCachesSOOrderEntry.cs(159): error CS0246: The type or namespace name ‘StandaloneLocationExt’ could not be found (are you missing a using directive or an assembly reference?)

using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using PX.Common;
using PX.Data;
using PX.Objects.AP;
using PX.Objects.AR;
using PX.Objects.CA;
using PX.Objects.CM;
using PX.Objects.CR;
using PX.Objects.CS;
using PX.Objects.DR;
using PX.Objects.EP;
using PX.Objects.GL;
using PX.Objects.IN;
using PX.Objects.PM;
using PX.Objects.PO;
using PX.Objects.TX;
using POLine = PX.Objects.PO.POLine;
using POOrder = PX.Objects.PO.POOrder;
using PX.CarrierService;
using PX.Concurrency;
using CRLocation = PX.Objects.CR.Standalone.Location;
using PX.Objects.AR.CCPaymentProcessing;
using PX.Objects.AR.CCPaymentProcessing.Common;
using PX.Objects.AR.CCPaymentProcessing.Helpers;
using PX.Objects.AR.CCPaymentProcessing.Interfaces;
using ARRegisterAlias = PX.Objects.AR.Standalone.ARRegisterAlias;
using PX.Objects.AR.MigrationMode;
using PX.Objects.Common;
using PX.Objects.Common.Discount;
using PX.Objects.Common.Extensions;
using PX.Objects.IN.Overrides.INDocumentRelease;
using PX.CS.Contracts.Interfaces;
using Message = PX.CarrierService.Message;
using PX.TaxProvider;
using PX.Data.DependencyInjection;
using PX.Data.WorkflowAPI;
using PX.LicensePolicy;
using PX.Objects.Extensions.PaymentTransaction;
using PX.Objects.SO.GraphExtensions.CarrierRates;
using PX.Objects.SO.GraphExtensions.SOOrderEntryExt;
using PX.Objects.SO.Attributes;
using PX.Objects.Common.Attributes;
using PX.Objects.Common.Bql;
using OrderActions = PX.Objects.SO.SOOrderEntryActionsAttribute;
using PX.Objects.SO.DAC.Projections;
using PX.Data.BQL.Fluent;
using PX.Data.Localization;
using PX.Data.Reports;
using PX.Objects.IN.DAC.Accumulators;
using PX.Data.BQL;
using PX.Objects.SO.Standalone;
using PX.Objects;
using PX.Objects.SO;
using CFMWT22072024;

namespace PX.Objects.SO
{
  public class SOOrderEntry_Extension : PXGraphExtension<PX.Objects.SO.SOOrderEntry>
  {
    #region Event Handlers
protected void SOLine_UsrAnticipatedInvDate_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e)
{
     var row = e.Row as SOLine;
            if (row == null) return;

            // Fetch the Sales Order
            SOOrder order = PXSelect<SOOrder,
                Where<SOOrder.orderNbr, Equal<Required<SOOrder.orderNbr>>>>
                .Select(Base, row.OrderNbr);
            if (order == null) return;

            // Fetch the Terms
            Terms terms = PXSelect<Terms,
                Where<Terms.termsID, Equal<Required<Terms.termsID>>>>
                .Select(Base, order.TermsID)
                .RowCast<Terms>()
                .FirstOrDefault();
            if (terms == null) return;

            // Get the anticipated invoice date from SOLine
            SOLineExt soLineExt = sender.GetExtension<SOLineExt>(row);
            DateTime? anticipatedInvoiceDate = soLineExt.UsrAnticipatedInvDate;
            if (anticipatedInvoiceDate == null) return;

            // Get the payment terms days
            int termsDays = terms.DayDue00.GetValueOrDefault();

            // Fetch the Location
            //Location location = PXSelect<Location,
            //    Where<Location.bAccountID, Equal<Required<Location.bAccountID>>,
             //   And<Location.locationID, Equal<Required<Location.locationID>>>>>
            //    .Select(Base, order.CustomerID, order.CustomerLocationID)
             //   .RowCast<Location>()
             //   .FirstOrDefault();
            //if (location == null) return;

            // Get the Location extension to access custom fields
           // LocationExt locationExt = PXCache<Location>.GetExtension<LocationExt>(location);
            // Fetch the Location using the CRLocation alias
    CRLocation location = PXSelect<CRLocation,
        Where<CRLocation.bAccountID, Equal<Required<CRLocation.bAccountID>>,
        And<CRLocation.locationID, Equal<Required<CRLocation.locationID>>>>>
        .Select(Base, order.CustomerID, order.CustomerLocationID)
        .RowCast<CRLocation>()
        .FirstOrDefault();
    if (location == null) return;

    // Get the Location extension to access custom fields
    StandaloneLocationExt locationExt = PXCache<CRLocation>.GetExtension<StandaloneLocationExt>(location);

            if (locationExt?.UsrExpectedPaymentDate == null) return;

            // Get the additional days from the Location UDF
            int additionalDays = locationExt.UsrExpectedPaymentDate.Value.Day;

            // Calculate the final expected payment date:
            // Anticipated Invoice Date + Terms Days + Additional Days from Location
            DateTime expectedPaymentDate = anticipatedInvoiceDate.Value
                .AddDays(termsDays)
                .AddDays(additionalDays);

            // Update the expected payment date in the SOLine
            sender.SetValueExt<SOLineExt.usrExpectedPaymentDate>(row, expectedPaymentDate);
}
}
}

How can I access this field in order to process my calculation?

Any help would be appreciated, thank you!

4

For the namespace problem, it appears you are missing a “using for PX.Objects.GDPR ? I am not sure whether or not your UDF field is a field added to Location table in SQL (eg. it looks like a PXCacheExtension of PX.Objects.CR.Location, not StandaloneLocationExt, but check your DAC code and where you created UsrExpectedPaymentDate and change code to something like:

location.GetExtension<LocationExt>();) 

or a BAccountKvExt value stored as UDF
(eg.

select * from baccountkvext where FieldName like '%ExpectedPaymentDate%')

If the latter, those KvExt fieldName have a leading string “Attribute”.
Below is an example that reads the ContactKvExt table to locate the Contact record of the given Customer:

if (e.NewValue != null)
        {
            // find the corresponding ContactID in the System
            Contact contact = PXSelectJoin<Contact,
                InnerJoin<ContactKvExt, On<Contact.noteID, Equal<ContactKvExt.recordID>>>,
                Where<Contact.bAccountID, Equal<Required<Contact.bAccountID>>,
                   And<ContactKvExt.fieldName, Equal<Required<ContactKvExt.fieldName>>,
                And<ContactKvExt.valueString, Equal<Required<ContactKvExt.valueString>>>>>>
                .Select(Base, row.CustomerID, "AttributeORDBY", (string)e.NewValue);

I was able to access the custom field using this line of code since I needed to access the custom field from Shipping tab of Customers screen from SOOrderEntry graph.

var locationExt = cache.GetExtension<PX.Objects.CR.Standalone.LocationExt>(row);

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật