Skip to main content
Solved

Create new Purchase Receipt Type

  • October 19, 2023
  • 8 replies
  • 251 views
  • Translate All

Denham
Jr Varsity III
Forum|alt.badge.img

Hello Everyone

I am trying to create a new Purchase Receipt type. Currently we have the default types of Receipt, Return, and Transfer Receipt. I am trying to a new type to this drop down called “DNS Return”. I basically need it to function in the exact same way as the current “Return” type.

I understand how to add the value to the dropdown via a customization project and adding the new value to the combo box. But what I cant figure out is how I also modify the workflow so it handles this type using the RN workflow as there doesnt seem to be an area to control that in the workflow editor.

For reference, I am on Acumatica 2022 R1.

As always, any and all help is greatly appreciated!

Best answer by Vignesh Ponnusamy

Hi @Denham,

Interesting question.!

I think the issue with how you are adding the receipt type. Instead of adding the type from the customization project, you can override the DAC definition by creating a custom POReceiptType attribute with the new receipt type.

Then we are just replacing the default POReceiptType attribute with the custom attribute. Example below,

using CRLocation = PX.Objects.CR.Standalone.Location;
using PX.Common;
using PX.Data.BQL.Fluent;
using PX.Data.ReferentialIntegrity.Attributes;
using PX.Data.WorkflowAPI;
using PX.Data;
using PX.Objects.AP;
using PX.Objects.AR;
using PX.Objects.CM.Extensions;
using PX.Objects.Common.Bql;
using PX.Objects.Common.GraphExtensions.Abstract;
using PX.Objects.Common;
using PX.Objects.CR;
using PX.Objects.CS;
using PX.Objects.GL.FinPeriods.TableDefinition;
using PX.Objects.GL;
using PX.Objects.IN;
using PX.Objects.PM;
using PX.Objects.PO;
using PX.Objects;
using PX.TM;
using System.Collections.Generic;
using System.Linq;
using System;

namespace PX.Objects.PO
{
[PXNonInstantiatedExtension]
public class PO_POReceipt_ExistingColumn : PXCacheExtension<PX.Objects.PO.POReceipt>
{
#region ReceiptType
[PXDBString(2, IsFixed = true, IsKey = true, InputMask = "")]
[PXDefault(POReceiptType.POReceipt)]
[PO_POReceipt_ExistingColumn.POReceiptTypeCustom.List()]
[PXUIField(DisplayName = "Type")]
[PX.Data.EP.PXFieldDescription]

public string ReceiptType { get; set; }
#endregion

public class POReceiptTypeCustom
{
public const string All = "AL";
public const string TransferReceipt = "RX";
public const string POReceipt = "RT";
public const string POReturn = "RN";
public const string DReturn = "DN";
public class ListAttribute : PXStringListAttribute
{
private static (string, string)[] ValuesToLabels = new[]
{
(POReceipt, Messages.PurchaseReceipt),
(POReturn, Messages.PurchaseReturn),
(TransferReceipt, Messages.TransferReceipt),
(DReturn, "DNS Return")
};

public ListAttribute() : this(false) { }

protected ListAttribute(bool all) : base(
all
? (new[] { (All, Messages.All) }).Concat(ValuesToLabels).ToArray()
: ValuesToLabels)
{ }

internal bool TryGetValue(string label, out string value)
{
var index = Array.IndexOf(_AllowedLabels, label);
if (index >= 0)
{
value = _AllowedValues[index];
return true;
}
value = null;
return false;
}

public class WithAll : ListAttribute
{
public WithAll() : base(true) { }
}
}
}
}
}

Publish the customization project, then the new receipt type should show-up in the Workflow Type to which you can use RN Workflow 

 

Once you add the workflow for the new type, you can Activate and publish it. I have attached the customization project you could try, I am not sure if the workflow is completely functional. But I think that should give some lead towards the solution.

Good Luck.! 

View original

8 replies

Denham
Jr Varsity III
Forum|alt.badge.img
  • Author
  • October 19, 2023

Just to add, here is how I have added the value to the “Type” combo box.
 

 

Translate

Denham
Jr Varsity III
Forum|alt.badge.img
  • Author
  • October 23, 2023

Bump

Any ideas? 

Translate

RohitRattan88
Acumatica Moderator
Forum|alt.badge.img+5

