Skip to main content
Solved

REST API: setting custom values using JSON


Forum|alt.badge.img+2

I can GET custom values using the REST API but when I trying setting, they remain NULL.

Question: what JSON structure do I use to set custom values?

Here’s an example when I use GET:

    "custom": {
        "Document": {
            "UsrDeviceIPaddress": {
                "type": "CustomStringField",
                "value": “100.99.777.55”
            }
        }
    }

However, when I use this same structure during a PUT to create a SalesOrder, the value is always null.

Best answer by jinin


Hi ​@bpgraves ,

Is this field created as a user-defined field (UDF) or a custom field added in the header section?

If it is a user-defined field (UDF), use the custom Json array. Otherwise, extend the endpoint, add the custom field, and then try again.


UDF Field:

"custom": {

        "Document": { 

            "AttributeIPaddress": {         // You should add "Attribute" as a prefix to the attribute name.

                "value": "100.99.777.55"

            }

        }

    }

Custom field on the screen:

"DeviceIPaddress": {

        "Value": "100.99.777.55"

    },

View original
Did this topic help you find an answer to your question?

9 replies

Samvel Petrosov
Jr Varsity II
Forum|alt.badge.img+5

Do you have any validations/masks on this field? 

Have you tried sending the value without “.”-s?


Forum|alt.badge.img+2
  • Author
  • Semi-Pro I
  • 66 replies
  • March 7, 2025
Samvel Petrosov wrote:

Do you have any validations/masks on this field? 

Have you tried sending the value without “.”-s?

No.  Why would the “.” make a difference?


Samvel Petrosov
Jr Varsity II
Forum|alt.badge.img+5
bpgraves wrote:
Samvel Petrosov wrote:

Do you have any validations/masks on this field? 

Have you tried sending the value without “.”-s?

No.  Why would the “.” make a difference?

I remember having hard time with fields that have fixed length and masks, in some cases although the REST API returns the value with the mask applied, it needs the value to be passed back without the mask. 

Could you please share both the GET and PUT requests that you are sending, also the code for the custom field?


Forum|alt.badge.img+2
  • Author
  • Semi-Pro I
  • 66 replies
  • March 7, 2025
Samvel Petrosov wrote:
bpgraves wrote:
Samvel Petrosov wrote:

Do you have any validations/masks on this field? 

Have you tried sending the value without “.”-s?

No.  Why would the “.” make a difference?

I remember having hard time with fields that have fixed length and masks, in some cases although the REST API returns the value with the mask applied, it needs the value to be passed back without the mask. 

Could you please share both the GET and PUT requests that you are sending, also the code for the custom field?

My GET call:

entity/Default/22.200.001/SalesOrder/WB/WB########?$custom=Document.UsrDeviceIPaddress

My POST call uses the same JSON object as I posted above.

I tried removing the Document level but I just get an API error.


Forum|alt.badge.img+2
  • Author
  • Semi-Pro I
  • 66 replies
  • March 8, 2025

Here’s what I’m using but it’s not working:

Acumatica


jinin
Pro I
Forum|alt.badge.img+11
  • Pro I
  • 702 replies
  • Answer
  • March 10, 2025


Hi ​@bpgraves ,

Is this field created as a user-defined field (UDF) or a custom field added in the header section?

If it is a user-defined field (UDF), use the custom Json array. Otherwise, extend the endpoint, add the custom field, and then try again.


UDF Field:

"custom": {

        "Document": { 

            "AttributeIPaddress": {         // You should add "Attribute" as a prefix to the attribute name.

                "value": "100.99.777.55"

            }

        }

    }

Custom field on the screen:

"DeviceIPaddress": {

        "Value": "100.99.777.55"

    },


Forum|alt.badge.img+2
  • Author
  • Semi-Pro I
  • 66 replies
  • March 10, 2025
jinin wrote:


Hi ​@bpgraves ,

Is this field created as a user-defined field (UDF) or a custom field added in the header section?

If it is a user-defined field (UDF), use the custom Json array. Otherwise, extend the endpoint, add the custom field, and then try again.


UDF Field:

"custom": {

        "Document": { 

            "AttributeIPaddress": {         // You should add "Attribute" as a prefix to the attribute name.

                "value": "100.99.777.55"

            }

        }

    }

Custom field on the screen:

"DeviceIPaddress": {

        "Value": "100.99.777.55"

    },

I’m not sure what you mean by UDF.  When I use the JSON you’ve listed above, I just get this error:

{"message":"An error has occurred.","exceptionMessage":"The column 'Document_AttributeUsrDeviceIPaddress' is not found in the data set.","exceptionType":"PX.Data.PXException","stackTrace":"   at PX.Api.PXSYRow.GetItem(String column)\r\n 

When I create my custom column, I do it in my customization project like this:

Anyway, extending the endpoint worked without having to actually have the field on the screen.


jinin
Pro I
Forum|alt.badge.img+11
  • Pro I
  • 702 replies
  • March 10, 2025

Hi ​@bpgraves ,

A User-Defined Field (UDF) in Acumatica is a custom field that can be added directly to data entry forms through the User-Defined Fields tab without modifying the database structure or writing code. 
These fields allow users to extend standard forms dynamically, making them more flexible for business-specific needs.
 

 


Forum|alt.badge.img+2
  • Author
  • Semi-Pro I
  • 66 replies
  • March 10, 2025
jinin wrote:

Hi ​@bpgraves ,

A User-Defined Field (UDF) in Acumatica is a custom field that can be added directly to data entry forms through the User-Defined Fields tab without modifying the database structure or writing code. 
These fields allow users to extend standard forms dynamically, making them more flexible for business-specific needs.
 

 

Thanks for the explanation but once you told me that not using a UDF required extended the endpoint and adding the field, everything started working!  😄


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings