You need to sign in to do that
Don't have an account?
Kashona Dotson
Could not resolve field '[field]' from <apex:inputField> value binding
GOAL: Create a vfp+apxc combo to make a button on a custom Parent Object that will allow a user to edit and create new items on a related list.
Current error: Could not resolve field '[field]' from <apex:inputField> value binding '{!RIM__c.[field]}' in page RimItemsEdit
public class RimItemEditExtension { private ApexPages.StandardController std; public List<RIM_Item__c> items; // the associated rim ITEMS public Id chosenITEMSId {get; set;} // the chosen rim item id - used when deleting an item public String newITEMStype {get; set;} // addmore=public String newITEMSLastName {get; set;} public RimItemEditExtension() {} public RimItemEditExtension(ApexPages.StandardController stdCtrl) { std=stdCtrl; } public RIM__c getRIM() //RIM getRIM { return (RIM__c) std.getRecord(); } public SObject getSobject() { return std.getRecord(); } private boolean updateITEMS() { boolean result=true; if (null!=ITEMS) { // TODO: should work out what's changed and then save, easier to update everything for prototype List<RIM_Item__c> updateITEMS=new List<RIM_Item__c>(); try { update ITEMS; } catch (Exception e) { String msg=e.getMessage(); integer pos; // if its field validation, this will be added to the messages by default if (-1==(pos=msg.indexOf('FIELD_CUSTOM_VALIDATION_EXCEPTION, '))) { ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, msg)); } result=false; } } return result; } public PageReference saveAndExit() { boolean result=true; result=updateITEMS(); if (result) { // call standard controller save return std.save(); } else { return null; } } public PageReference save() { Boolean result=true; PageReference pr=Page.RimItemsEdit; if (null!=getRIM().id) { result=updateITEMS(); } else { pr.setRedirect(true); } if (result) { // call standard controller save, but don't capture the return value which will redirect to view page std.save(); ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.INFO, 'Changes saved, click Back to return to main file')); } pr.getParameters().put('id', getRIM().id); return pr; } public void newITEMS() { if (updateITEMS()) { RIM_Item__c i=new RIM_Item__c(Transaction_Type__c=newitemstype, RIM__c=getRIM().id); insert i; newitemsType=null; //newField=null; items=null; } } public void deleteITEMS() { if (updateITEMS()) { if (null!=chosenITEMSId) { RIM_Item__c i=new RIM_Item__c(Id=chosenITEMSId); delete i; ITEMS=null; chosenITEMSId=null; } } } public List<RIM_Item__c> getITEMS() //'List getITEMS' { if ( (null!=getRIM().id) && (ITEMS == null) ) { ITEMS=[SELECT Id, Transaction_Type__c, Check_Number__c, Transaction_Amount_Detail__c, Fee_Detail__c, Decision__c, Transaction_Amount_Decision__c, Fee_Decision__c, Item_Purpose__c, RIM__c FROM RIM_Item__c WHERE RIM__c = : getRIM().ID ORDER BY CreatedDate asc]; } return ITEMS; } }
<apex:page standardController="RIM__c" extensions="RimItemEditExtension" tabStyle="RIM__c" title="RIM Item Edit" > <apex:pageMessages /> <apex:form > <apex:pageBlock mode="mainDetail"> <apex:pageBlockButtons location="top"> <apex:commandButton action="{!cancel}" value="Back" /> <apex:commandButton action="{!save}" value="Save" /> <apex:commandButton action="{!newITEMS}" value="Add Item" rendered="{!NOT(ISBLANK(RIM.id))}" onclick="showpopup(); return false;"/> </apex:pageBlockButtons> <apex:pageBlockSection title="Main RIM File Details" collapsible="true" id="mainRecord" columns="2" > <apex:repeat value="{!$ObjectType.RIM__c.FieldSets.RIMListEdit}" var="field"> <apex:inputField value="{!RIM__c.[field]}" /> </apex:repeat> </apex:pageBlockSection> <apex:outputPanel id="ITEMS"> <apex:repeat value="{!RIM_Item__c}" var="itemobj" > <apex:pageBlockSection columns="1" title="RIM Item {!ITEMobj.Name}" collapsible="true"> <apex:pageBlockSectionItem > <apex:pageBlockSection columns="2"> <apex:repeat value="{!$ObjectType.ITEMobj.FieldSets.RIMItemListEdit}" var="field"> <apex:inputField value="{!ITEMobj[field]}" /> </apex:repeat> </apex:pageBlockSection> </apex:pageBlockSectionItem> </apex:pageBlockSection> <div style="text-align:left"> <apex:commandButton value="Delete This Item" onclick="idToDelete='{!ITEMS.id}'; showpopup('deletecontent'); return false;"/> </div> </apex:repeat> </apex:outputPanel> </apex:pageBlock> <apex:outputPanel id="addPanel"> <apex:actionRegion id="popupRegion"> <div id="opaque"/> <div id="popupcontent" class="popupcontent" style="width: 250px; height: 100px;"> Please enter the new RIM item details <apex:outputLabel value="Transaction Type: "/> <apex:inputField id="newitemsType" value="{!ITEMS.Transaction_Type__c}"/> <apex:commandButton id="cancelBtn" value="Cancel" onclick="hidepopup(); return false;"/> <apex:commandButton id="confirmBtn" action="{!newITEMS}" value="Create" rerender="itemsList, addPanel" onclick="hidepopup();" status="working"/> </div> </apex:actionRegion> </apex:outputPanel> <apex:actionRegion id="deleteRegion"> <div id="deletecontent" class="popupcontent" style="width: 250px; height: 100px;"> Are you sure you wish to delete RIM Item? <apex:commandButton id="cancelDelBtn" value="Cancel" onclick="hidepopup('deletecontent'); return false;"/> <apex:commandButton id="confirmDelBtn" value="Delete" rerender="itemsList" onclick="hidepopup('deletecontent'); alert('Deleting item ' + idToDelete); deleteITEMS(idToDelete); return false;" status="working"/> </div> </apex:actionRegion> <apex:actionFunction name="deleteITEMS" action="{!deleteITEMS}" rerender="contactList" status="working"> <apex:param name="itemsIdent" value="" assignTo="{!chosenITEMSId}"/> </apex:actionFunction> </apex:form> <div id="workingcontent" class="popupcontent" style="width:150px; height:50px; margin-top:-100px; marginleft:-100px"> <p align="center" style='{font-family:"Arial", Helvetica, sans-serif; font-size:20px;}'><apex:image value="/img/loading.gif"/> Please wait</p> </div> <apex:actionStatus id="working" onstart="showpopup('workingcontent');" onstop="hidepopup('workingcontent');" /> <script> function showpopup(popupname) { var name="popupcontent"; if (popupname) { name=popupname; } var popUp = document.getElementById(name); popUp.style.display = "block"; document.getElementById('opaque').style.display='block'; } function hidepopup(popupname) { var name="popupcontent"; if (popupname) { name=popupname; } var popUp = document.getElementById(name); popUp.style.display = "none"; document.getElementById('opaque').style.display='none'; } var idToDelete; </script> <style> .popupcontent{ position: fixed; top: 100%; left: 100%; margin-top: -100px; margin-left: -100px; display: none; overflow: auto; border:1px solid #CCC; background-color:white; border:3px solid #333; z-index:100; padding:5px; line-height:20px; font-size: 14px; } #opaque { position: fixed; top: 0px; left: 0px; width: 100%; height: 100%; z-index: 1; display: none; background-color: gray; filter: alpha(opacity=30); opacity: 0.3; -moz-opacity:0.3; -khtml-opacity:0.3 } * html #opaque { position: absolute; } </style> </apex:page>
Current error: Could not resolve field '[field]' from <apex:inputField> value binding '{!RIM__c.[field]}' in page RimItemsEdit
I tried your code and seems like the issue is with the way you are trying to display the fieldset using variable.I made a couple of modifications in your code, please check and confirm if this helps:
<apex:page standardController="RIM__c"
extensions="RimItemEditExtension"
tabStyle="RIM__c" title="RIM Item Edit" >
<apex:pageMessages />
<apex:form >
<apex:pageBlock mode="mainDetail">
<apex:pageBlockButtons location="top">
<apex:commandButton action="{!cancel}" value="Back" />
<apex:commandButton action="{!save}" value="Save" />
<apex:commandButton action="{!newITEMS}" value="Add Item" rendered="{!NOT(ISBLANK(RIM.id))}" onclick="showpopup(); return false;"/>
</apex:pageBlockButtons>
<apex:pageBlockSection title="Main RIM File Details" collapsible="true" id="mainRecord" columns="2" >
<apex:repeat value="{!$ObjectType.RIM__c.FieldSets.RIMListEdit}" var="field">
<apex:inputField value="{!RIM[field]}" />
</apex:repeat>
</apex:pageBlockSection>
<apex:outputPanel id="ITEMS">
<apex:repeat value="{!RIM_Item__c}" var="itemobj" >
<apex:pageBlockSection columns="1" title="RIM Item {!ITEMobj.Name}" collapsible="true">
<apex:pageBlockSectionItem >
<apex:pageBlockSection columns="2">
<apex:repeat value="{!$ObjectType.ITEMobj.FieldSets.RIMItemListEdit}" var="field">
<apex:inputField value="{!ITEMobj[field]}" />
</apex:repeat>
</apex:pageBlockSection>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
<div style="text-align:left">
<apex:commandButton value="Delete This Item" onclick="idToDelete='{!ITEMS.id}'; showpopup('deletecontent'); return false;"/>
</div>
</apex:repeat>
</apex:outputPanel>
</apex:pageBlock>
<apex:outputPanel id="addPanel">
<apex:actionRegion id="popupRegion">
<div id="opaque"/>
<div id="popupcontent" class="popupcontent" style="width: 250px; height: 100px;">
Please enter the new RIM item details
<apex:outputLabel value="Transaction Type: "/>
<apex:inputField id="newitemsType" value="{!ITEMS.Transaction_Type__c}"/>
<apex:commandButton id="cancelBtn" value="Cancel" onclick="hidepopup(); return false;"/>
<apex:commandButton id="confirmBtn" action="{!newITEMS}" value="Create" rerender="itemsList, addPanel" onclick="hidepopup();" status="working"/>
</div>
</apex:actionRegion>
</apex:outputPanel>
<apex:actionRegion id="deleteRegion">
<div id="deletecontent" class="popupcontent" style="width: 250px; height: 100px;">
Are you sure you wish to delete RIM Item?
<apex:commandButton id="cancelDelBtn" value="Cancel" onclick="hidepopup('deletecontent'); return false;"/>
<apex:commandButton id="confirmDelBtn" value="Delete" rerender="itemsList" onclick="hidepopup('deletecontent'); alert('Deleting item ' + idToDelete); deleteITEMS(idToDelete); return false;" status="working"/>
</div>
</apex:actionRegion>
<apex:actionFunction name="deleteITEMS" action="{!deleteITEMS}" rerender="contactList" status="working">
<apex:param name="itemsIdent" value="" assignTo="{!chosenITEMSId}"/>
</apex:actionFunction>
</apex:form>
<div id="workingcontent" class="popupcontent" style="width:150px; height:50px; margin-top:-100px; marginleft:-100px">
<p align="center" style='{font-family:"Arial", Helvetica, sans-serif; font-size:20px;}'><apex:image value="/img/loading.gif"/> Please wait</p>
</div>
<apex:actionStatus id="working" onstart="showpopup('workingcontent');" onstop="hidepopup('workingcontent');" />
<script>
function showpopup(popupname)
{
var name="popupcontent";
if (popupname)
{
name=popupname;
}
var popUp = document.getElementById(name);
popUp.style.display = "block";
document.getElementById('opaque').style.display='block';
}
function hidepopup(popupname)
{
var name="popupcontent";
if (popupname)
{
name=popupname;
}
var popUp = document.getElementById(name);
popUp.style.display = "none";
document.getElementById('opaque').style.display='none';
}
var idToDelete;
</script>
<style>
.popupcontent{
position: fixed;
top: 100%;
left: 100%;
margin-top: -100px;
margin-left: -100px;
display: none;
overflow: auto;
border:1px solid #CCC;
background-color:white;
border:3px solid #333;
z-index:100;
padding:5px;
line-height:20px;
font-size: 14px;
}
#opaque {
position: fixed;
top: 0px;
left: 0px;
width: 100%;
height: 100%;
z-index: 1;
display: none;
background-color: gray;
filter: alpha(opacity=30);
opacity: 0.3;
-moz-opacity:0.3;
-khtml-opacity:0.3
}
* html #opaque {
position: absolute;
}
</style>
</apex:page>