Skip to main content

The Sales Order screen has an option to “Recalculate Prices”, which displays a dialog box containing several options including “Set Current Unit Prices”. I’d like to invoke this functionality using the REST API.

 

I’ve discovered the /SalesOrder/AutoRecalculateDiscounts API action, which seems to be the correct endpoint. However, I’m not sure how to pass a parameter indicating that ‘current unit prices’ should be set.

A payload like this does not cause the unit prices to be updated:

 

POST /entity/Default/22.200.001/SalesOrder/AutoRecalculateDiscounts HTTP/1.1
{
    "entity" :
    {
        "OrderType" : {"value" : "SO"},
        "OrderNbr" : {"value" : "002215"}
    },
    "parameters": { }
}

(EDIT: I’ll note that “DisableAutomaticDiscountCalculation” is set to false for the SO in question.)

What’s the correct parameter to supply this endpoint for unit prices to be updated? The swagger.json file doesn’t appear to contain any information about parameters for this action. Any assistance is appreciated, thank you!

Parameters for the /AutoRecalculateDiscounts action can be sent as shown in the example below

 

{
"entity" :
{
"OrderType" : {"value" : "SO"},
"OrderNbr" : {"value" : "SO008266"}
},
"parameters": {
"custom": {
"recalcdiscountsfilter": {
"RecalcTarget": {
"type" : "CustomStringField",
"value" : "All Lines"
}
}
}
}
}

Also, the filter and the field can be found by inspecting the element 


The help article on how to execution custom action has the example which should be of help

https://help.acumatica.com/(W(20))/Help?ScreenId=ShowWiki&pageid=f01f3b8b-56c4-48ab-a043-dcbb10e3bfb3

Also, to identify the view & field, please use the article below

https://help.acumatica.com/(W(20))/Help?ScreenId=ShowWiki&pageid=bd0d8a36-b00b-44c8-bdcd-b2b4e4c86fd0


Thank you for the detailed reply, Varthini.

 

With your help, I have been able to identify the view and parameter names (for my purposes, “RecalcTarget”, and “RecalcUnitPrices”; belonging to the “RecalcDiscountsParamFilter” object, with a view name of “recalcdiscountsfilter”).

 

However, executing the API action still has apparent effect on the order.

 

I’ve created a sales order, and when I select the “Recalculate Prices” option in the Acumatica UI (with the target of “All Lines” and, “Set Current Unit Prices” enabled), the prices are updated to reflect the correct sales prices. However, executing an equivalent API request does no affect the sales order’s prices. Indeed, the request has no apparent effects whatsoever. The HTTP status is 204, and there is no data in the response’s body.

 

Is there another reason, beyond the API parameter names, why this operation could fail to update prices, when the UI option does not? Thanks again!

 

Some of the HTTP payloads I’ve tried, which did not successfully affect the sales order:

{
  "entity": {
    "OrderType": {
      "value": "SO"
    },
    "OrderNbr": {
      "value": "002354"
    }
  },
  "parameters": {
    "custom": {
      "recalcdiscountsfilter": {
        "RecalcTarget": {
          "type": "CustomStringField",
          "value": "All Lines"
        },
        "RecalcUnitPrices": {
          "type": "CustomBooleanField",
          "value": "true"
        }
      }
    }
  }
}

 

 

Attempting to use “id” rather than “OrderType”/”OrderNbr” has no effect:

{
  "entity": {
    "id": "06d67ff2-a976-ef11-835e-0a640ff6d111"
  },
  "parameters": {
    "custom": {
      "recalcdiscountsfilter": {
        "RecalcTarget": {
          "type": "CustomStringField",
          "value": "All Lines"
        },
        "RecalcUnitPrices": {
          "type": "CustomBooleanField",
          "value": "true"
        }
      }
    }
  }
}

 

Attempting to use “ALL” instead of “All Lines” as the target has no effect)

{
  "entity": {
    "OrderType": {
      "value": "SO"
    },
    "OrderNbr": {
      "value": "002354"
    }
  },
  "parameters": {
    "custom": {
      "recalcdiscountsfilter": {
        "RecalcTarget": {
          "type": "CustomStringField",
          "value": "ALL"
        },
        "RecalcUnitPrices": {
          "type": "CustomBooleanField",
          "value": "true"
        }
      }
    }
  }
}


Excuse me, I intended to say the action has no apparent affect on the sales order.


The status of these action calls can be retrieved by making a GET call to the “Location” header of the response to the action call.

 


Can you please check the status?

Reference:

https://help.acumatica.com/(W(1))/Help?ScreenId=ShowWiki&pageid=91bf9106-062a-47a8-be1f-b48517a54324


Hello,

Thanks again for the reply!

The “location:” header returned from AutoRecalculateDiscounts contains a value like “/entity/Default/22.200.001/SalesOrder/14e101bd-c675-ef11-835e-0a640ff6d111”

Invoking GET on that location gives me a JSON representation of the sales order that I’m attempting to modify. I’ve attached that data.

The prices shown in that JSON are identical to what I see when viewing the sales order in the Acumatica UI. That is to say, after running AutoReclculatePrices and fetching the returned location, the prices have not been modified in the way they are when pressing the “Recalculate Prices” button in the UI.


Hi @dominicfedco were you able to find a solution? Thank you!


Reply