• Krzysztof Kot
  • NEWBIE
  • 5 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 1
    Replies
Hey, I have a list of records displayed (in my case a list of surveys). I want when the user clicks on the link (it can be a button) the system opens the survey record as subTab with the simultaneous update of one field (reading flags). Unfortunately, I can not pin this down and the value of the parameter (surveyId) is not passed to the Apex class method.

visualforce page:
<apex:page standardcontroller="Case" standardStylesheets="false" lightningStylesheets="true" docType="html-5.0" extensions="SurveyController">
<apex:slds />
<style type="text/css">
.y{background-color: #ffff99}
.g{background-color: #99ff99}
</style>
<apex:includeScript value="/support/console/44.0/integration.js" />
<apex:includeScript value="/support/api/44.0/interaction.js" />
<script language="javascript" type="text/javascript">
function openRecordPage(){
    saveSurveyId('ss');
    chageSurveyFlag();
}
</script>
<apex:form id="form2">       
   <apex:pageBlock id="pageblock" >
            <apex:actionFunction action="{!chageSurveyFlag}" name="chageSurveyFlag">
            <apex:param id="myParam" name="myParam" value="hoho" assignTo="{!surveyId}"/>
            </apex:actionFunction>
            <apex:pageblocktable value="{!surveyTaker}" var="survey" id="blocktable">
              <apex:column value="{!survey.CreatedDate}" headerValue="Data" styleClass="{!if(survey.IsRead__c,"g","y")}"/>
              <apex:column value="{!survey.Survey__c}" headerValue="Nazwa ankiety" styleClass="{!if(survey.IsRead__c,"g","y")}"/>
              <apex:column styleClass="{!if(survey.IsRead__c,"g","y")}" id="column">
              <apex:inputHidden value="{!survey.Id}" id="hiddenField"/>
              <apex:outputLink value="/{!survey.Id}" onclick="openRecordPage(); return false;">Szczegóły
              </apex:outputLink>
              </apex:column>
            </apex:pageblocktable>
  </apex:pageBlock>
   </apex:form>
</apex:page>

apex class controller:
public with sharing class SurveyController {
    private final Case c;
    private ApexPages.StandardController controller {get; set;}
    public List<SurveyTaker__c> surveysForCase {get; private set;}
    public List<SurveyTaker__c> surveyTaker  {get; private set;}
    public String caseId {get; set;}
    public String surveyId {get; set;}
        
	public SurveyController(ApexPages.StandardController controller) {
        this.controller = controller;
        this.c = (Case) controller.getRecord();
        searchSurveyTaker();
    }
    public void searchSurveyTaker () {
		surveyTaker = [Select Survey__c, Case__c, CreatedDate, IsRead__c, Id FROM SurveyTaker__c WHERE Case__c =: c.Id ORDER BY CreatedDate DESC]; 
    }
    public PageReference chageSurveyFlag() {
        System.debug('survey: '+surveyId);
        SurveyTaker__c s = new SurveyTaker__c();
        s.id = surveyId;
        s.isRead__c = true;
        update s;
        return null;
    }
    
}


 
I have created a component of Events for Omni-Channel (lightning: omniChannelStatusChanged) and when adding it to Utility Items as Background or as normal it does not work. I do not know what the problem may be. I took the code from the documentation. I tested other events but also without results.

component:

<aura:component implements="lightning:backgroundUtilityItem,force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId" access="global" >
    <lightning:omniToolkitAPI aura:id="omniToolkit" />  
    <aura:handler event="lightning:omniChannelStatusChanged" action="{! c.onStatusChanged }"/>
</aura:component>

js controller:

({
    onStatusChanged : function(component, event, helper) {
        console.log("Status changed.");
        var statusId = event.getParam('statusId');
        var channels = event.getParam('channels');
        var statusName = event.getParam('statusName');
        var statusApiName = event.getParam('statusApiName');
        console.log(statusId);
        console.log(channels);
        console.log(statusName);
        console.log(statusApiName);
    }, 
})
Hi Guys,
I have the following code and want a test method to cover the for loop.Please give the test method so as to cover the for loop

Public class CreateDummyAccount{

Public static void dummyMethod(List<Account> accList){
try{
    if(accList != NULL && !accList.isEmpty()){
        List<Contact> conList = new List<Contact>();
        for(Account acc : accList){
        conList.add(new  Contact(LastName = 'Larry'))
        }
        
        insert conList;
    }
    
    }

}

}


Thanks,
Abhilash