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
Marit HendriksenMarit Hendriksen 

Apex URL output

I have created a custom field, Product_URL for my opportunities. I would like this URL in generated quotes, but with a different link text. 
I've been working on the template, but I can't seem to get this link in the template. So what I want is "View Product" to link to the predefined product URL, in the quote.

What I tried so far:
<apex:outputLink value="{!line.Product_URL}">View Product</apex:outputLink>

However, this doesn't seem to work. I've also tried working with a href, but still no result. Anyone know how to solve this?
 
Best Answer chosen by Marit Hendriksen
Shashi PatowaryShashi Patowary
Hi Marit,

Got your problem. Please try this way -

In the Custom URL field set the full url link as 'http://vanvliet.com/trucks'

And you can use any of the these line of code in VF page -

    <apex:outputLink target="_blank" value="{!Contact.ProductURL__c}">View Product 1</apex:outputLink><br/>
    <a target="_blank" style="text-decoration:none" href="{!Contact.ProductURL__c}">View Product 2</a>

Please refer to the screenshot -
User-added image

Please let me know if this is helpful.

Regards,
Shashi

All Answers

Shashi PatowaryShashi Patowary
Hi Marit,

How are you populating this Product_URL field ? If you are setting a value like below, it should be working fine.

https://na1.salesforce.com/0Q090000000c7iQ

Please let me know if this is helpful.

Regards,
Shashi
Marit HendriksenMarit Hendriksen
Hello Shashi,

Thank you for your quick response. I can't see what type of value you mean though, because I can't access your link..

Regards, Marit
Shashi PatowaryShashi Patowary
Hi Marit,

That was an example URL.What I meant was that you can set the full URL to your quote record in the Product_URL field. You can access that url in VF page like the same way -

<apex:outputLink value="{!line.Product_URL}">View Product</apex:outputLink>

Please let me know if this is helpful.

Regards,
Shashi
Marit HendriksenMarit Hendriksen
Hi Shashi,

I'm not sure what you mean. The URL als specified in the Product_URL field differs for each product, so that still wouldn't work right?

What I'd like to do is this:

Product: Truck
Product URL: http://vanvliet.com/trucks

Product: Truck2
Product URL: http://vanvliet.com/truck2

Then, in my quote, I'd like 

Product Truck - Qt. 2 - URL to product (http://vanvliet.com/trucks)
Product Truck2 - Qt. 5 - URL to product (http://vanvliet.com/truck2)

Do you get what I mean? the Product__URL field refers to an external link, not something in SF and is unique for every produc
Marit HendriksenMarit Hendriksen
I've been able to fix the problem, it should have been:
<td><apex:outputlink title="Product URL" value="/{!line.Product_URL__c}">Product URL</apex:outputlink>

However, as I mentioned, the URL should be to a link outside of Salesforce. However, it keeps taking me to: cs80.salesforce.com/URL-HERE. Which obviously doesn't work. Does anyone have a solution to this?
 
Shashi PatowaryShashi Patowary
Hi Marit,

Got your problem. Please try this way -

In the Custom URL field set the full url link as 'http://vanvliet.com/trucks'

And you can use any of the these line of code in VF page -

    <apex:outputLink target="_blank" value="{!Contact.ProductURL__c}">View Product 1</apex:outputLink><br/>
    <a target="_blank" style="text-decoration:none" href="{!Contact.ProductURL__c}">View Product 2</a>

Please refer to the screenshot -
User-added image

Please let me know if this is helpful.

Regards,
Shashi
This was selected as the best answer
Marit HendriksenMarit Hendriksen
Hi Shashi,

That did the trick! Thank you! :)