You need to sign in to do that
Don't have an account?
Олег Савинков
Method in Apex Controller doesn't work
Hello!
I have some page named CallsHospInsert. It have some code:
Controller:
That code of page AccountsListforHosp :
So, why method applyFilterByOrganisationsIns() doesn't starting?
P.S.
Please sorry for my bad English.
I have some page named CallsHospInsert. It have some code:
<apex:page standardController="CallReportHosp__c" extensions="CtrlCallHospInsert" id="CallsHospEditt"> <script type="text/javascript"> function openOrganisationDialog() { openPopup("/apex/AccountsListforHosp?context=pharma_chain&list=noList", "lookup", 900, 600, "width=900,height=600,toolbar=no,status=no,directories=no,menubar=no,resizable=yes,scrollable=no", true); } window.addSelectedOrganisationsIns = function(Organisations) { applyFilterByOrganisationsIns(Organisations);} </script> <apex:form > <apex:actionfunction name="applyFilterByOrganisationsIns" action="{!applyFilterByOrganisationsIns}" rerender="isorganisation,organisation" status="asLoadingSelectedOrganisations"> <apex:param name="selectedOrganisationsStr" value="" assignto="{!selectedOrganisationsStr}" /> </apex:actionfunction> <apex:pageBlockSectionItem > <apex:outputLabel value="Organisation" for="organisation"/> <apex:actionRegion id="isorganisation" > <apex:inputfield value="{!rep.AccountID__c}" id="organisation" required="true" onclick="openOrganisationDialog()"> </apex:inputfield> </apex:actionRegion> </apex:pageBlockSectionItem>
Controller:
public class CtrlCallHospInsert { public Boolean booleanValue {get;set;} public CallReportHosp__c rep {get; set;} public Set<Id> selectedOrganisationsIds { get; set; } public String selectedOrganisationsStr { get; set; } private ApexPages.StandardController controller { get; set; } public CtrlCallHospInsert(ApexPages.StandardController controller) { this.controller = controller; this.rep = (CallReportHosp__c)controller.getRecord(); this.booleanValue=false; System.debug(' bool= '+booleanValue); SelectService(); } public void applyFilterByOrganisationsIns() { system.debug('apply filter by org'); this.selectedOrganisationsIds = new Set<Id>(); if(String.isBlank(this.selectedOrganisationsStr) || this.selectedOrganisationsStr == '[]') { return; } String[] OrganisationsIds = this.selectedOrganisationsStr.remove('[').remove(']').remove(' ').split(','); for(String s : OrganisationsIds) { if(!String.isBlank(s)) { System.debug(' org= '+s ); rep.AccountID__c=s; } } this.selectedOrganisationsStr = null; } public List<Account> getSelectedOrganisations() { Account[] Organisations = [SELECT Name FROM Account WHERE Id IN :this.selectedOrganisationsIds ORDER BY Name]; return Organisations; } public PageReference save(){ try { insert rep; }catch (Exception e){ ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, '"Something went wrong !"')); } PageReference pageRef = Page.CallsHospList; pageRef.setRedirect(true); return pageRef; } public void ChangeField() { } public PageReference cancel() { PageReference pageRef = Page.CallsHospList; pageRef.setRedirect(true); return pageRef; } }So, when i click on field rep.AccountID__c the page named AccountsListforHosp open. Then I select organisation name and page AccountsListforHosp closed. After that I waiting page CallsHospInsert is updating by using method applyFilterByOrganisationsIns(), but method doesn't work.
That code of page AccountsListforHosp :
<apex:column rendered="{!Not(ListCalls)}"> <apex:commandLink action="{!updateSelectedAccountsSet}" onclick="updateSelectedAccountsIns(); return false;" value="{!res.record.Name}" /> </apex:column> ....... <apex:actionfunction name="updateSelectedAccountsIns" action="{!updateSelectedAccountsSet}" oncomplete="addSelectedOrganisationsIns();" rerender="pnlSearchResults"> <apex:param name="bParam" value="{!record.id}" assignTo="{!ArecordId}"/> </apex:actionfunction> <script type="text/javascript"> function addSelectedOrganisations() { var searchContext = "{!searchContext}"; var parentWindow = top.parent.window; if(searchContext === "brick") { parentWindow.opener.addSelectedBricks("{!selectedRecords}"); } else { if (searchContext === "pharma_chain") { parentWindow.opener.addSelectedOrganisations("{!selectedRecords}");} else {parentWindow.opener.addSelectedParents("{!selectedRecords}");} } parentWindow.close(); } function addSelectedOrganisationsIns() { var searchContext = "{!searchContext}"; var parentWindow = top.parent.window; if (searchContext === "pharma_chain") { parentWindow.opener.addSelectedOrganisationsIns("{!selectedRecords}");} parentWindow.close(); } </script>And I caused this page with context noList ( Not(ListCalls) = true).
So, why method applyFilterByOrganisationsIns() doesn't starting?
P.S.
Please sorry for my bad English.