Solved

Acumatica API not returning a field value


Userlevel 2
Badge

Hi,

I’m using Acumatica API in a C# project. I wrote following code to access all the Purchase Receipts:

if (InitAPI() == false) { return ""; }
                PO302000Content POReceipt = context.PO302000GetSchema();
                #region Fields
                List<Command> cmdSelect = new List<Command>();
                cmdSelect.Add(POReceipt.DocumentSummary.ReceiptNbr);
                cmdSelect.Add(POReceipt.DocumentSummary.VendorRef);
                cmdSelect.Add(POReceipt.DocumentSummary.Status);
                cmdSelect.Add(POReceipt.DocumentSummary.ExternalNbr);
                cmdSelect.Add(POReceipt.Other.Branch);
                cmdSelect.Add(POReceipt.Other.BillDate);
                cmdSelect.Add(POReceipt.Other.INRefNbr);
                cmdSelect.Add(POReceipt.Details.InventoryID);
                Field lmd = new Field
                {
                    ObjectName = POReceipt.DocumentSummary.ReceiptNbr.ObjectName,
                    FieldName = "LastModifiedDateTime"
                };
                cmdSelect.Add(lmd);
                Field cdt = new Field
                {
                    ObjectName = POReceipt.DocumentSummary.ReceiptNbr.ObjectName,
                    FieldName = "CreatedDateTime"
                };
                cmdSelect.Add(cdt);
                #endregion Fields

                #region Filters
                List<Filter> filters = new List<Filter>();
                filters.Add(new Filter()
                {
                    Field = new Field
                    {
                        ObjectName = POReceipt.DocumentSummary.ReceiptNbr.ObjectName,
                        FieldName = "CreatedDateTime"
                    },
                    Condition = FilterCondition.GreaterOrEqual,
                    Value = DateTime.Now.AddDays(-1).ToLongDateString(),
                    Operator = FilterOperator.And
                });

                #endregion Filters

                var POReceiptExport = context.PO302000Export(cmdSelect.ToArray(), filters.ToArray(), 0, false, false);
                foreach (var dd in POReceiptExport)
                {
                    
                }

 

I’m getting all the field values correctly except INRefNbr.  Which is showing me a blank value. I checked all the PO Receipts are in released status and have a value in this field at screen. Any idea why I’m not getting this field value and how to resolve that? would really appreciate your help..

icon

Best answer by adilaleem 5 April 2022, 08:12

View original

14 replies

Userlevel 7
Badge +5

Is there any reason you are using old ‘screen based api’ and not Contract Based REST  API?

I’d recommend you switch to the newer one.

Userlevel 2
Badge

Is there any reason you are using old ‘screen based api’ and not Contract Based REST  API?

I’d recommend you switch to the newer one.

Even though I used the latest contract based rest API, it didn’t change the result:

 

You can see the status is released but INRefNbr is still blank.

Please suggest..

Userlevel 2
Badge

Is there any reason you are using old ‘screen based api’ and not Contract Based REST  API?

I’d recommend you switch to the newer one.

Even though I used the latest contract based rest API, it didn’t change the result:

 

You can see the status is released but INRefNbr is still blank.

Please suggest..

One more strange thing.. I tried to add this field in generic inquiry and it is not displaying over there too. Is this an special field? how can I see the value in APIs and GIs??

Userlevel 7
Badge +5

I’ve checked the code and it seems to be a bug. 

The thing is the field is being calculated on the fly by selecting INTran records with corresponding ReceiptNumber. It is being optimized out by the API engine. 

I’ll let the engineering team know.

 

As a workaround you can select INTran records with the Receipt number (.e.g via GI)

Userlevel 2
Badge

I’ve checked the code and it seems to be a bug. 

The thing is the field is being calculated on the fly by selecting INTran records with corresponding ReceiptNumber. It is being optimized out by the API engine. 

I’ll let the engineering team now.

 

As a workaround you can select INTran records with the Receipt number (.e.g via GI)

Where are the INTran records?

Userlevel 7
Badge +5

I think you’d need to use a generic inquiry to retrieve the INTran records. 

Userlevel 2
Badge

I think you’d need to use a generic inquiry to retrieve the INTran records. 

yes this is something I’m working on. I already created a generic inquiry which is displaying this field but now trying to figuring out how to access generic inquiry through REST API. basically having a hard time to add GI in the extended endpoint. do you know any documentation about how to use GIs through API?

Userlevel 7
Badge +5

To create a new endpoint you may need to follow this article:

https://help-2022r1.acumatica.com/Help?ScreenId=ShowWiki&pageid=709351cc-566a-47b3-b153-3a9fdd690ce0

 

Also, the GI mapping should appear automatically on new versions once you add it to the endpoint. 

 

As to how to retrieve the data from a GI through REST API, this article is useful:

https://help-2022r1.acumatica.com/Help?ScreenId=ShowWiki&pageid=6340cff3-4732-4231-9e42-5d1e5e65b5dd

Userlevel 2
Badge

To create a new endpoint you may need to follow this article:

https://help-2022r1.acumatica.com/Help?ScreenId=ShowWiki&pageid=709351cc-566a-47b3-b153-3a9fdd690ce0

 

Also, the GI mapping should appear automatically on new versions once you add it to the endpoint. 

 

As to how to retrieve the data from a GI through REST API, this article is useful:

https://help-2022r1.acumatica.com/Help?ScreenId=ShowWiki&pageid=6340cff3-4732-4231-9e42-5d1e5e65b5dd

“GI” and “GI forms” are two different objects, the one given in the solution is “GI form”. The GI I created for PO Receipt isn’t coming over to web endpoint.

Userlevel 7
Badge +5

@adilaleem what do you mean by GI and GI forms?

I think we usually mean an inquiry form that can be created on the Generic Inquiry screen (SM208000) in the system.

Do you mean something else by GI?

Userlevel 2
Badge

@adilaleem what do you mean by GI and GI forms?

I think we usually mean an inquiry form that can be created on the Generic Inquiry screen (SM208000) in the system.

Do you mean something else by GI?

I takes GI as Generic Inquiry which is a profile and the screen code is SM208000.. while “Inventory Summary” is an Inquiry form and the screen code is IN401000. Under endpoint you can add inquiry forms but not the generic inquiry profiles. 

Userlevel 7
Badge +5

@adilaleem I see. 

In the GI configuration you should check "Make visible in Menu/UI" checkbox and it'll allow you to assign a sitemap path to the GI. After that you will be able to map it in an endpoint.

Userlevel 2
Badge

@adilaleem what do you mean by GI and GI forms?

I think we usually mean an inquiry form that can be created on the Generic Inquiry screen (SM208000) in the system.

Do you mean something else by GI?

I takes GI as Generic Inquiry which is a profile and the screen code is SM208000.. while “Inventory Summary” is an Inquiry form and the screen code is IN401000. Under endpoint you can add inquiry forms but not the generic inquiry profiles. 

Here it is… solved!! you are the man Dmitrii… Thanks

Userlevel 2
Badge

@adilaleem I see. 

In the GI configuration you should check "Make visible in Menu/UI" checkbox and it'll allow you to assign a sitemap path to the GI. After that you will be able to map it in an endpoint.

This solved my problem.

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