@Denham  I havent tested myself, but you could try to extend Default workflow from your RN workflow and I believe system would apply this new workflow to your custom state:

 

Good luck

Translate

Denham
Jr Varsity III
Forum|alt.badge.img
  • Author
  • October 24, 2023

Hi @RohitRattan88 

I have tried extending the RN workflow, but this does not work. I am actually adding a new Document Type, not a new state in the workflow. By default, the system is trying to use the RT (Receipt) workflow for the new document type.

Translate

RohitRattan88
Acumatica Moderator
Forum|alt.badge.img+5

Even after you enable DEFAULT worklow?

Translate

Vignesh Ponnusamy
Acumatica Moderator
Forum|alt.badge.img+5

Hi @Denham,

Interesting question.!

I think the issue with how you are adding the receipt type. Instead of adding the type from the customization project, you can override the DAC definition by creating a custom POReceiptType attribute with the new receipt type.

Then we are just replacing the default POReceiptType attribute with the custom attribute. Example below,

using CRLocation = PX.Objects.CR.Standalone.Location;
using PX.Common;
using PX.Data.BQL.Fluent;
using PX.Data.ReferentialIntegrity.Attributes;
using PX.Data.WorkflowAPI;
using PX.Data;
using PX.Objects.AP;
using PX.Objects.AR;
using PX.Objects.CM.Extensions;
using PX.Objects.Common.Bql;
using PX.Objects.Common.GraphExtensions.Abstract;
using PX.Objects.Common;
using PX.Objects.CR;
using PX.Objects.CS;
using PX.Objects.GL.FinPeriods.TableDefinition;
using PX.Objects.GL;
using PX.Objects.IN;
using PX.Objects.PM;
using PX.Objects.PO;
using PX.Objects;
using PX.TM;
using System.Collections.Generic;
using System.Linq;
using System;

namespace PX.Objects.PO
{
[PXNonInstantiatedExtension]
public class PO_POReceipt_ExistingColumn : PXCacheExtension<PX.Objects.PO.POReceipt>
{
#region ReceiptType
[PXDBString(2, IsFixed = true, IsKey = true, InputMask = "")]
[PXDefault(POReceiptType.POReceipt)]
[PO_POReceipt_ExistingColumn.POReceiptTypeCustom.List()]
[PXUIField(DisplayName = "Type")]
[PX.Data.EP.PXFieldDescription]

public string ReceiptType { get; set; }
#endregion

public class POReceiptTypeCustom
{
public const string All = "AL";
public const string TransferReceipt = "RX";
public const string POReceipt = "RT";
public const string POReturn = "RN";
public const string DReturn = "DN";
public class ListAttribute : PXStringListAttribute
{
private static (string, string)[] ValuesToLabels = new[]
{
(POReceipt, Messages.PurchaseReceipt),
(POReturn, Messages.PurchaseReturn),
(TransferReceipt, Messages.TransferReceipt),
(DReturn, "DNS Return")
};

public ListAttribute() : this(false) { }

protected ListAttribute(bool all) : base(
all
? (new[] { (All, Messages.All) }).Concat(ValuesToLabels).ToArray()
: ValuesToLabels)
{ }

internal bool TryGetValue(string label, out string value)
{
var index = Array.IndexOf(_AllowedLabels, label);
if (index >= 0)
{
value = _AllowedValues[index];
return true;
}
value = null;
return false;
}

public class WithAll : ListAttribute
{
public WithAll() : base(true) { }
}
}
}
}
}

Publish the customization project, then the new receipt type should show-up in the Workflow Type to which you can use RN Workflow 

 

Once you add the workflow for the new type, you can Activate and publish it. I have attached the customization project you could try, I am not sure if the workflow is completely functional. But I think that should give some lead towards the solution.

Good Luck.! 

Translate

RohitRattan88
Acumatica Moderator
Forum|alt.badge.img+5

@Denham  while @Vignesh Ponnusamy’s approach would let you add custom value and related workflow, I would suggest lots of testing before going live because there might be places in the code where execution might rely on system values.

Good luck

Translate

Denham
Jr Varsity III
Forum|alt.badge.img
  • Author
  • October 30, 2023

@Vignesh Ponnusamy 

Thank you very much for this. This gives me a great starting point!

Translate