Solved

CRExtensionHelper.UpdateServiceOrderHeader()

  • 18 January 2023
  • 4 replies
  • 67 views

Userlevel 4
Badge

update from 2020 r2 to 2022 r2 and got the following error in the following code.

 

Kindly assist.

All responses will be highly appreciated.

 

icon

Best answer by Django 20 January 2023, 16:58

View original

4 replies

Userlevel 7
Badge +5

Searching the source code I can confirm that CRExtensionHelper.cs no longer includes that method.  Searching for UpdateServiceOrderHeader reveals it in SM_CRCaseMaint.cs and SM_SOOrderEntry.cs.

You may want to review the source code from 2020 R2 and see how it compares to the methods in the files I mentioned above to see which one you want to reference in your code.

Userlevel 4
Badge

T

Searching the source code I can confirm that CRExtensionHelper.cs no longer includes that method.  Searching for UpdateServiceOrderHeader reveals it in SM_CRCaseMaint.cs and SM_SOOrderEntry.cs.

You may want to review the source code from 2020 R2 and see how it compares to the methods in the files I mentioned above to see which one you want to reference in your code.

 

Thank you for this, really helpful.

This [SM_CRCaseMaint.cs] is the one am supposed to use. Tried to implement it. 

I’m getting an error;

 

See full code below;

using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using PX.Common;
using PX.Data;
using System.Collections;
using PX.Data.EP;
using PX.Objects.AR;
using PX.Objects.CT;
using PX.Objects.GL;
using PX.Objects.EP;
using PX.Objects.IN;
using PX.Objects.PM;
using PX.SM;
using PX.TM;
using PX.Objects;
using PX.Objects.CR;
using PX.Objects.FS;
using PX.Objects.SM;
namespace PX.Objects.CR
{
public class CRCaseMaint_Extension : PXGraphExtension<CRCaseMaint>
{
#region Event Handlers
public PXFilter<FSCreateServiceOrderOnCaseFilter> CreateServiceOrderFilter;

public override void Initialize()
{
this.Base.Action.AddMenuAction(CreateServiceOrders);
base.Initialize();
}


public PXAction<CRCase> CreateServiceOrders;
[PXButton]
[PXUIField(DisplayName = "Create Service Orders", Visible = true, MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select)]
public virtual void createServiceOrders()
{
CRCase crCaseRow = Base.Case.Current;
FSxCRCase fsxCRCaseRow = Base.Case.Cache.GetExtension<FSxCRCase>(crCaseRow);
if (crCaseRow.CustomerID == null && crCaseRow.ContactID == null)
{
throw new PXException("You can not create proceed." + Environment.NewLine + "The Business Account and Contact are NULL.");
}
if (crCaseRow.CustomerID == null)
{
throw new PXException("You can not create proceed." + Environment.NewLine + "The Business Account is NULL.");
}
if (crCaseRow.ContactID == null)
{
throw new PXException("You can not create proceed." + Environment.NewLine + "The ContactID is NULL.");
}
if (CreateServiceOrderFilter.AskExt() == WebDialogResult.OK)
{
fsxCRCaseRow.SDEnabled = true;
fsxCRCaseRow.BranchLocationID = CreateServiceOrderFilter.Current.BranchLocationID;
fsxCRCaseRow.SrvOrdType = CreateServiceOrderFilter.Current.SrvOrdType;
fsxCRCaseRow.AssignedEmpID = CreateServiceOrderFilter.Current.AssignedEmpID;
fsxCRCaseRow.ProblemID = CreateServiceOrderFilter.Current.ProblemID;

PXLongOperation.StartOperation(Base, delegate ()
{
CreateServiceOrderDocument(Base, crCaseRow, CreateServiceOrderFilter.Current);
});
}
}



private void CreateServiceOrderDocument(CRCaseMaint graphCRCaseMaint, CRCase crCaseRow, FSCreateServiceOrderOnCaseFilter fsCreateServiceOrderOnCaseFilterRow)
{
if (graphCRCaseMaint == null || crCaseRow == null || fsCreateServiceOrderOnCaseFilterRow == null)
{
return;
}

ServiceOrderEntry graphServiceOrderEntry = PXGraph.CreateInstance<ServiceOrderEntry>();

FSServiceOrder newServiceOrderRow = CRExtensionHelper.InitNewServiceOrder(CreateServiceOrderFilter.Current.SrvOrdType, ID.SourceType_ServiceOrder.CASE);

graphServiceOrderEntry.ServiceOrderRecords.Current = graphServiceOrderEntry.ServiceOrderRecords.Insert(newServiceOrderRow);

//CRExtensionHelper.UpdateServiceOrderHeader(
// graphServiceOrderEntry,
// Base.Case.Cache,
// crCaseRow,
// fsCreateServiceOrderOnCaseFilterRow,
// graphServiceOrderEntry.ServiceOrderRecords.Current,
// true);

SM_CRCaseMaint.UpdateServiceOrderHeader(
graphServiceOrderEntry,
Base.Case.Cache,
crCaseRow,
fsCreateServiceOrderOnCaseFilterRow,
graphServiceOrderEntry.ServiceOrderRecords.Current,
true);

//graphServiceOrderEntry.ServiceOrderRecords.Current.SourceID = crCaseRow.CaseCD;
graphServiceOrderEntry.ServiceOrderRecords.Current.SourceRefNbr = crCaseRow.CaseCD;

if (!Base.IsContractBasedAPI)
{
throw new PXRedirectRequiredException(graphServiceOrderEntry, null);
}
}
}
#endregion
}

 

 

 

Userlevel 4
Badge

Searching the source code I can confirm that CRExtensionHelper.cs no longer includes that method.  Searching for UpdateServiceOrderHeader reveals it in SM_CRCaseMaint.cs and SM_SOOrderEntry.cs.

You may want to review the source code from 2020 R2 and see how it compares to the methods in the files I mentioned above to see which one you want to reference in your code.

Kindly assist in implementing this i.e SM_CRCaseMaint.cs.

Userlevel 7
Badge +5

Just having a quick look I see that SM_CRCaseMaint is a Graph Extension of CRCaseMaint.  The error message is tell you that you need a variable (object) that is of type SM_CRCaseMaint and then that variable has a method you can call.

Looking at the declaration of your method:

private void CreateServiceOrderDocument(CRCaseMaint graphCRCaseMaint, CRCase crCaseRow, FSCreateServiceOrderOnCaseFilter fsCreateServiceOrderOnCaseFilterRow)

I see your first parameter is a variable of type CRCaseMaint.

So I’ll take a guess that you need a line of code something like:

SM_CRCaseMaint caseMaintExt = graphCRCaseMaint.GetExtension<SM_CRCaseMaint>();

caseMaintExt.UpdateServiceOrderHeader(
graphServiceOrderEntry,
Base.Case.Cache,
crCaseRow,
fsCreateServiceOrderOnCaseFilterRow,
graphServiceOrderEntry.ServiceOrderRecords.Current,
true);

I’m not certain but I think this is the direction you need to take.

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