Redigera

Dela via


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.

License and role requirements

Requirement type You must have
License Dynamics 365 Sales Premium or Dynamics 365 Sales Enterprise
More information: Dynamics 365 Sales pricing
Security roles System customizer
More information: Predefined security roles for Sales

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);
        }
    );
}