Back to Blog Listing
Why Lock Prices?
Invoices within Microsoft Dynamics CRM have an option to allow the user to "Lock Pricing" as an option in the toolbar of the Invoice form window.
This facility ensures that any changes to the price of the products do not impact the invoice.
As such when an invoice has been issued to a customer it is necessary to ensure that the prices have been locked.
If you are using workflows to automate the invoicing processes then it may be necessary to lock the pricing via code.
How to Lock Prices via Workflows / Code
Unfortunately it is not possible to update the "ispricelocked" attribute to be "Yes"/"No" via a standard workflow step. This has to be achieved via a custom workflow step.
Within the custom workflow step the attribute "ispricelocked" cannot be simply updated in the standard way as it is a read only field, within the API as well as the form. To set this attribute you must use a "LockInvoicePricingRequest". Please see example on how to use this below:
req.InvoiceId = inv.InvoiceId
It is worth noting that after you have locked the pricing that any changes to you Invoice Product lines will not be impacted by any workflows/code. As such you need to consider carefully when the invoice pricing should be locked e.g. when the invoice is emailed to the client.