Closed ajbollis closed 4 years ago
UI for that is at https://github.com/SalesforceLabs/survey-force/blob/master/src/components/viewShareSurveyComponent.component
Controller for that is at https://github.com/SalesforceLabs/survey-force/blob/master/src/classes/viewShareSurveyComponentController.cls
It runs following SOQL query to get list of sites
Select Name, Status, Subdomain, UrlPathPrefix, SiteType, OptionsRequireHttps from Site where Subdomain != ''
You can try to run that in DevConsole and see what it returns.
`public List < Selectoption > sitesPicklist { get{ sitesPicklist = new List < Selectoption > (); try{ sitesPicklist.add(new Selectoption(getVFUrl(), 'Internal'));
//Site is standard object and there is no CRUD/FLS check for this as it can not be changed
List<Site> siteList = [Select Name, Status, Subdomain, UrlPathPrefix, SiteType, OptionsRequireHttps from Site where Subdomain != ''];
for(Site s: siteList){
String url = (s.OptionsRequireHttps == true)?'https://':'http://';
url += Utilities.getSubdomainPrefix() + s.Subdomain + '.';
url += Utilities.getInstance();
url += (s.OptionsRequireHttps == true && s.SiteType == 'Visualforce')?'secure.force.com/':'force.com/';
url += (String.isEmpty(s.UrlPathPrefix))?'':s.UrlPathPrefix + '/';
url += 'TakeSurvey?';
sitesPicklist.add(new Selectoption(url, s.Name));
}
}catch(Exception e){ System.debug('Exception:' + e.getMessage());
}
return sitesPicklist;
}
set;
}`
Thanks for all of that. I ran the soql query in the devConsole and it did return my sites but they still aren't appearing the in survey component. I will go through the code you supplied to see if I can find out why.
Thank you again for the quick reply.
Ok, Issue is in https://github.com/SalesforceLabs/survey-force/blob/master/src/classes/Utilities.cls Line#16. It works in a dev org but not in sandbox because I get following error:
08:49:51:110 VARIABLE_ASSIGNMENT [73]|e|"common.apex.runtime.impl.ExecutionException: List index out of bounds: -1"|0x36516ddd
I believe issue is the latest CRUC where we don't have instance name in the URL. I'll need to create a new org and enable that CRUC there and test a fix that will work in both scenarios (with and without instance name).
With the CRUC, we now get https://DOMAIN--c.visualforce.com
Rather than https://DOMAIN--c.INSTANCE.visualforce.com
These changes (to Utilities and Utilities_Test classes) fix this issue,
https://github.com/SalesforceLabs/survey-force/commit/17f624b828d3f99912ddf2a4c990753734f55780
https://github.com/SalesforceLabs/survey-force/commit/bc2a69dea25b49fc96abf3b743e746ac49009275
I am setting up survey force in a new sandbox and walked through all of the installation steps found on github. I have a site setup with the correct permissions but it does not appear in the Select Site link when I create a survey with Email Link... sharing options.