Currently I am trying to block certain profiles from changing UnitPrice within Quote. I used validation rules under customize> QuoteLineItem and worked perfectly fine. However those validation rules only work when the product has been already added. The Issue I have right now; is when the user adds a product inside quote by clicking on "Add Line Item" they are prompted to a page where they can enter quantity. There is also a UnitPrice there as well. They are still allowed to change the price. I am not sure how i can access that page and how I can disable that field within the page. I thought the below trigger could do it, but I am not sure how to add certain profile or even where do i add that trigger to for this page.
Check if the value of "UnitPrice" has changed like
if(trigger.new[0].UnitPrice != trigger.old[0]).UnitPrice)
{
trigger.new[0].addError('You can not change the value of SalesPrice');
}
currently this is what I have as validation rule that stops user from changing price after the lineItem has been added
OR(AND(ISCHANGED(UnitPrice),$UserRole.Id = "00E..."),AND(ISCHANGED(UnitPrice),$UserRole.Id = "00E..."))
Updated: the new validation rule using my own profile ID as a test case
OR(
AND(ISNEW(), NOT(ISNULL(UnitPrice)),
AND(NOT(ISNEW()), ISCHANGED(UnitPrice)),$UserRole.Id = "00EG00....")
)
$UserRole.DeveloperName
instead of$UserRole.Id
. Are you testing as someone with a blacklisted role? – Adrian Larson♦ Dec 23 '16 at 17:12