Upravit

Sdílet prostřednictvím


RecalculatePrice Action

This action is used to trigger out of the box price calculation for Opportunity, Quote, Sales Order or Invoice entities. This action is applicable for both server and client invocations.

Parameters

Name Type Required Description
entityLogicalName String Yes Entity logical name
entityId GUID Yes Entity GUID

Examples

Server Invocation

Request

POST [Organization URI]/api/data/v9.1/RecalculatePrice
{
    "entityLogicalName": "quote",
    "entityId":"00aa00aa-bb11-cc22-dd33-44ee44ee44ee"
}

Response

HTTP/1.1 204 No Content
OData-Version: 4.0

Client Invocation

function RecalculatePrice(formContext) {
    var recalculatePriceRequest = {
        entityId: formContext.data.entity.getId(),
        entityLogicalName: formContext.data.entity.getEntityName(),
        Target: parameters.Target,
        getMetadata: function () {
            return {
                boundParameter: null,
                parameterTypes: {
                    "entityId": {
                        "typeName": "Edm.Guid",
                        "structuralProperty": 5,
                    },
                    "entityLogicalName": {
                        "typeName": "Edm.String",
                        "structuralProperty": 1,
                    },
                },
                operationType: 0,
                operationName: "RecalculatePrice"
            };
        }
    };
    Xrm.WebApi.online.execute(recalculatePriceRequest).then(
        function success(result) {
            if (result.ok) {
                //Success
            }
        },
        function (error) {
            Xrm.Utility.alertDialog(error.message);
        }
    );
}