Add Reprice Action to Edit Opportunity Page
Add an action in the Edit Opportunity page that salespeople can use to retrieve updated prices.
-
In Application Composer, navigate to
. -
Click the Create icon.
-
In the Opportunity: Create Action or Link page, in the Display Label field, enter
Reprice Opportunity
. As you click away from the Display Label field, the Name field automatically populates with the internal name. -
In the Type field, ensure that Action is selected.
-
In the Script region, click the New icon.
-
In the Create Object Function page, in the Function Name field, enter
RepriceOpty
. -
In the Edit Script region, enter this script:
def revenueItems = ChildRevenue def pricebook = nvl (PriceBook_Obj_c, null) if (pricebook == null) return def priceBookId = pricebook?.getAttribute("PricebookId") def view_PriceBookItem = newView('PriceBookItem') def view_Criteria = newViewCriteria(view_PriceBookItem) def view_criteria_row = view_Criteria.createRow() def view_condition = view_criteria_row.ensureCriteriaItem('InvItemId') view_condition.setOperator('=') view_Criteria.insertRow(view_criteria_row) view_PriceBookItem.appendViewCriteria(view_Criteria) def view_condition_1 = view_criteria_row.ensureCriteriaItem('PricebookId') view_condition_1.setOperator('=') view_condition_1.setValue(priceBookId) while (revenueItems.hasNext()) { def revenueLine = revenueItems.next() def itemid= nvl(revenueLine.InventoryItemId, 0L) def invorgid = nvl (revenueLine.InventoryOrgId, 0L) view_condition.setValue(itemid) //1,400 is the number of records in the system; change this number according to your system records. view_PriceBookItem.setMaxFetchSize(1400) view_PriceBookItem.executeQuery() while(view_PriceBookItem.hasNext()){ def var_Row = view_PriceBookItem.next() //Get the price from PriceBookItem for the item you want: revenueLine.setAttribute('UnitPrice', var_Row.getAttribute('ListPrice'))} }
-
Click Save and Close.
-
Back in the Opportunity: Actions and Links page, click Save.
- Verify the action was created by going to . If you still don't see it, sign out and back in.
-
Add the action to the opportunity details page: Navigate to
. -
Ensure that the Application Pages tab is selected.
-
In the Opportunity: Pages page, find the Details Page Layouts region. Duplicate the standard layout and then name and edit the copy.
-
In the Details Layout page, at the top right of the page next to the Actions drop-down list, click the Edit icon.
-
In the Buttons and Actions page, find the action you created and move it to from the Available Actions shuttle area to the Selected Actions shuttle area.
-
Click Save and Close.
-
Click Done.