-
ChatterFeed
-
0Best Answers
-
0Likes Received
-
0Likes Given
-
10Questions
-
9Replies
Opportunity sharing via Sales Team
There's a need for us to share certain opportunities based on Region (custom field from Account). Right now, the opportunity owner either has to add the users one at a time via Sales Team, or create a default Sales Team and add them.
But there are times we also need to switch the Opportunity owner out. As soon as we change the Opportunity owner, the default sales team from the previous owner is removed from the Opportunity. And now the new owner has to add the members.
How are other people doing this? We cannot do a sharing based on role, users etc. coz' we only want this behavior based on Region. If it is from Region A, then we want a selective set of users to have full rights to those opportunities.
Thanks.
- jlim
- October 26, 2009
- Like
- 0
- Continue reading or reply
Perl - pricebook detail from Standard pricebook coming up empty
Using the Perl API, if I'm querying from an opportunity line item that is referencing the "Standard" pricebook, I'm not getting any details from the pricebookentry. The same query, if pass an id that contains item from our customized "Software" pricebook, will return the pricebookentry details (such as product code, countryisocode etc.)
Can someone who is using Perl API give it a try and report back if you are experiencing the same issue?
I'm using this version of the Perl API: WWW-Salesforce-0.11
http://search.cpan.org/dist/WWW-Salesforce/
I've tried the following versions:
https://www.salesforce.com/services/Soap/c/13.0';
https://www.salesforce.com/services/Soap/c/16.0';
https://www.salesforce.com/services/Soap/u/13.0';
https://www.salesforce.com/services/Soap/u/16.0';
This is the partial SOAP XML responses:
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Header> <sforce:QueryOptions xmlns:sforce="urn:partner.soap.sforce.com"> <batchSize xsi:type="xsd:int">500</batchSize> </sforce:QueryOptions> <sforce:SessionHeader xmlns:sforce="urn:partner.soap.sforce.com"> <sessionId xsi:type="xsd:string">xxxx</sessionId> </sforce:SessionHeader> </soap:Header> <soap:Body> <query xmlns="urn:partner.soap.sforce.com"> <queryString xsi:type="xsd:string"> SELECT oli.Product_Class__c, oli.Product_Type__c, oli.PricebookEntry.ProductCode FROM OpportunityLineItem oli WHERE oli.OpportunityId='xxxx' </queryString> </query> </soap:Body> </soap:Envelope>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns="urn:partner.soap.sforce.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:sf="urn:sobject.partner.soap.sforce.com"> <soapenv:Body> <queryResponse> <result xsi:type="QueryResult"> <done>true</done> <queryLocator xsi:nil="true"/> <records xsi:type="sf:sObject"> <sf:type>OpportunityLineItem</sf:type> <sf:Id xsi:nil="true"/> <sf:Product_Class__c>Lease</sf:Product_Class__c> <sf:Product_Type__c>New Product</sf:Product_Type__c> <sf:PricebookEntry xsi:nil="true"/> </records> <records xsi:type="sf:sObject"> <sf:type>OpportunityLineItem</sf:type> <sf:Id xsi:nil="true"/> <sf:Product_Class__c>Lease</sf:Product_Class__c> <sf:Product_Type__c>New Product</sf:Product_Type__c> <sf:PricebookEntry xsi:nil="true"/> </records> <size>2</size> </result> </queryResponse> </soapenv:Body> </soapenv:Envelope>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns="urn:partner.soap.sforce.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:sf="urn:sobject.partner.soap.sforce.com"> <soapenv:Body> <queryResponse> <result xsi:type="QueryResult"> <done>true</done> <queryLocator xsi:nil="true"/> <records xsi:type="sf:sObject"> <sf:type>OpportunityLineItem</sf:type> <sf:Id xsi:nil="true"/> <sf:Product_Class__c>Maintenance</sf:Product_Class__c> <sf:Product_Type__c>Renewal</sf:Product_Type__c> <sf:PricebookEntry xsi:type="sf:sObject"> <sf:type>PricebookEntry</sf:type> <sf:Id xsi:nil="true"/> <sf:ProductCode>GWU-FLT-MNT</sf:ProductCode> </sf:PricebookEntry> </records> <size>1</size> </result> </queryResponse> </soapenv:Body> </soapenv:Envelope>
- jlim
- September 24, 2009
- Like
- 0
- Continue reading or reply
Question: Is it possible to update field when viewing record using VF?
On the Opportunity Line item view page, I've a custom List_Price__c field. I want to set up a VF page that does the following:
1. If List_Price__c is null then populate with Pricebook ListPrice
2. If List_Price__c is not null, then check if Opportunity contains the word "Closed". If it does, then leave it alone. If not, update it with the Pricebook ListPrice.
I've setup a workflow that will do this, but only if the record is edited or created. Since we have existing records that existed before the workflow, List_Price__c could be null. I could export all the Opportunity Line Item IDs and mass populate this field, but I would like to know how to do this with a VF page.
I've tried with a formula, but a formula cannot refer to itself.
Also, can I update the List_Price__c directly using VF, or do I need to write the corresponding Apex code? Or do I have to actually simulate a quick save which then triggers the workflow rule?
Thanks.
- jlim
- September 09, 2009
- Like
- 0
- Continue reading or reply
How to fix -- Formula cannot use another formula field that directly or indirectly refers to itself
We have an issue where we update our pricebook once a year, but we do not want to maintain multiple pricebooks. The problem is when we update the list price, Salesforce goes thru all our opportunities and updates all the List Price. The problem is we already have a trigger that calculates discount and sale price based on List Price. So, once the List Price is updated, unless the user edits the existing opportunity line items, the discount and sale price calculation is incorrect.
However, we only want the re-calc to be performed for any open Opportunities and ignore closed ones. So, we created a custom List Price field and I set the formula to be equals to List Price if null, or if not null, then set it to List Price if stage is not "Closed xxx". Otherwise, I want it to be set back to itself or not changed.
However, if I do:
IF(
ISNULL(List_Price__c), ListPrice,
IF(
CONTAINS(TEXT(Opportunity.StageName),"Closed"), List_Price__c,
ListPrice
)
)
I'm getting the "Formula cannot use another formula field that directly or indirectly refers to itself".
I also tried setting up List_Price__c as just a currency field and use workflow rules to populate the value. This works, except for existing records it is null, unless I edit and save any part of the opportunity line item. If I set it as formula (say a simple List_Price__c = ListPrice), then by virtue of viewing the Opportunity Line Item, the List_Price__c value is populated.
I guess I could do a mass update of all the existing Opportunity line items on the backend and then use the workflow rule from now on, but since I'm learning how best to maximize Salesforce functionality, I'm wondering if anyone knows of a way to solve this formula issue?
In any programming language, I can just do the following:
List_Price__c = List_Price__c == null ? ListPrice : List_Price__c
Thanks.
- jlim
- September 08, 2009
- Like
- 0
- Continue reading or reply
Question: SOQL how to join Opportunity Close Date with Dated Conversion Rate?
I would like to accomplish this in 1 query. Is it possible? When selecting the Opportunity, I have the CloseDate and I would like to use this CloseDate and lookup in the DatedConversionRate table and get the exchange rate.
Thanks.
- jlim
- September 02, 2009
- Like
- 0
- Continue reading or reply
How to return to previous page if validation fails?
On the Opportunity page, I've a VF page which generates a selection list based on some criteria and a button to submit based on a similar criteria (both select list will be enabled or disabled as well).
Now when they submit the form, my Apex code is as follow:
public PageReference createOrderSFA() { String newPageUrl = SFAURL+'?sfdcid='+oppor.Id+'&sfdcsubregion='+selectedRegion; PageReference newPage = new PageReference(newPageUrl); newPage.setRedirect(true); return newPage; }
But I want to check if selectedRegion is null, I want to cancel the submit and stay on the current page (the Opportunity page).
How do I do it?
I tried returning null upon checking for selectedRegion, but it loads the VF page instead.
Also, how to I reference an element (SFA_item) on the VF page?
<apex:page id="SFA_page" standardController="Opportunity" extensions="SfaOrderExtension"> <apex:form id="SFA_form" target="SFAWINDOW"> <apex:selectList id="SFA_item" disabled="{!selectListState}" value="{!subRegions}" size="1" multiselect="false" styleClass="opporSubregionStyle"> <apex:selectOptions value="{!items}" /> </apex:selectList> <apex:commandButton value="Create Order" action="{!createOrderSFA}" disabled="{!buttonState}" onclick="return checkOrderEntered()" /> </apex:form> </apex:page>
Based on this,
http://developinthecloud.wordpress.com/2009/06/17/visualforce-component-ids-javascript/
I tried:
var theItem = document.getElementById('{!$Component.SFA_item}');
but it is actually (empty). I'm using document.getElementById('SFA_page:SFA_form:SFA_item') now, but would like to know the proper method.
Thanks.
- jlim
- August 17, 2009
- Like
- 0
- Continue reading or reply
Precision in calculation of sales price, list price and discount
Hi,
Can someone explain how to solve this? On the opportunity line item level, there are 2 standard fields called "List Price" and "Sales Price" defined as Currency(16,2). We have a custom field called Discount__c defined as Percent(12,6).
We have a trigger that will calculate Sales Price or Discount depending on which is changed. The following example shows the results obtained on the sandbox environment.
List Price = 4.75
Discount = 50%
results in Sales Price of 2.38 (Displayed) or 2.375 (stored)
List Price = 4.75
Sales Price = 2.375 (entered)
upon saving,
Sales Price = 2.38 (displayed and stored) and Discount = 49.894737%
My question is, if Sales Price is already defined as 16,2 why is the value stored with 3 decimal (2.375)? Ideally we'll need 3 or more precision.
Thank you.
EDIT:
This is really weird and causing our trigger to not work as expected. In our trigger, we compare the old Sales Price and Discount in a loop and depending on what changed, we calculate either new Sales Price or Discount.
The IF statement:
>> if(Trigger.oldMap.get(oli.id).UnitPrice != oli.UnitPrice && Trigger.oldMap.get(oli.id).Discount__c == oli.Discount__c) {
What happens is if I change the Sales Price (Unit Price) once, then it calculates a new discount. Now, if I change the Sales Price again without changing the discount values, it thinks the discount is not the same this time around and goes to another loop that calculates Sales Price. I printed out the old and new values the second time and I'm seeing 14 number precision on the old discount as opposed to the set 6 precision.
An example of a calculate discount is below:
>> 57.89473684210527 57.894737
The weirdest part is if I enter 2 then 3 the second time for sales price, I'm seeing 2 and 3 when I print out the variables on another dummy field. But the actual Sales Price field is still showing 2 in the GUI.
What's going on??
- jlim
- August 06, 2009
- Like
- 0
- Continue reading or reply
Picklist dependency question between Account and Opportunity
Under Account, I have a custom picklist called Region__c.
Under Opportunity, I have a custom picklist called Sub_Region__c.
I want to be able to setup Opportunity.Sub_Region__c picklist to be dependent on the value picked on Account.Region__c.
Using the UI, it appears there's no apparent way for me to set up the dependency. If Sub_Region__c is part of Account, then it is possible. But that's not what we want.
Can this be done using the UI, or do I need to write a VF page to accomplish this? Thanks.
- jlim
- August 04, 2009
- Like
- 0
- Continue reading or reply
Help with writing simple unit test
I'm really new in this and would appreciate any pointers. I read through examples but still not sure how to proceed. TIA.
/*** Controller ***/
public class MyControllerExtension {
private final Opportunity oppor;
public myControllerExtension (ApexPages.StandardController stdController) {
Id id = ApexPages.currentPage().getParameters().get('Id');
oppor = (id == null) ? new Opportunity() :
[
SELECT Id, StageName, Account_Region__c
FROM Opportunity
WHERE Id = :id
];
}
public Opportunity getOpportunity() {
return oppor;
}
public String getButtonState() {
if(oppor.Account_Region__c == 'UK') {
if(oppor.StageName == 'Closed Won') {
return 'False';
} else {
return 'True';
}
} else {
return 'True';
}
}
}
/*** TEST ***/
@isTest
private class TestMyControllerExtension {
static testMethod void TestMyControllerExtension() {
ApexPages.StandardController stdController;
MyControllerExtension mce = new MyControllerExtension(stdController);
Opportunity oppor = mce.getOpportunity();
oppor.StageName = 'Closed Won';
oppor.Account.Region__c = 'UK';
System.assertEquals(mce.getButtonState(),'False');
}
}
- jlim
- July 27, 2009
- Like
- 0
- Continue reading or reply
How to display visualforce page as a custom button?
A custom button is laid out on the same level as the standard buttons in our Opportunity detail page, top and bottom. I've a VF page that creates a commandButton that does different things depending on the Opportunity specifics.
I would like this VF page to appear at the same level as the standard/custom buttons at the top and bottom of the detail. How do I do it?
Right now the only place I can put it is in the detail itself as a field and I cannot "re-use" this VF button more than once on the same page.
Thanks.
- jlim
- July 24, 2009
- Like
- 0
- Continue reading or reply
How to fix -- Formula cannot use another formula field that directly or indirectly refers to itself
We have an issue where we update our pricebook once a year, but we do not want to maintain multiple pricebooks. The problem is when we update the list price, Salesforce goes thru all our opportunities and updates all the List Price. The problem is we already have a trigger that calculates discount and sale price based on List Price. So, once the List Price is updated, unless the user edits the existing opportunity line items, the discount and sale price calculation is incorrect.
However, we only want the re-calc to be performed for any open Opportunities and ignore closed ones. So, we created a custom List Price field and I set the formula to be equals to List Price if null, or if not null, then set it to List Price if stage is not "Closed xxx". Otherwise, I want it to be set back to itself or not changed.
However, if I do:
IF(
ISNULL(List_Price__c), ListPrice,
IF(
CONTAINS(TEXT(Opportunity.StageName),"Closed"), List_Price__c,
ListPrice
)
)
I'm getting the "Formula cannot use another formula field that directly or indirectly refers to itself".
I also tried setting up List_Price__c as just a currency field and use workflow rules to populate the value. This works, except for existing records it is null, unless I edit and save any part of the opportunity line item. If I set it as formula (say a simple List_Price__c = ListPrice), then by virtue of viewing the Opportunity Line Item, the List_Price__c value is populated.
I guess I could do a mass update of all the existing Opportunity line items on the backend and then use the workflow rule from now on, but since I'm learning how best to maximize Salesforce functionality, I'm wondering if anyone knows of a way to solve this formula issue?
In any programming language, I can just do the following:
List_Price__c = List_Price__c == null ? ListPrice : List_Price__c
Thanks.
- jlim
- September 08, 2009
- Like
- 0
- Continue reading or reply
Precision in calculation of sales price, list price and discount
Hi,
Can someone explain how to solve this? On the opportunity line item level, there are 2 standard fields called "List Price" and "Sales Price" defined as Currency(16,2). We have a custom field called Discount__c defined as Percent(12,6).
We have a trigger that will calculate Sales Price or Discount depending on which is changed. The following example shows the results obtained on the sandbox environment.
List Price = 4.75
Discount = 50%
results in Sales Price of 2.38 (Displayed) or 2.375 (stored)
List Price = 4.75
Sales Price = 2.375 (entered)
upon saving,
Sales Price = 2.38 (displayed and stored) and Discount = 49.894737%
My question is, if Sales Price is already defined as 16,2 why is the value stored with 3 decimal (2.375)? Ideally we'll need 3 or more precision.
Thank you.
EDIT:
This is really weird and causing our trigger to not work as expected. In our trigger, we compare the old Sales Price and Discount in a loop and depending on what changed, we calculate either new Sales Price or Discount.
The IF statement:
>> if(Trigger.oldMap.get(oli.id).UnitPrice != oli.UnitPrice && Trigger.oldMap.get(oli.id).Discount__c == oli.Discount__c) {
What happens is if I change the Sales Price (Unit Price) once, then it calculates a new discount. Now, if I change the Sales Price again without changing the discount values, it thinks the discount is not the same this time around and goes to another loop that calculates Sales Price. I printed out the old and new values the second time and I'm seeing 14 number precision on the old discount as opposed to the set 6 precision.
An example of a calculate discount is below:
>> 57.89473684210527 57.894737
The weirdest part is if I enter 2 then 3 the second time for sales price, I'm seeing 2 and 3 when I print out the variables on another dummy field. But the actual Sales Price field is still showing 2 in the GUI.
What's going on??
- jlim
- August 06, 2009
- Like
- 0
- Continue reading or reply
Picklist dependency question between Account and Opportunity
Under Account, I have a custom picklist called Region__c.
Under Opportunity, I have a custom picklist called Sub_Region__c.
I want to be able to setup Opportunity.Sub_Region__c picklist to be dependent on the value picked on Account.Region__c.
Using the UI, it appears there's no apparent way for me to set up the dependency. If Sub_Region__c is part of Account, then it is possible. But that's not what we want.
Can this be done using the UI, or do I need to write a VF page to accomplish this? Thanks.
- jlim
- August 04, 2009
- Like
- 0
- Continue reading or reply
Help with writing simple unit test
I'm really new in this and would appreciate any pointers. I read through examples but still not sure how to proceed. TIA.
/*** Controller ***/
public class MyControllerExtension {
private final Opportunity oppor;
public myControllerExtension (ApexPages.StandardController stdController) {
Id id = ApexPages.currentPage().getParameters().get('Id');
oppor = (id == null) ? new Opportunity() :
[
SELECT Id, StageName, Account_Region__c
FROM Opportunity
WHERE Id = :id
];
}
public Opportunity getOpportunity() {
return oppor;
}
public String getButtonState() {
if(oppor.Account_Region__c == 'UK') {
if(oppor.StageName == 'Closed Won') {
return 'False';
} else {
return 'True';
}
} else {
return 'True';
}
}
}
/*** TEST ***/
@isTest
private class TestMyControllerExtension {
static testMethod void TestMyControllerExtension() {
ApexPages.StandardController stdController;
MyControllerExtension mce = new MyControllerExtension(stdController);
Opportunity oppor = mce.getOpportunity();
oppor.StageName = 'Closed Won';
oppor.Account.Region__c = 'UK';
System.assertEquals(mce.getButtonState(),'False');
}
}
- jlim
- July 27, 2009
- Like
- 0
- Continue reading or reply
How to display visualforce page as a custom button?
A custom button is laid out on the same level as the standard buttons in our Opportunity detail page, top and bottom. I've a VF page that creates a commandButton that does different things depending on the Opportunity specifics.
I would like this VF page to appear at the same level as the standard/custom buttons at the top and bottom of the detail. How do I do it?
Right now the only place I can put it is in the detail itself as a field and I cannot "re-use" this VF button more than once on the same page.
Thanks.
- jlim
- July 24, 2009
- Like
- 0
- Continue reading or reply
Discrepancy between OpportunityLineItem ListPrice values
Hello All,
I have an OpportunityLineItem (oli) before insert trigger that references the oli.ListPrice value. The trigger works great in my sandbox when manually testing through the UI but is failing due to a null value for oli.ListPrice un unit testing.
I have verified that the issue is specifically that the oli.ListPrice value is null when adding the oli through the unit test code, but the ListPrice is not null when adding an oli through the UI.
Naturally, I suspected the unit test code had an issue with the PriceBook and PriceBookEntry process. But after scouring the code, the Apex Code Language Reference section "Testing the Sample Application", and the developer boards, I'm not seeing anything that explains why the oli.ListPrice value would be null in the unit test.
The behavior seems like the assignment of the oli.ListPrice from the pbe.UnitPrice isn't happening in the correct sequence when the unit test is running but is occurring correctly when the UI is used.
Here is the unit test code that is resulting in a null oli.ListPrice when the oli before insert trigger is firing:
public class testTrigger {
static testMethod void testTriggers_Trigger () {
Product2 p = new product2(name='Test Product');
insert p;
Pricebook2 stdPb = [select Id from Pricebook2 where isStandard=true limit 1];
insert new PricebookEntry(pricebook2id = stdPb.id, product2id = p.id, unitprice=100.0, isActive=true);
Pricebook2 pb = new pricebook2(name='test pricebook');
insert pb;
PricebookEntry pbe = new PricebookEntry(pricebook2id=pb.id, product2id=p.id, unitprice=100.0, isActive=true);
insert pbe;
Opportunity o = new Opportunity(name='test', pricebook2id=pb.id, stageName='Open', CloseDate=Date.newInstance(2009,10,10) );
insert o;
OpportunityLineItem oli = new OpportunityLineItem(opportunityid=o.id, UnitPrice=100, quantity=1, pricebookentryid=pbe.Id);
insert oli;
}
}
I hope that you read this post and chuckle as you gently explain the obvious piece that I'm missing. Otherwise, any input is appreciated.
Cheers,
-Philip
- Philip_F
- March 02, 2009
- Like
- 0
- Continue reading or reply