Populating SelectList with sobject - salesforce

I am trying to create a class that will populate the a multi selectlist depending on what URL parameters are passed in.
Im having trouble. The slectlist never renders, however, looking through the debugger, i can see that records are found and that it should populate.
Am I missing something stupid?
VisualForce.Page
<apex:page controller="PopUp">
<apex:form >
<apex:selectList value="{!objectType}" multiselect="true">
<apex:selectOptions value="{!SelectListOptions}"/>
</apex:selectList>
</apex:form>
Controller class:
public with sharing class PopUp {
public sObject objParameter {get;set;}
public string fldParameter {get;set;}
public string queryType {get;set;}
public static string objName{get;set;}
public list<SelectOption> selectListOptions {get;set;}
public static list<string> TEST {get;set;}
public String[] objectType= new String[]{};
public PopUp(){
objName = ApexPages.currentPage().getParameters().get('obj');
sObject dynObject = Schema.getGlobalDescribe().get(objName).newSObject() ;
objParameter = dynObject;
fldParameter = ApexPages.currentPage().getParameters().get('fld');
String queryType = ApexPages.currentPage().getParameters().get('qt');
system.debug('***objParameter: ' + objParameter);
system.debug('***fldParameter: ' + fldParameter);
//List<selectOption> L = getPicklistValues(objParameter, fldParameter, queryType);
}
public static list<SelectOption> getPicklistValues(SObject obj, String fld, String queryType)
{
list<SelectOption> options = new list<SelectOption>();
if(queryType == 'soql'){
string query = 'select ' + fld + ' from ' + objName;
system.debug('***query: ' + query);
List<sObject> dynList = Database.query(query);
system.debug('***dynList: ' + dynList);
for(integer i=0;i< dynList.size();i++){
string fldValue = string.valueof(dynList[i].get(fld));
system.debug('***fldValue: ' + fldValue);
options.add(new SelectOption(fldValue,fldValue));
TEST.add(fldValue);
}
}
system.debug('***options: ' + options);
return options;
}
public List<selectOption> getSelectListOptions() {
return getPicklistValues(objParameter, fldParameter, queryType);
}
public String[] getObjectType()
{
return objectType;
}
public void setObjectType(String[] objectType)
{
this.objectType= objectType;
}

I think you're confusing the VF page by having essentially two getter methods (the one you added, and the one you told the controller to create itself by specifying get; in the variable declaration):
public list<SelectOption> selectListOptions {get;set;}
public List<selectOption> getSelectListOptions() {
return getPicklistValues(objParameter, fldParameter, queryType);
}
It doesn't look like you're populating selectListOptions anywhere, so the VF page sees that and doesn't add any options to your picklist. The VF page will only call getSelectListOptions() if it doesn't find a getter for your variable, so modify the selectListOptions declaration like so, and you should be fine:
public List<SelectOption> selectListOptions {set;}
In fact, it doesn't look like your page should have access to set this, so you could remove the setter as well if you wanted.

Related

Why can't I return a List<Account> or an array of wrappers?

I would like to display a list of Accounts or Account wrappers in my VF page. I have a controller that works for a LWC and would like to add methods for a VF page, as well, that does pretty much the same thing. I have a very simple VF page that I nearly copied from the developer guide, and Salesforce wants to create a method that just returns a String, but I want to return a list of accounts. For now, I am just trying to pass in some fixed parameters. Can anyone tell me what is wrong here?
Page:
<apex:page docType="html-5.0" controller="AccountTypeAheadSearchHelper">
<h1>Account Type-Ahead Search Demo VF</h1>
<apex:outputLink value="{!URLFOR($Action.Account.View,'0018c00002N0qccAAB')}">Open this Account</apex:outputLink>
<apex:form >
<apex:actionFunction name="onKeyUpHandler" action="{!onKeyUpHandlerVF}">
<apex:param name="currentValue" assignTo="{!accountSearchVF}" value="" />
</apex:actionFunction>
<div>
<apex:inputText label="Search for account" id="theAccountName" value="{!accountSearchVF}" onkeyup="onKeyUpHandler(document.getElementById({!$Component.theAccountName}).nodeValue);" />
</div>
<apex:commandButton action="{!saveVF}" value="Save" id="theSaveButtonVF" />
</apex:form>
<apex:pageBlock title="Matching Accounts" mode="view">
<apex:dataList value="{!matchingAccountsVF}" var="matchingAccount" >
<apex:outputText value="{!matchingAccount.Name}" />
</apex:dataList>
</apex:pageBlock>
</apex:page>
Controller:
public with sharing class AccountTypeAheadSearchHelper {
private String accountSearchVFValue = 'Enter an account name';
/**
* Given a searchString, returns an array of MatchingAccountsWrappers for the LWC to consume
*
* #param searchString a part of the name of the account to search for
*
* #return an array of MatchingAccountsWrappers
*/
#AuraEnabled
public static MatchingAccountsWrapper[] getMatchingAccounts(String searchString, Boolean showContacts) {
String searchSpec = '%' + searchString + '%';
List<Account> accountsFound;
if (showContacts) {
accountsFound = [
SELECT Id, Name,
(SELECT Id, Name FROM Contacts ORDER BY Name)
FROM Account
WHERE Name LIKE :searchSpec
ORDER BY Name];
} else {
accountsFound = [
SELECT Id, Name
FROM Account
WHERE Name LIKE :searchSpec
ORDER BY Name];
}
List<MatchingAccountsWrapper> matchingAccounts = new List<MatchingAccountsWrapper>();
for (Account ma : accountsFound) {
MatchingAccountsWrapper mar = new MatchingAccountsWrapper(ma.Id, ma.Name, showContacts ? ma.Contacts: null);
matchingAccounts.add(mar);
system.debug('### matching account.name = ' + ma.Name);
}
return matchingAccounts;
}
public List<Account> getMatchingAccountsVF(String searchString, Boolean showContacts) {
String searchSpec = '%' + searchString + '%';
List<Account> accountsFound;
if (showContacts) {
accountsFound = [
SELECT Id, Name,
(SELECT Id, Name FROM Contacts ORDER BY Name)
FROM Account
WHERE Name LIKE :searchSpec
ORDER BY Name];
} else {
accountsFound = [
SELECT Id, Name
FROM Account
WHERE Name LIKE :searchSpec
ORDER BY Name];
}
return accountsFound;
}
public PageReference saveVF() {
system.debug('### AccountTypeAheadSearchHelper:saveVF() method');
return null;
}
public String accountSearchVF {
get {
system.debug('### AccountTypeAheadSearchHelper:accountSearchVF() getter: accountSearchVFValue = ' + accountSearchVFValue);
return accountSearchVFValue;
}
set {
system.debug('### AccountTypeAheadSearchHelper:accountSearchVF() setter: value = ' + value);
accountSearchVFValue = value;
}
}
public void onKeyUpHandlerVF() {
system.debug('### AccountTypeAheadSearchHelper:onKeyUpHandlerVF(): BEGIN');
system.debug('### AccountTypeAheadSearchHelper:onKeyUpHandlerVF(): accountSearchVFValue = ' + accountSearchVFValue);
MatchingAccountsWrapper[] mars = getMatchingAccounts(accountSearchVFValue, false);
system.debug('### AccountTypeAheadSearchHelper:onKeyUpHandlerVF(): END');
}
private class MatchingAccountsWrapper {
public MatchingAccountsWrapper(String k, String n) {
key = k;
name = n;
}
public MatchingAccountsWrapper(String k, String n, List<Contact> c) {
key = k;
name = n;
relatedContacts = c;
}
public MatchingAccountsWrapper(Account a) {
key = a.Id;
name = a.Name;
}
#AuraEnabled
public string key {get; set;}
#AuraEnabled
public string name {get; set;}
#AuraEnabled
public string link {get {
return URL.getSalesforceBaseUrl().toExternalForm() + '/' + this.key;
} set;}
private List<Contact> relatedContacts {get; set;}
#AuraEnabled
public List<MatchingContactsWrapper> contacts {get {
if (relatedContacts != null) {
List<MatchingContactsWrapper> matchingContacts = new List<MatchingContactsWrapper>();
for (Contact matchingContact : relatedContacts) {
MatchingContactsWrapper mac = new MatchingContactsWrapper(matchingContact);
matchingContacts.add(mac);
}
return matchingContacts;
} else {
return null;
}
} set;}
}
private class MatchingContactsWrapper {
public MatchingContactsWrapper(Contact c) {
key = c.Id;
name = c.Name;
}
#AuraEnabled
public string key {get; set;}
#AuraEnabled
public string name {get; set;}
#AuraEnabled
public string link {get {
return URL.getSalesforceBaseUrl().toExternalForm() + '/' + this.key;
} set;}
}
}
I think I really should be able to use the same getMatchingAccounts method that I use for the LWC, have also tried getMatchingAccountsVF. But it tells me that it doesn't exist in the controller. When I let Salesforce create the method, I makes a Public String method. I don't understand why it is making a String method.
The form part is not even relevant here, just the pageblock with the datalist in it. I would like to call "{!matchingAccountsVF('st', false)}" as a starting point and then pass in actual parameters from the user, but this doesn't work.
I am basing this on the very simple example I see here: https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_dataList.htm
You can reuse Apex written for Aura/LWC in VF but the main difference is "state". Aura and LWC are stateless, you pass everything you need to server (or query it fresh) explicitly and the methods have to be static (btw your #AuraEnabled could really use cacheable=true). In Visualforce state is passed silently for you in a hidden encoded variable. All variables (except the ones declared transient) will be passed from the page to apex and class' internal state will be reconstructed.
You need a kind of autocomplete, right? You have few ways to do it. (Plus there are lots of examples on the net) Depends if you want it "pure Visualforce way" with that syntax or you're more comfortable with doing everything in JS.
completely reuse your component (read up about "Lightning Out")
call the javascript similar to LWC (as a static function, lightweight, mobile-friendly) with "Remoting". It's bit old and I guess you could say it's early version of Aura - JavaScript function, handle the response in JS (not VF), rebuild your list of accounts in JS.
call the server side code "old school visualforce" - with full resubmit of the form (or onKeyUp, doesn't matter). The key thing will be that parameter will be passed as part of that whole viewstate thing. And then your getMatchingAccountsVF doesn't need parameters, it becomes pure getter. It'll just rely on normal class variable with the search term.
public class Stack73082136 {
// Service part (static, useable in Aura/LWC but eventually maybe also as a REST service)
// This method would typically throw exceptions, perhaps AuraHandledException
#RemoteAction #AuraEnabled(cacheable=true)
public static MatchingAccountsWrapper[] getMatchingAccounts(String searchString, Boolean showContacts) {
String searchSpec = '%' + searchString + '%';
List<Account> accountsFound;
if (showContacts) {
accountsFound = [
SELECT Id, Name,
(SELECT Id, Name FROM Contacts ORDER BY Name)
FROM Account
WHERE Name LIKE :searchSpec
ORDER BY Name];
} else {
accountsFound = [
SELECT Id, Name
FROM Account
WHERE Name LIKE :searchSpec
ORDER BY Name];
}
List<MatchingAccountsWrapper> matchingAccounts = new List<MatchingAccountsWrapper>();
for (Account ma : accountsFound) {
MatchingAccountsWrapper mar = new MatchingAccountsWrapper(ma.Id, ma.Name, showContacts ? ma.Contacts: null);
matchingAccounts.add(mar);
system.debug('### matching account.name = ' + ma.Name);
}
return matchingAccounts;
}
// Visualforce part (old school, stateful)
// This would typically not throw exceptions but ApexPages.addMessage() etc.
// (which means that non-VF context like a trigger, inbound email handler or code called from Flow would crash and burn at runtime; in these you can only do exceptions)
public String searchValue {get;set;}
public List<MatchingAccountsWrapper> getMatchingAccountsVF() {
return getMatchingAccounts(searchValue, false);
}
public void onKeyUpHandlerVF() {
system.debug('### AccountTypeAheadSearchHelper:onKeyUpHandlerVF(): BEGIN');
system.debug('### AccountTypeAheadSearchHelper:onKeyUpHandlerVF(): accountSearchVFValue = ' + searchValue);
// do nothing. this method is "stupid", it's only job is to be called, pass the parameter and then the getMatchingAccountsVF
// will be called by VF engine when it needs to rerender {!matchingAccountsVF} expression
}
private class MatchingAccountsWrapper {
public MatchingAccountsWrapper(String k, String n) {
key = k;
name = n;
}
public MatchingAccountsWrapper(String k, String n, List<Contact> c) {
key = k;
name = n;
relatedContacts = c;
}
public MatchingAccountsWrapper(Account a) {
key = a.Id;
name = a.Name;
}
#AuraEnabled
public string key {get; set;}
#AuraEnabled
public string name {get; set;}
#AuraEnabled
public string link {get {
return URL.getSalesforceBaseUrl().toExternalForm() + '/' + this.key;
} set;}
private List<Contact> relatedContacts {get; set;}
#AuraEnabled
public List<MatchingContactsWrapper> contacts {get {
if (relatedContacts != null) {
List<MatchingContactsWrapper> matchingContacts = new List<MatchingContactsWrapper>();
for (Contact matchingContact : relatedContacts) {
MatchingContactsWrapper mac = new MatchingContactsWrapper(matchingContact);
matchingContacts.add(mac);
}
return matchingContacts;
} else {
return null;
}
} set;}
}
private class MatchingContactsWrapper {
public MatchingContactsWrapper(Contact c) {
key = c.Id;
name = c.Name;
}
#AuraEnabled
public string key {get; set;}
#AuraEnabled
public string name {get; set;}
#AuraEnabled
public string link {get {
return URL.getSalesforceBaseUrl().toExternalForm() + '/' + this.key;
} set;}
}
}
<apex:page docType="html-5.0" controller="Stack73082136">
<h1>Account Type-Ahead Search Demo VF</h1>
<apex:form >
<apex:pageBlock title="1. Total old school">
<apex:actionRegion>
<apex:inputText value="{!searchValue}" label="type and click" />
<apex:commandButton action="{!onKeyUpHandlerVF}" rerender="out1" />
<apex:outputPanel id="out1">
<apex:dataList value="{!matchingAccountsVF}" var="acc" >
<apex:outputText value="{!acc.Name}" />
</apex:dataList>
</apex:outputPanel>
</apex:actionRegion>
</apex:pageBlock>
<apex:actionFunction action="{!onKeyUpHandlerVF}" name="onKeyUpJS" rerender="out2">
<apex:param name="param1" assignTo="{!searchValue}" value="" />
</apex:actionFunction>
<apex:pageBlock title="2. Old school (viewstate, not mobile friendly) but at least onkeyup">
<!-- this is bit rubbish, fires immediately. Realistically you probably want some delay, wait till user stops typing. -->
<apex:actionRegion>
<apex:inputText value="{!searchValue}" label="type and wait" onkeyup="onKeyUpJS(this.value);"/>
<apex:outputPanel id="out2">
<apex:dataList value="{!matchingAccountsVF}" var="acc" >
<apex:outputText value="{!acc.Name}" />
</apex:dataList>
</apex:outputPanel>
</apex:actionRegion>
</apex:pageBlock>
<script>
function callRemote(term){
// call static method in ClassName.methodName format
Visualforce.remoting.Manager.invokeAction(
'{!$RemoteAction.Stack73082136.getMatchingAccounts}',
term,
false, // no contacts pls
function(result, event){
if (event.status) {
//debugger;
let target = document.getElementById("out3");
while (target.firstChild) {
target.removeChild(target.firstChild);
}
result.forEach(item => target.append(item.key + ': ' + item.name + ';'));
} else if (event.type === 'exception') {
document.getElementById("responseErrors").innerHTML =
event.message + "<br/>\n<pre>" + event.where + "</pre>";
} else {
document.getElementById("responseErrors").innerHTML = event.message;
}
},
{escape: true}
);
}
</script>
<apex:pageBlock title="3. VF remoting, the grandfather of Aura. No viewstate, pure html and js">
<input type="text" id="text3" label="type and vait v2" onkeyup="callRemote(this.value)" />
<div id="out3"></div>
<div id="responseErrors"></div>
</apex:pageBlock>
</apex:form>
</apex:page>

Salesforce apex class Unexpected token error

I want to create a keyword search referring to "UserName__c" api on Salesforce Apex class.
compile error Unexpected token 'UserName__c'.
public with sharing class AccountListCon {
static List<String> TARGET_FIELDS = new List<String>{
'Name'
,'UserName__c'
,'CompanyName__c'
};
public SearchCondition condition{ get;set; }
public String UserName__c results { get;set; }
public String sortingField { get;set; }
public void init(){
this.condition = new SearchCondition();
this.results = new String UserName__c();
}
public PageReference clear(){
init();
return null;
}
There is no such type String UserName__c. It's not entirely clear what you want to do here, but I suspect you intend just to declare a String variable. The fact that you're looking for values in some field whose API name is UserName__c is not relevant to the type system
public String UserName__c results { get;set; } is wrong. Is this supposed to be just
public String results { get;set; } ?

Displaying custom controller data in visualforce page after onchange event

I have a picklist containing names of records of an object, "Test_Script".When I select any option from a picklist("selectlist" & selectoption are used for implementing picklist),at onchange event the other fields related to that record name should be displayed on visualforce page.
VF Page:
<h1>Choose Script:</h1>
<apex:selectlist value="{!selectedValue}" size="1"onchange="{!setValues}">
<apex:selectOptions value="{!scriptoptions}" />
</apex:selectlist>
<br/>
Executioner Name:
<outputfield value="{!valueResult.executioner_name}"/>
<br/>Planner Name:
<outputfield value="{!valueResult.planner_name}"/>
<br/>Reviewer Name:
<outputfield value="{!valueResult.reviewer_name}"/>
Controller:
public class ScriptAttributesController
{
public String setValues { get; set; }
public List<Test_script__c> scriptListWithValues = [select name, id, Executioner__c, Planner__c, Reviewer__c from Test_Script__c];
public static Test_Script__c valueResult=new Test_Script__c();
public String selectedValue {get;set;}
public void ScriptAttributesController()
{
}
public List<SelectOption> getScriptoptions()
{
List<SelectOption> options = new List<SelectOption>();
options.add(new SelectOption('select a value','select a value'));
for(Test_Script__c s: scriptListWithValues )
{
options.add(new SelectOption(s.id,s.name));
}
return options;
}
public void setValues()
{
valueResult=[select name, id, Executioner__c, Planner__c, Reviewer__c, Iteration__c from Test_Script__c where name='selectedValue' limit 1];
}
}
I am not able to see value on screen on change og picklist value
I would say that a getter is missing for your valueResult.
public Test_Script__c valueResult {get; set;}
and in the controller you can init the object.

Salesforce: Attempt to de-reference a null object

I've searched and found several articles about this error, but I'm new to APEX and Visualforce and so I can't figure out how to apply the solutions to what I'm working on. Any help would be appreciated. What I'm trying to do in the code below is create a visualforce page embedded on Opportunity records that displays 2 multi-select picklists, one being dependent on the choice(s) picked in the first.
public class WatermelonOppController {
//added an instance varaible for the standard controller
private ApexPages.StandardController controller {get; set;}
// the actual opportunity
private Opportunity o;
public String[] parentPicklistVal {public get; public set;}
public String[] childMultiPicklistVal {public get; public set;}
public String childSinglePicklistVal {public get; public set;}
// maps to hold your dependencies between picklists
private Map<String, List<String>> parentDepMap;
private Map<String, List<String>> childDepMap;
private String[] parentOpts = new String[] { 'parent option 1', 'parent option 2' };
private String[] childMultiOpts = new String[] { 'child multi 1', 'child multi 2', 'child multi 3' };
//private String[] childSingleOpts = new String[] { 'child single 1', 'child single 2', 'child single 3' };
public WatermelonOppController(ApexPages.StandardController controller) {
//initialize the stanrdard controller
this.controller = controller;
//this.o = (Opportunity)controller.getRecord();
}
public WatermelonOppController() {
// init dependency maps
parentDepMap = new Map<String, List<String>>();
// childDepMap = new Map<String, List<String>>();
// pick which child options to display for which parent value
parentDepMap.put(parentOpts[0], (new String[]{childMultiOpts[0], childMultiOpts[1]}));
parentDepMap.put(parentOpts[1], (new String[]{childMultiOpts[1], childMultiOpts[2]}));
// pick which single-select options to display for which child value
//childDepMap.put(childMultiOpts[0], (new String[]{childSingleOpts[0], childSingleOpts[2]}));
//childDepMap.put(childMultiOpts[1], (new String[]{childSingleOpts[1], childSingleOpts[2]}));
//childDepMap.put(childMultiOpts[2], childSingleOpts); // or if you want to show them all?
}
public List<SelectOption> getParentPicklistOptions() {
List<SelectOption> selectOpts = new List<SelectOption>();
for ( String s : parentOpts )
selectOpts.add(new SelectOption(s, s));
return selectOpts;
}
public List<SelectOption> getChildMultiPicklistOptions() {
List<SelectOption> selectOpts = new List<SelectOption>();
if ( parentPicklistVal != null && parentPicklistVal.size() > 0 ) {
// build a set of values to avoid dupes, since there may be overlapping dependencies
Set<String> possibleOpts = new Set<String>();
for ( String val : parentPicklistVal )
possibleOpts.addAll(parentDepMap.get(val));
for ( String s : possibleOpts )
selectOpts.add(new SelectOption(s, s));
}
return selectOpts;
}
/*
public List<SelectOption> getChildSinglePicklistOptions() {
List<SelectOption> selectOpts = new List<SelectOption>();
if ( childMultiPicklistVal != null && childMultiPicklistVal.size() > 0 ) {
// build a set of values to avoid dupes, since there may be overlapping dependencies
Set<String> possibleOpts = new Set<String>();
for ( String val : childMultiPicklistVal )
possibleOpts.addAll(childDepMap.get(val));
for ( String s : possibleOpts )
selectOpts.add(new SelectOption(s, s));
}
return selectOpts;
}
*/
public PageReference actionUpdatePicklistVals() {
// this doesn't really need to do anything, since the picklists should be updated when their getters call after returning
return null;
}
}
And the Visualforce page:
<apex:page standardController="Opportunity" extensions="WatermelonOppController">
<apex:form >
<apex:outputPanel id="panel1">
<apex:selectList value="{!parentPicklistVal}" multiselect="true" size="3">
<apex:selectOptions value="{!parentPicklistOptions}" />
<apex:actionSupport event="onchange" action="{!actionUpdatePicklistVals}" rerender="panel1" />
</apex:selectList>
<apex:selectList value="{!childMultiPicklistVal}" multiselect="true" size="3">
<apex:selectOptions value="{!childMultiPicklistOptions}" />
<apex:actionSupport event="onchange" action="{!actionUpdatePicklistVals}" rerender="panel1" />
</apex:selectList>
</apex:outputPanel>
</apex:form>
You should move all your logic from default contructor to the parameterized constructor. Since the class is an extension, it's parameterized contructor with Standard Controller is being called.

Rule__c : managerules does not exist or is not a valid override for action Edit.

i have a class in dev org with code is
name of class is ManageRules.cls
/**
* This class is used for creating and editing Rule
**/
public with sharing class ManageRules{
public Rule__c newrule {get;set;}
public String objType {get;set;}
public string SearchEvalRule {get;set;}
public string Descr {get;set;}
public List<SelectOption> objOptions {get;set;}
// public String descr {get;set;}
public boolean edit {get;set;}
String ruleId;
public ManageRules(Apexpages.StandardController stdcon){
ruleId = stdcon.getId();
newrule = new Rule__c();
objOptions = new List<SelectOption>();
edit=false;
/**
* Add standard Objects
*/
objOptions.add(new SelectOption('',''));
objOptions.add(new SelectOption('Account','Account'));
objOptions.add(new SelectOption('Contact','Contact'));
objOptions.add(new SelectOption('Opportunity','Opportunity'));
objOptions.add(new SelectOption('Case','Case'));
objOptions.add(new SelectOption('Lead','Lead'));
objOptions.add(new SelectOption('Campaign','Campaign'));
objOptions.add(new SelectOption('Quote','Quote'));
objOptions.add(new SelectOption('Product2','Product'));
//objOptions.add(new SelectOption('ForeCast','Forecast'));
Map<String, Schema.SObjectType> mapObj = Schema.getGlobalDescribe();
for(String objname:mapObj.keySet()){
Schema.SObjectType sobj = mapObj.get(objname);
Schema.DescribeSObjectResult descRes = sobj.getDescribe();
/**
* Add custom objects
*/
if(descRes.isCustom() && !descRes.isCustomSetting()){
String objLabel = descRes.getLabel();
objOptions.add(new SelectOption(objName,objLabel));
}
}
/* Edit Rule */
if(ruleId!=null){
edit=true;
newrule = [select name,object__c,Rule_Execution_Plan__c,Available__c,Evaluation_Rule__c,Description__c from rule__c where id=:ruleId];
if(newrule!=null){
objtype=newrule.object__c;
Descr =newrule.Description__c;
SearchEvalRule =newrule.Evaluation_Rule__c ;
}
}
}
Public List<SelectOption> getEvalRule() {
List<selectOption> options = new List<selectOption>();
options.add(new selectOption('', '- None -'));
Schema.DescribeFieldResult field = Rule__c.Evaluation_Rule__c.getDescribe();
for (Schema.Picklistentry picklistEntry : field.getPicklistValues())
{
options.add(new SelectOption(pickListEntry.getValue(),pickListEntry.getLabel()));
}
return options;
}
public PageReference saveRule(){
newrule.object__c = objtype;
newrule.Evaluation_Rule__c=SearchEvalRule;
newrule.Description__c= Descr;
try{
Database.upsert(newrule);
return(new PageReference('/'+newrule.id));
}
catch(Exception e){
ApexPages.Message msg = new ApexPages.Message(ApexPages.severity.Error,e.getDMLMessage(0));
ApexPages.addMessage(msg);
return null;
}
}
public PageReference saveAndNewRule(){
newrule.object__c = objtype;
newrule.Evaluation_Rule__c=SearchEvalRule;
newrule.Description__c= Descr;
edit=false;
try{
Database.upsert(newrule);
newrule = new Rule__c();
return(new PageReference('/apex/manageRules'));
}
catch(Exception e){
ApexPages.Message msg = new ApexPages.Message(ApexPages.severity.Error,e.getDMLMessage(0));
ApexPages.addMessage(msg);
return null;
}
}
}
i created an object its giving me error
Description Resource Path Location Type
Save error: Rule_c : managerules does not exist or is not a valid override for action Edit. Rule_c.object /RuleCriteria/src/objects line 0 Force.com save problem
my Rule__c object code segment where i am getting this error is :
<actionOverrides>
<actionName>Edit</actionName>
<content>ManageRules</content>
<skipRecordTypeSelect>false</skipRecordTypeSelect>
<type>Visualforce</type>
</actionOverrides>
i am unable to figure why its showing me this error its an existing project so i have to deploy it on my dev org .on others org its working perfectly fine.i first save this class code and then try to save this object code and getting this error.can any one please how to resolve this issue??

Resources