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

unable to update custome setting from sites

Ok i give up and need some help....


I have pageRefrenece method that needs to generate a list of strings for the search auto complete to use, based on search params and cache time. (This is all using sites) So when the user goes to search i first check to see if any of the params have changed by comparing them to a saved custom setting that holds the last searched data. If its a new search or one of the params have changed, the method updates the list of strings accordingly and then updates the custom setting with the new search params... this is where it is failing.


As a part of trouble shooting i took the block of code and put it in the Execute Anonymous and ran it with more system.debug lines to see why it might be failing.... but no error this time. In the system logs for the page, when i run it i see the error System.LimitException: DML currently not allowed as shown below:


16:06:07.604 (2914726000)|STATEMENT_EXECUTE|[482]|Try
16:06:07.604 (2914754000)|STATEMENT_EXECUTE|[482]|Block with 2 statements
16:06:07.604 (2914795000)|STATEMENT_EXECUTE|[483]|database.update(SOBJECT:SelfServiceSettings__c)
16:06:07.604 (2915155000)|METHOD_ENTRY|[483]|Database.update(SObject)
16:06:07.604 (2915213000)|HEAP_ALLOCATE|[483]|Bytes:8
16:06:07.604 (2915246000)|DML_BEGIN|[483]|Op:Update|Type:SelfServiceSettings__c|Rows:1
16:06:07.604 (2915291000)|EXCEPTION_THROWN|[483]|System.LimitException: DML currently not allowed
16:06:07.604 (2915384000)|METHOD_EXIT|[483]|Database.update(SObject)
16:06:07.605 (2915453000)|METHOD_EXIT|[493]|SelfServiceTemplateCon.titleSearch()


but when i run the block in the Execute Anonymous the logs dont show the same error:


15:58:57.903 (129162000)|STATEMENT_EXECUTE|[27]|Try
15:58:57.903 (129190000)|STATEMENT_EXECUTE|[27]|Block with 2 statements
15:58:57.903 (129240000)|STATEMENT_EXECUTE|[28]|database.update(SOBJECT:SelfServiceSettings__c)
15:58:57.903 (129275000)|METHOD_ENTRY|[28]|Database.update(SObject)
15:58:57.903 (129344000)|HEAP_ALLOCATE|[28]|Bytes:8
15:58:57.904 (129386000)|DML_BEGIN|[28]|Op:Update|Type:SelfServiceSettings__c|Rows:1
15:58:57.904 (129529000)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:8
15:58:57.930 (156215000)|DML_END|[28]
15:58:57.930 (156272000)|METHOD_EXIT|[28]|Database.update(SObject)
15:58:57.930 (156324000)|STATEMENT_EXECUTE|[29]|system.debug(String)


I thought the issue might be the 'with sharing' i had on the class but it still failed even when i removed that...


here is the code....


string lang = 'en';
string prod = 'lmipro2';
list<string> titleListToShow = new List<string>();
List<string> doctypes = new List<string>();
//normally more than one added to list but for testing lets just deal with one
if(selfservicehelperclass.seeIfNewListIsNeeded(doctypes, lang, prod) || titleListToShow == null){
titleListToShow = selfservicehelperclass.getAllTitleLists(doctypes, lang, prod);
system.debug('\n\n in titleSearch titleListToShow: ' + titleListToShow + '\n\n ');
string dcToSave;
for(string stype: doctypes){
dcToSave = dcToSave + ',' + stype;
dcToSave = stype;
system.debug('\n\n in titleSearch dcToSave: ' + dcToSave + '\n\n ');
SelfServiceSettings__c selfSerSet = SelfServiceSettings__c.getOrgDefaults();
system.debug('\n\n in titleSearch selfSerSet before update: ' + selfSerSet + '\n\n ');
selfSerSet.LastTitleSearch__c =;
selfSerSet.docTypesSearched__c = dcToSave;
system.debug('\n\n in titleSearch sss: ' + selfSerSet + '\n\n ');
}catch(exception e){
system.debug('\n\n in titleSearch e: ' + e + '\n\n ');




I just tried changing the custom setting from a Hierarchy to a list, thinking that maybe the sharing rules wouldnt allow them to update the org defaults of the Hierarchy.... but it still gave the same error...


saving any custom setting for sites that's "per user" won't work.  all sites traffic runs as a single user, so users' actions wouuld conflict with each other.  save that in a cookie instead.  in this scenario, you wouldn't be able to save the titles in a cookie because it's require an extra page load to pick them back up (so would the settings for last searched/updated/etc).


because the title cache is already in a custom setting, there's no big issue in querying this in real time and on any change of params.  no performance hit when you query custom settings vs. custom objects which have a soql performance hit.


i know generating a new list of titles from the cache seems wasteful because the query syntax is the same, but it's really not, if the cache is populate by a separate process (scheduler).