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
mahesh1.396434879374128E12mahesh1.396434879374128E12 

Create the Task to Opportunity Owner when the ListPrice in OpportunityLineItem is changed.

When the ListPrice(Field in OpportunityLineItem)  value is changed(Suppose $100 is changed to $150). then create a Task to Opportunity Owner.stating that ListPrice is changed Please review the SalesPrice.


Note: ListPrice value in OpportunityLineItem is changed only when we change the value  PriceBookEntry.
Vinit_KumarVinit_Kumar
You can create an update Trigger on OpportunityLineItem to check if the ListPrice has been changed (Query the related PriceBookEntry value and see if that has changed or not),

If it has changed Create a Task and assign it to Opportunity Owner.

Hope this helps !!

If this helps,please mark it as best answer to help others.
mahesh1.396434879374128E12mahesh1.396434879374128E12
I am comparing the OldOppLineItem(ListPrice) and NewOppLine(ListPrice) But i am not getting any values in the System.Debug statement.
Can you Please help me in this issue.
can we use the Ischange Option which is their WorkFlow in apex.
Vinit_KumarVinit_Kumar
Can you post your code as how you are comparin old and new values ??
mahesh1.396434879374128E12mahesh1.396434879374128E12
trigger CreateTaskonOpp on OpportunityLineItem(after update)
{

    for(OpportunityLineItem  Oli : Trigger.new)
        {
            OpportunityLineItem oldOli = Trigger.oldMap.get(Oli.ID);     
            System.debug('***********Old List price********'+oldOli.ListPrice);
           
            System.debug('*********New List price*********'+Oli.ListPrice); 

        // After getting the Old values and New values, I want to Compare with these values(Old and New) 

             If(oldOli != Oli){
        //Create the Task
               }

          }
Vinit_KumarVinit_Kumar
Ohk just checked List Price is coming from Pricebookentry and PricebookEntry object is not triggerable as of now in salesforce.Below is an Idea for the same :-

https://success.salesforce.com/ideaView?id=08730000000XnicAAC

You should try checking for Sales Price field on OpportunityLineItem object in salesforce or Total Price which ever suits your scenario.

Hope this helps !!

mahesh1.396434879374128E12mahesh1.396434879374128E12
Thanks for your valuable answer Vinit...

My actual bussiness requirement is when the listprice in opportunitylineItem is changed then the task should be created to the Opportunity associated to that OpportunitylineItem.

Task description: Listprice is changed please review the SalesPrice.

As i told you in my first post only 

listprice value is changed only when we change the value in PriceBookEntry.


If you get any idea related to this.....

Please help me in this issue.........
Vinit_KumarVinit_Kumar
Ok got it,the way I would approach is to check whether ListPrice and Unitprice is same or not,if it is not then create a Task for Owner.so,you shold be targeting soemthing like below :-

trigger CreateTaskonOpp on OpportunityLineItem(after update)
{

    for(OpportunityLineItem  Oli : Trigger.new)
        {
			if(Oli.ListPrice!=Oli.UnitPrice)
			{
				        //Create the Task
			}
		}
}
If this helps,please mark it as best answer to help others :)

mahesh1.396434879374128E12mahesh1.396434879374128E12
This wont work. (Because the ListPrice and UnitPrice are independent to their behaviour......unitprice wont effect when we change the Listprice value)

When the ListPrice is changed,create the task to the opportunity owner.

Task description: Listprice is changed please review the SalesPrice.

Then opportunity owner should change the salesPrice(Unitprice in OpportunityLineItems) manually.
Vinit_KumarVinit_Kumar
See SalesPrice API name is Unit Price,

If I understood correctly,our goal is to check if the Sales price and List Price is different or not If it is then create a Task for the Opp owner and thats what I suggested you.

Hope this helps!!
mahesh1.396434879374128E12mahesh1.396434879374128E12
Our goal is not to check the salesprice and listprice...

Our goal is to Check the Old values and New values of the ListPrice in OppotyunityLineItem,If it is different then create task to Opportunity Owner.