function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Behzad Bahadori 18Behzad Bahadori 18 

Make UnitPrice read Only using formula field, when "Add Line Item"

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.
User-added image
how do I add profile to this, and also this didnt work 
 
OR( 
AND(ISNEW(), NOT(ISNULL(UnitPrice)), 
AND(NOT(ISNEW()), ISCHANGED(UnitPrice))) 
)


 
Best Answer chosen by Behzad Bahadori 18
Akhil AnilAkhil Anil
Hi Behzad,

Sorry about that. You should be using this formula !
 
AND( 
OR( 
ISNEW(), 
ISCHANGED(UnitPrice)
), 
UnitPrice <>  PricebookEntry.UnitPrice,
OR(
$Profile.Name = "Profile Name here",
$Profile.Name = "Profile Name here"
)
)

 

All Answers

Alain CabonAlain Cabon
Hello Behzad,

Why don't you use the "Field Accessibility" control?  "Read-Only" or "Editable".

User-added image

Best regards and happy Christmas!

Alain
Akhil AnilAkhil Anil
Hi Behzad,

You just have to tweak your validation rule like this to ensure that it's triggered during creation as well. You can also add the list of profiles for which whom you want to run this validation in the OR condition as seen below.
 
AND( 
OR( 
ISNEW(), 
ISCHANGED(UnitPrice)
), 
UnitPrice <> ListPrice,
OR(
$Profile.Name = "Profile Name here",
$Profile.Name = "Profile Name here"
)
)

Hope that helps !

Kindly mark it as an answer if that works for you !
Behzad Bahadori 18Behzad Bahadori 18
Hi Akhil when I do check syntax i get Error: Field ListPrice does not exist. Check spelling. I am doing this in QuoteLineItem object validation rules
Akhil AnilAkhil Anil
Hi Behzad,

Sorry about that. You should be using this formula !
 
AND( 
OR( 
ISNEW(), 
ISCHANGED(UnitPrice)
), 
UnitPrice <>  PricebookEntry.UnitPrice,
OR(
$Profile.Name = "Profile Name here",
$Profile.Name = "Profile Name here"
)
)

 
This was selected as the best answer