Friday, September 16, 2011

Migrating Opportunity line item

This post is a continuation of my earlier post on Product, Pricebook and Pricebook entry.Opportunity Product(line item) is a junction object between opportunity and pricebookentry table.

List of fields in opportunity products
  • ID
  • OPPORTUNITYID
  • PRICEBOOKENTRYID
  • CURRENCYISOCODE
  • QUANTITY
  • TOTALPRICE
  • UNITPRICE
  • LISTPRICE
  • SERVICEDATE
  • DESCRIPTION
Fields indicated in red are mandatory fields and fields which are in grey are read only. Unit price field specifies the price at which the product was sold. List price is the price of the product in the pricebook. use either one of the totalprice or unitprice field while loading.The other field will be automatically calculated based on quantity while loading. Refer to my previous post for inserting a new pricebook entry/ Exporting existing pricebookentry. Prepare a csv file with all these data.Also optional fields like service date and description can be filled for CSV. Use data loader to insert data. Click here for Sample CSV

Notes on loading

  • pricebook entry should be in the same pricebook that is assigned to the opportunity.  The pricebook name can be found in pricebook2id field in opportunity
  • If the opportunity does not have an associated pricebook2, the API automatically sets the pricebook on the opportunity if the line item corresponds to a Pricebookentry in an active Pricebook2. Changing the pricebook association would delete existing opportunity line items.
  • Creating an OpportunityLineItem increments the OpportunityAmount value by the TotalPrice of the OpportunityLineItem. Additionally, inserting an OpportunityLineItem increments the ExpectedRevenue on the opportunity by the TotalPrice times the opportunity Probability.
  • The OpportunityAmount becomes a read-only field when the opportunity has line items.
  • If multi-Currency is enable for your organization, Choose a price book that contains products with the same currency as the opportunity. pricebook entry currency code should match opportunity currency code.You cannot update the CurrencyIsoCode field on the opportunity if line items exist.

Thursday, September 8, 2011

Escalation Queues and workflows.

I recently had a need to escalate a case which has status value new and in a queue for 2 hours, So that if nobody picks up the case it would be escalated to manager.

It took me about a day to figure out how to write the entry criteria to check whether the case is in a queue or assigned to a owner. salesforce Ids has a certain pattern across all org for certain objects. so by that i figured out that users always started with 005 and group and queue always started with 00G.

Also i had to use 'Formula evaluates to true'  instead of easy 'Criterias are met' as owner ids are not available in this. Here is the formula i used.

AND(  ISPICKVAL( Status ,"New") , BEGINS(OwnerId, "00G") ,not( IsClosed ) )  

 Now coming to other stuffs
  
Realized that Case Escalation cannot trigger a workflow. Case escalation would cause an 'isEscalated' flag to be checked. I assumed that it can be used to trigger a workflow. i used the same entry criteria in workflow as in the escalation rule and used time dependent action instead. Thankfully my use case needed field updates only for the first time the case is escalated.


Couple of more things changes to formulae field would not trigger the workflow and so also field update from a workflow. This link might be useful Workflow considerations

If you could find if salesforce has documented somewhere which all will trigger a workflow, Let me know