Reigner Ouano
Reigner Ouano

Reputation: 135

How to Get Custom Field value acumatica

I'm new in developing acumatica I am stuck at getting the value of a custom TextEdit field that I created. I can get all of the built-in field value through this code

InventoryItem items = (InventoryItem)Base.Item.Cache.Current;

but I cannot get the one that I have created at acumatica customization here is the field I want to get

https://i.sstatic.net/gPln4.png

I already tried

InventoryItem items = (InventoryItem)Base.ItemSettings.Cache.Current;

var shortdesc = items.UsrShortDescription;

But it's not working and does not show the value inside the textbox thank you in advance for helping

Upvotes: 1

Views: 1195

Answers (3)

vachmir
vachmir

Reputation: 21

This is an example of getting value from a non-extension field. I did not use extension DAC to add the Gift card field to the store setup screen.

enter image description here

In a method I need to get the value of that field. I should check whether the order contains Gift card item or not.

 public static bool GiftcardName(OrderModel orders, BZWoocommerceStore store)
 {
     // "ZGift CArd W" => "giftcard"
     string wooCommName = string.Empty;
     string wooCommNameNoSpases = string.Empty;

     bool containsGiftcardName = false;
     bool isGiftcard = false;


     foreach (OrderLineModel line in orders.LineItems)
     {
         string gNameInAcumatica = store.GiftcardIdentifier;

         string gNameInAcumaticaWithoutSpaces = gNameInAcumatica.Replace(" ", "");

         wooCommName = line.Name; //pattern
         wooCommNameNoSpases = wooCommName.Replace(" ", "");
         //wooCommNameNoSpases =  new string(wooCommName.ToCharArray()
         //    .Where(c => !Char.IsWhiteSpace(c))
         //    .ToArray());
         //woCommNameNoUperCase= wooCommNameNoSpases.ToLower();
         //isGiftcardName= woCommNameNoUperCase.Contains(gName);
         //containsGiftcardName = wooCommNameNoSpases.Contains(gName);

         containsGiftcardName = Regex.IsMatch(wooCommNameNoSpases, gNameInAcumaticaWithoutSpaces, RegexOptions.IgnoreCase);

         if(containsGiftcardName)
         {
             isGiftcard = true;
         }
     }

     return isGiftcard;
 }

So, when I call this method I give to that 2 arguments, orders and store. The store argument was created in this way.

     public PXSelect<BZWoocommerceOrder> Order;

In an action method I wrote this.

string storeCode = this.Order.Current.StoreCode;
BZWoocommerceStore store = PXSelect<BZWoocommerceStore, Where<BZWoocommerceStore.storeCode, Equal<Required<BZWoocommerceStore.storeCode>>>>.Select(this, storeCode);

My GiftcardName() method sees the value of original field. Writing "Original" I mean that you do not use any technique like this one.

BZSOOrderExt rowExt = sender.GetExtension<BZSOOrderExt>(row);

Upvotes: 0

Yuriy Zaletskyy
Yuriy Zaletskyy

Reputation: 5151

Vardan showed one way, for completeness of picture want to show another as well:

InventoryItem items = (InventoryItem)Base.ItemSettings.Current;
var itemExt = items.GetExtension<InventoryItemExt>();

Upvotes: 1

Vardan Vardanyan
Vardan Vardanyan

Reputation: 669

InventoryItem items = (InventoryItem)Base.ItemSettings.Current;
var itemExt = PXCache<InventoryItem>.GetExtension<InventoryItemExt>(items);
var shortdesc = itemExt.UsrShortDescription;

Upvotes: 2

Related Questions