You need to sign in to do that
Don't have an account?

how to simulate the link field in an object using PageReference
Hi
I am using visualforce and custom controller to try and extract and save information from a custom object (call it FSL) and then automatically store certain information from an FSL entry into various fields in the Case object.
So the FSL custom object would contain fields like Account and Contact that are lookups to Account and Contact entries, as well as containing other info.
And the goal is then to automatically create a Case entry that will then use the same Account Name, Contact Name, and other info from the FSL object.
So somewhere in my Class code, I would do something like:
Case c = new Case();
c.AccountID = FSL.Account;
c.ContactID=FSL.Contact;
And one of the things that I do want to store in the Case's Description field would be a reference to how to access the FSL entry in salesforce (i.e. something like https://na0.salesforce.com/5000R00000zf)
I know that when I am writing custom button or link and I select Content Sounrce to be URL, I can extract from the
Insert fields of the custom object FSL the Detailed Link field (!FSL.Link}
But in my visualforce class, if I try to access that, it tells me that it is an invalid field Link for Sobject FSL.
That is, I can't do something like this:
c.Description='This case is based on a specific custom object FSL entry. To access it, please click on this link '+FSL.Link;
So the only way I can think of to somehow store that info in the Description field is to somehow use the PageReference
function.
In the class, we have methods like this:
public PageReference Save() {
PageReference FSLpage = new PageReference('/' +FSL.id);
.
.
}
and so the PageReferenceFSLpage is storing this info. But how to get this info to be extracted/converted into a string value so that in my code, that I can't seem to get it working properly.
If I put in something like this in the code above:
PageReference FSLpage = new PageReference('/' +FSL.id);
String FSL_Link = FSLpage.getURL;
c.Description = 'This case is based on a specific custom object FSL entry. To access it, please click on this link '+FSL_Link;
Then what happens is that the FSL_Link will only provide just the id, and not the full url path. So the Description would contain:
This case is based on a specific custom object FSL entry. To access it, please click on this link 5000R00000zf
instead of:
This case is based on a specific custom object FSL entry. To access it, please click on this link https://na0.salesforce.com/5000R00000zf
Can someone show me how to get the complete url?
thx in advance
I am using visualforce and custom controller to try and extract and save information from a custom object (call it FSL) and then automatically store certain information from an FSL entry into various fields in the Case object.
So the FSL custom object would contain fields like Account and Contact that are lookups to Account and Contact entries, as well as containing other info.
And the goal is then to automatically create a Case entry that will then use the same Account Name, Contact Name, and other info from the FSL object.
So somewhere in my Class code, I would do something like:
Case c = new Case();
c.AccountID = FSL.Account;
c.ContactID=FSL.Contact;
And one of the things that I do want to store in the Case's Description field would be a reference to how to access the FSL entry in salesforce (i.e. something like https://na0.salesforce.com/5000R00000zf)
I know that when I am writing custom button or link and I select Content Sounrce to be URL, I can extract from the
Insert fields of the custom object FSL the Detailed Link field (!FSL.Link}
But in my visualforce class, if I try to access that, it tells me that it is an invalid field Link for Sobject FSL.
That is, I can't do something like this:
c.Description='This case is based on a specific custom object FSL entry. To access it, please click on this link '+FSL.Link;
So the only way I can think of to somehow store that info in the Description field is to somehow use the PageReference
function.
In the class, we have methods like this:
public PageReference Save() {
PageReference FSLpage = new PageReference('/' +FSL.id);
.
.
}
and so the PageReferenceFSLpage is storing this info. But how to get this info to be extracted/converted into a string value so that in my code, that I can't seem to get it working properly.
If I put in something like this in the code above:
PageReference FSLpage = new PageReference('/' +FSL.id);
String FSL_Link = FSLpage.getURL;
c.Description = 'This case is based on a specific custom object FSL entry. To access it, please click on this link '+FSL_Link;
Then what happens is that the FSL_Link will only provide just the id, and not the full url path. So the Description would contain:
This case is based on a specific custom object FSL entry. To access it, please click on this link 5000R00000zf
instead of:
This case is based on a specific custom object FSL entry. To access it, please click on this link https://na0.salesforce.com/5000R00000zf
Can someone show me how to get the complete url?
thx in advance
...Or make the <a> link relative to the current path - if you are on an /apex/page, use href="../" + theID
Message Edited by EricVlach on 01-08-2009 05:33 PM
There must be a way to extract out from either PageReference or some other function/API in visualforce or apex that will return what the full URL is of the organization, no?