0

can help me this error?

This error occur at

LIST empMember = [SELECT Id, Name, Full_Name__r.Name FROM HREMPINFO__c WHERE Id IN (SELECT Employee_No__c FROM PYEMPPAYPERIOD__c WHERE Period__r.Period__r.Id =: selectedPeriod) ORDER BY Name];

error message : Didn't understand relationship 'Period__r' in field path. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names.

my controller :

public with sharing class PreProcessController {

public SelectOption[] selectedEmployee { get; set; }
public SelectOption[] allContacts { get; set; }
public String selectedPeriod { get; set; }
Public String ProcessAll {get; set;}
Public Integer Count=0;
public String message { get; set; }
public String picklistVal;

public List<selectOption> getPeriod() {        
    List<selectOption> listPeriod = new List<selectOption>(); 
    listPeriod.add(new selectOption('', '- None -')); 
    for (PYSETPAYPERIOD__c perCode : [SELECT Id, Name, Process_Flag__c FROM PYSETPAYPERIOD__c WHERE Process_Flag__c < 4 OR Process_Flag__c = NULL ORDER BY Name]) {         
        listPeriod.add(new selectOption(perCode.id, perCode.Name));       
    } 
    return listPeriod;
}
public PreProcessController() {}
public LIST<SelectOption> GetAllEmployee() {
    LIST<HREMPINFO__c> empMember = [SELECT Id, Name, Full_Name__r.Name FROM HREMPINFO__c WHERE Id IN 
                                    (SELECT Employee_No__c FROM PYEMPPAYPERIOD__c WHERE Period__r.Period__r.Id =: selectedPeriod)
                                    ORDER BY Name];

    LIST<HREMPASSIGNMENT__c> empAssignment = [SELECT Position_Name__c, Position_Name__r.Name, Employee_No__c  FROM HREMPASSIGNMENT__c];

    LIST<SelectOption> empList = new LIST<SelectOption>();

    for(HREMPINFO__c eM : empMember){
        for(HREMPASSIGNMENT__c eA : empAssignment){
            if(eA.Employee_No__c == eM.Id){
                picklistVal = eM.Full_Name__r.Name + ' - ' + eM.Name + ' - ' +eA.Position_Name__r.Name;
                empList.add(new SelectOption(eM.Id, picklistVal));}
            }
        }
        return empList;
    }

public PageReference save() {
    message = 'Work'+Count;
    Boolean first = true;
    for ( SelectOption so : selectedContacts ) {
        if (!first) {
            message += ', ';
        }
        message += so.getLabel() + ' (' + so.getValue() + ')';
        first = false;
    }

    return null; }      
}

my vf page:

<apex:page controller="PreProcessController">
<apex:form >

    <apex:pageBlock title="Contacts">
        <apex:pageBlockSection columns="1" showHeader="false">
        <apex:pageBlockSectionItem>
                <apex:outputLabel value="Payroll Name" for="listPeriod"/>
                <apex:selectList id="listPeriod" size="1" multiselect="false" value="{!selectedPeriod}" style="width:150px">
                    <apex:selectOptions value="{!Period}"/>
                    <apex:actionSupport event="onchange" reRender="listEmployee"/>
                </apex:selectList>
            </apex:pageBlockSectionItem>

        <apex:pageblocksectionItem >
                <apex:outputLabel value="All Employee" />
                <apex:inputCheckbox id="ProcessAll" value="{!ProcessAll}">
                    <apex:actionSupport event="onclick" reRender="listEmployee" />
                </apex:inputCheckbox>
            </apex:pageblocksectionItem>
        </apex:pageBlockSection>

        <apex:panelGroup id="listEmployee">
            <c:MultiselectPicklist leftLabel="Available Employee" leftOptions="{!allEmployee}"
                                   rightLabel="Selected Employee"
                                   rightOptions="{!selectedEmployee}"
                                   size="14"
                                   width="475px"/>
        </apex:panelGroup>

            <apex:pageBlockButtons >
            <apex:commandButton value="Save" action="{!save}"/>
        </apex:pageBlockButtons>
        <apex:outputText >{!message}</apex:outputText>
    </apex:pageBlock>
</apex:form>

  • 2
    Does Period__c look up to itself? It seems like the simplest field path would be Period__c in place of Period__r.Period__r.Id. – Adrian Larson Sep 27 '16 at 3:13
  • nope, it was lookup field from object a, then lookup again from object b, so it was 2 level lookup @AdrianLarson – Vikolai Sep 27 '16 at 3:25
  • 2
    As the error message says, if you are not sure about the correct API name, better to have a look at the WSDL first. – highfive Sep 27 '16 at 3:38
0

For me, it looks like security issue. Make sure your current account has field access to period__c field and related object

  • hmm oke then, thanks for answer sir, u already comment at all my question, very very appreciate that sir! :) i will find it myself then hehe @LanceShi – Vikolai Sep 27 '16 at 3:46
  • 1
    While Visualforce automatically handles object and field level CRUD permissions automatically, Apex does not. See e.g. Enforcing CRUD and FLS. So not a security issue (and the error message in the question is pretty clear). – Keith C Sep 27 '16 at 7:41
  • @KeithC hmm, LanceShi already know my problem, cause i already post about my problem in many context, and he know what i'm doing and what is my problem, but i find the answer now, my button cant operation because of my reRender, now i need to know how to isolate the reRender and action. any idea? i post it in another question. Thanks! – Vikolai Sep 27 '16 at 8:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.