You need to sign in to do that
Don't have an account?
Ana K. Bertuzzi
I need to create an url with a dynamic instance
Hi,
I had an apex class that works if I write the instance I'm running. But if I try to change it to a "dynamic" instance, meaning that it detects the instance I'm logged in, I'm getting a "null"
I found a piece of code and I tried to make it work here, not sure what I'm doing wrong (cause I actually have no idea of coding). Please help!
I wonder if has anything to do with using both PageRefence and gerSalesforceBaseUrl in the same class.
Thank you!!
I had an apex class that works if I write the instance I'm running. But if I try to change it to a "dynamic" instance, meaning that it detects the instance I'm logged in, I'm getting a "null"
I found a piece of code and I tried to make it work here, not sure what I'm doing wrong (cause I actually have no idea of coding). Please help!
I wonder if has anything to do with using both PageRefence and gerSalesforceBaseUrl in the same class.
Thank you!!
public class MyflowController { public Flow.Interview.Tickets Myflow {get; set;} public PageReference getLinkID() { String U1 = 'https://'; String U2 = '.salesforce.com/a1G/e?retURL=%2Fa1G%2Fo&RecordType='; String U3 = '&ent=02I400000013Z1q'; PageReference p = new PageReference (U1+Instance+U2+RTid()+U3); p.setRedirect(true); return p; } public String RTid() { if (Myflow==null) return ''; else return Myflow.varRecordType; } private String Instance = null; private void GetURL(){ Instance = GetInstance(Instance); } public String GetInstance(String Instance) { if (Instance == null) { List<String> parts = System.URL.getSalesforceBaseUrl().getHost().replace('-api','').split('\\.'); if (parts.size() == 3) Instance = parts[0]; else if (parts.size() == 5) Instance = parts[1]; else Instance = null; } return Instance; } }
Best Answer chosen by Ana K. Bertuzzi
Ana K. Bertuzzi
I was able to make it work, here's the code:
Anyway, now I'm supposed to create a test for it. If anyone knows an easy way to do it... I would appreciate it!