Skip to main content
Solved

Acumatica API not returning a field value

  • April 3, 2022
  • 14 replies
  • 421 views

Forum|alt.badge.img

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..

Best answer by adilaleem

@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

14 replies

Dmitrii Naumov
Acumatica Moderator
Forum|alt.badge.img+7
  • Acumatica Moderator
  • April 3, 2022

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.


Forum|alt.badge.img
  • Author
  • Jr Varsity III
  • April 4, 2022

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..


Forum|alt.badge.img
  • Author
  • Jr Varsity III
  • April 4, 2022

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??


Dmitrii Naumov
Acumatica Moderator
Forum|alt.badge.img+7
  • Acumatica Moderator
  • April 4, 2022

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)


Forum|alt.badge.img
  • Author
  • Jr Varsity III
  • April 4, 2022

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?


Dmitrii Naumov
Acumatica Moderator
Forum|alt.badge.img+7
  • Acumatica Moderator
  • April 4, 2022

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


Forum|alt.badge.img
  • Author
  • Jr Varsity III
  • April 4, 2022

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?


Dmitrii Naumov
Acumatica Moderator
Forum|alt.badge.img+7
  • Acumatica Moderator
  • April 4, 2022

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


Forum|alt.badge.img
  • Author
  • Jr Varsity III
  • April 4, 2022

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.


Dmitrii Naumov
Acumatica Moderator
Forum|alt.badge.img+7
  • Acumatica Moderator
  • April 4, 2022

@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?


Forum|alt.badge.img
  • Author
  • Jr Varsity III
  • April 4, 2022

@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. 


Dmitrii Naumov
Acumatica Moderator
Forum|alt.badge.img+7
  • Acumatica Moderator
  • April 4, 2022

@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.


Forum|alt.badge.img
  • Author
  • Jr Varsity III
  • Answer
  • April 5, 2022

@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


Forum|alt.badge.img
  • Author
  • Jr Varsity III
  • April 6, 2022

@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.