Trying to disable the Customize Application permission so that end users aren't able to customize the platform. The problem is that a visualforce page calls some apex code to export data to XML (business critial/before me) stops working when the permission is disabled. How can I modify the VF or APEX to make it work without the Customize Application permission?
Visualforce Page:
<apex:page controller="ETOExport" contentType="application/xml/#ETO__{!casenum}__{!TODAY()}.xml" cache="false" >
<apex:outputText value="{!xmlstr}"/>
</apex:page>
Apex Code:
public class ETOExport {
public ApexPages.StandardController ctrl;
public Id caseid{ get; set; }
public string xmlstr{ get; set; }
public String casenum{ get; set; }
List<Case> cse = new List<Case>();
public ETOExport() {
xmlstr=CreateXML();
}
public string CreateXML(){
Id id = apexpages.currentpage().getparameters().get('id');
casenum = [Select CaseNumber FROM Case WHERE ID=:id].CaseNumber;
cse = [SELECT CaseNumber, Id, Statement_of_Work_1__c,
(SELECT Quoted_Part_Number__c, Quoted_Part_Description__c, Product_Name_Text__c, Sale_Price_Each__c, Additional_Lead_Time_weeks__c, Weight__c, Install_Hours__c, Minimum_Quantity__c, Paint_Required__c
FROM ETOs__r)
FROM Case
WHERE Id=:id];
Dom.Document doc = new DoM.Document();
xmlstreamwriter x = new xmlstreamwriter();
x.writeStartDocument('UTF-8', '1.0');
x.writeStartElement(null, 'Case', null);
for (Case c : cse) {
//if (c.ETOs__r.size()>0){
x.writeStartElement(null, 'CaseNo', null);
x.writeCharacters(c.CaseNumber);
x.writeEndElement();
x.writeStartElement(null, 'SOW', null);
x.writeCharacters(c.Statement_of_Work_1__c != null ? c.Statement_of_Work_1__c : '');
x.writeEndElement();
for (ETO__c eto: c.ETOs__r) {
x.writeStartElement(null, 'ETO', null);
x.writeStartElement(null, 'PartNo', null);
x.writeCharacters(eto.Quoted_Part_Number__c);
x.writeEndElement();
x.writeStartElement(null, 'Description', null);
x.writeCharacters(eto.Quoted_Part_Description__c);
x.writeEndElement();
x.writeStartElement(null, 'Product', null);
x.writeCharacters(eto.Product_Name_Text__c);
x.writeEndElement();
x.writeStartElement(null, 'UnitPrice', null);
x.writeCharacters((eto.Sale_Price_Each__c != null ? String.valueOf(eto.Sale_Price_Each__c) : '0'));
x.writeEndElement();
x.writeStartElement(null, 'AddlLeadTimeWks', null);
x.writeCharacters((eto.Additional_Lead_Time_weeks__c != null ? String.valueOf(eto.Additional_Lead_Time_weeks__c) : '0'));
x.writeEndElement();
x.writeStartElement(null, 'Weight', null);
x.writeCharacters((eto.Weight__c != null ? String.valueOf(eto.Weight__c) : '0'));
x.writeEndElement();
x.writeStartElement(null, 'IHR', null);
x.writeCharacters((eto.Install_Hours__c != null ? String.valueOf(eto.Install_Hours__c) : '0'));
x.writeEndElement();
x.writeStartElement(null, 'MinQty', null);
x.writeCharacters((eto.Minimum_Quantity__c != null ? String.valueOf(eto.Minimum_Quantity__c) : '0'));
x.writeEndElement();
x.writeStartElement(null, 'ColorReq', null);
x.writeCharacters((eto.Paint_Required__c == true ? '1' : '0'));
x.writeEndElement();
x.writeEndElement();
}
//}
}
x.writeEndElement();
x.writeEndDocument();
String xmlstr = x.getXmlString();
x.close();
doc.load(xmlstr);
system.debug(xmlstr);
//string xmldata = doc.toXmlString();
//system.debug(xmldata);
return xmlstr;
}
}