+ Start a Discussion
DahveedDahveed 

URL Hacking for adding products to an opportunity

I'm finding when passing the parameters it fills it out correctly but seems to create almost another value. If I manually go and select the second value then the filter works, otherwise it's not seeing it correctly.  My guess is its something like passing report filters where for the first filter you use pvo.

 

I click my button on the Products related list on an opportunity. The button contains the below url
Ex:
https://cs14.salesforce.com/p/opp/SelectSearch?addTo=006c00000079xsa&PricebookEntrycol0=Product Family&PricebookEntryoper0=contains&PricebookEntryfval0=Consulting&PricebookEntrycol1=Global Product&PricebookEntryoper1=equals&PricebookEntryfval1=false&retURL=%2F006c00000079xsa

Where

PricebookEntrycol0=Product Family
PricebookEntryoper0=contains
PricebookEntryfval0=Consulting

However I get multiple Product Familys and the filter doesn't work. If I manually go select the second "Product Family" in the drop down the filter works. Should I be using different values?

 

Thanks

 

Dahveed

 

 

 

Best Answer chosen by Admin (Salesforce Developers) 
DahveedDahveed

 

For anyone looking for an answer, I found this out at the SF Users group. Props to C-level Management.  

 

Instead of using the full URL use the below string which hooks it to the current opportunity when you select the button

/ui/opportunity/SelectSearch?relatedListId=PricebookEntry&addTo={!Opportunity.Id}

 

The parameters are

srtClmn

srtOrd

The filter fields where 0 is the row

PricebookEntrycol0

PricebookEntryoper0

PricebookEntryfval0

 

PricebookEntrycol1

PricebookEntryoper1

PricebookEntryfval1

 

The catch is you can't set literals except for the PricebookEntryfval field. You must use field name which aren't actually the SF API field names. Ex:

Product Name = PRODUCT.NAME

Product Family = PRODUCT2.FAMILY_ENUM

List Price = PRODUCT.DEFAULT_PRICE

Product Code = PRODUCT.CUSTOMER_PRODUCT_ID

Product Description = PRODUCT2.DESCRIPTION

 

Operators

equals=e  

contains=c

 

I realise salesforce doesn't support this officially however it is common practice. It would be amazing to somehow get a list of all the filter field access names. Could I do a SOQL query on something to get the field filter names?

 

All Answers

DahveedDahveed

 

For anyone looking for an answer, I found this out at the SF Users group. Props to C-level Management.  

 

Instead of using the full URL use the below string which hooks it to the current opportunity when you select the button

/ui/opportunity/SelectSearch?relatedListId=PricebookEntry&addTo={!Opportunity.Id}

 

The parameters are

srtClmn

srtOrd

The filter fields where 0 is the row

PricebookEntrycol0

PricebookEntryoper0

PricebookEntryfval0

 

PricebookEntrycol1

PricebookEntryoper1

PricebookEntryfval1

 

The catch is you can't set literals except for the PricebookEntryfval field. You must use field name which aren't actually the SF API field names. Ex:

Product Name = PRODUCT.NAME

Product Family = PRODUCT2.FAMILY_ENUM

List Price = PRODUCT.DEFAULT_PRICE

Product Code = PRODUCT.CUSTOMER_PRODUCT_ID

Product Description = PRODUCT2.DESCRIPTION

 

Operators

equals=e  

contains=c

 

I realise salesforce doesn't support this officially however it is common practice. It would be amazing to somehow get a list of all the filter field access names. Could I do a SOQL query on something to get the field filter names?

 

This was selected as the best answer
RobLofaroRobLofaro
Two questions on this thread:
1. Is there a paramter to include in the URL to initiate the actual Search?  The above passes the parameters ok, but then the user must press Search - I want to automate that.
2. What is the syntax for srtOrd?  srtOrd=a does not work

Thanks!
GuillermoPGuillermoP
Does anyone have the Operator for Does Not Contain?
GuillermoPGuillermoP
Found it it's k
Jason OrbisonJason Orbison
@robLofaro kind of late, but I found that if you don't use the correct filter name, it won't filter, I found the correct name for product family on this site 

https://sfdc-gyaan.rhcloud.com/tag/product/

This is my final url: 

https://na18.salesforce.com/p/opp/SelectSearch?addTo=0061200000SZYtc&PricebookEntrycol0=PRODUCT2.FAMILY_ENUM&PricebookEntryoper0=k&PricebookEntryfval0=na,svc,accessories,P%20%26%20A

obviously, the ID should be replaced with {!Opportunity.ID}

I was able to add my button and it works like a charm. If you want to use mulitple criteria, you can use the comma, just like a report or list view filter. Works very well. Using a community partner portal and I don't want the external users to choose the wrong product. This helps a lot.

 
Dave DurantDave Durant
> srtClmn
> srtOrd

Any more details on these paramters? I'd love to be able to automatically sort by a column other than the default.. 

Thanks!
Jon-Luke WestJon-Luke West
Late addition, but I identified how to get the underlying system names for each field.

(In Chrome)
Right click one of the field drop downs for filtering and inspect the code using the developer console.  The actual <select> tag contains a list of <option>s that list all of the field values that you can use.  I have copied most of the standard fields below.  Enjoy :)

<option value="">--None--</option>
<option value="PRICEBOOK.NAME">Price Book Name</option>
<option value="PRICEBOOK.ACTIVE">Active (Price Book)</option>
<option value="PRODUCT.NAME">Product Name</option>
<option value="PRODUCT.CUSTOMER_PRODUCT_ID">Product Code</option>
<option value="PRODUCT2.FAMILY_ENUM">Product Family</option>
<option value="PRODUCT.DEFAULT_PRICE">Standard Price</option>
<option value="PB_ENTRY.USE_STANDARD_PRICE">Use Standard Price</option>
<option value="PRODUCT.ACTIVE">Active (Price)</option>
<option value="PRODUCT2.DESCRIPTION">Product Description</option>
<option value="PB_ENTRY.CREATED_DATE">Created Date</option>
<option value="PB_ENTRY.LAST_UPDATE">Last Modified Date</option>
<option value="CREATEDBY_USER.ALIAS">Created By Alias</option>
<option value="UPDATEDBY_USER.ALIAS">Last Update By Alias</option>
<option value="PRODUCT2.ACTIVE">Active (Product)</option>
 
Scott High 7Scott High 7
Is it possible to preset a filter for a custom field?  If so, what is the naming convention.  If I use the actual name of the custom field, it "looks" like it sets the filters up correctly, but when you hit search, it doesn't actually respect the filters.  I think it is filling in the fields with the custom field name, but not actually selecting the filter with the matching name.  If I pull down the list and select the one with the same name and then hit search, it works as expected.
Kid Jansen workKid Jansen work
In addition to the great answer from Dahveed:

You can find the available fields with the dev tools / inspect functionality in your browser, but for custom fields it's very simple: it's just the 15 character Salesforce ID of the field (starting with 00N). You can find this ID through the Tooling API, or by extracting it from the URL by navigating to the field in the setup.
Jesse Miller 10Jesse Miller 10
How would someone go about adding two conditions into this URL string? I need PRODUCT2.FAMILY_ENUM and PRICEBOOK.ACTIVE