My lightning component is intermittently getting this error message in my QA sandbox. what is property O? I have used dualListbox, when the first value is selected, there is no issue, when the second one selected, the error starts happening. Sometimes happened sometimes didn't.
----- Aura Component ---
<aura:component controller="RetrieveProjectNotesController" implements="force:lightningQuickAction,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes" access="global">
<aura:attribute name="lstProject" type="RetrieveProjectNotesController.ProjectWrapper[]" />
<aura:attribute name="mapNotes" type="object"/>
<!--aura:attribute name="lstProjectEpic" type ="Project_Epic__c[]"/-->
<aura:attribute name="userProfile" type="String"/>
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
<aura:attribute name="options" type="List" default="[]"/>
<aura:attribute name="values" type="List" default="[]"/>
<lightning:dualListbox name="multipleOptions"
label="Project Departments"
sourceLabel="Available"
selectedLabel="Selected"
options="{!v.options}"
value="{!v.values}"
onchange="{! c.handleChange }"
fieldLevelHelp="Select department(s) to view the list of projects associated with the selected department(s)"
size="2"/>
<div class="c-container">
<aura:Iteration items="{!v.lstProject}" var="item">
<lightning:layout multipleRows="true">
<lightning:layoutitem padding="around-small" size="12">
<lightning:card >
<aura:set attribute="title" >
<aura:unescapedHtml value="{!item.project.Priority_Color__c}" ></aura:unescapedHtml>
<a href="{!'/'+ item.project.Id}" >
{!item.project.SFDC_Project_Name__c} </a>
</aura:set>
</lightning:card>
</lightning:layoutitem>
<lightning:layoutItem padding="around-small" size="6">
<div class="page-section page-main">
<dl class="slds-dl_horizontal">
<dt class="slds-dl_horizontal__label">
<p class="slds-truncate" title="Description">Epic:</p>
</dt>
<dd class="slds-dl_horizontal__detail slds-tile__meta">
<p> {!item.project.Project_Epic__r.Name}</p>
</dd>
<dt class="slds-dl_horizontal__label">
<p class="slds-truncate" title="Description">Description:</p>
</dt>
<dd class="slds-dl_horizontal__detail slds-tile__meta">
<p> {!item.project.SFDC_Status_Description__c}</p>
</dd>
<dt class="slds-dl_horizontal__label">
<p class="slds-truncate" title="Status">Status:</p>
</dt>
<dd class="slds-dl_horizontal__detail slds-tile__meta">
<p> {!item.project.SFDC_Project_Status__c}</p>
</dd>
<dt class="slds-dl_horizontal__label">
<p class="slds-truncate" title="StartDate">Start Date:</p>
</dt>
<dd class="slds-dl_horizontal__detail slds-tile__meta">
<lightning:formattedDateTime value="{!item.project.SFDC_Project_Start_Date__c}" year="2-digit" month="2-digit" day="2-digit" hour="2-digit" minute="2-digit" ></lightning:formattedDateTime>
</dd>
<dt class="slds-dl_horizontal__label">
<p class="slds-truncate" title="StartDate">Project Epic:</p>
</dt>
<dd class="slds-dl_horizontal__detail slds-tile__meta">
<p> {!item.project.Project_Epic__r.Name}</p>
</dd>
</dl>
<div class="page-note">
<b>Related Registrars</b>
<aura:if isTrue="{!not(empty(item.accounts))}">
<aura:Iteration items="{!item.accounts}" var="acctP" >
<li>
{!acctP.Account__r.Name} </li>
</aura:Iteration>
<aura:set attribute="else">
<p>There are no project notes for this project.</p>
</aura:set>
</aura:if>
</div>
<div class="page-note" >
<div class="page-header">
<b>Project Related Notes</b>
</div>
<aura:if isTrue="{!not(empty(item.notes))}">
<aura:Iteration items="{!item.notes}" var="noteP" >
<c:DisplayNoteItem item="{!noteP}" />
</aura:Iteration>
<aura:set attribute="else">
<p>There are no project notes for this project.</p>
</aura:set>
</aura:if>
</div>
</div>
</lightning:layoutItem>
<lightning:LayoutItem padding="around-small" size="6">
<div class="page-section page-main">
<div class="page-header">
<b>Project Related Tasks</b>
</div >
<aura:if isTrue="{!not(empty(item.tasks))}">
<aura:Iteration items="{!item.tasks}" var ="task">
<div class="page-task ">
<li>Task Subject: <a href="{!'/'+ task.task.Id}" >{!task.task.Subject}</a></li>
</div>
<dl class="slds-dl_horizontal">
<dt class="slds-dl_horizontal__label">
<p class="slds-truncate" title="Comment">Comment:</p>
</dt>
<dd class="slds-dl_horizontal__detail slds-tile__meta">
<p> {!task.task.Description}</p>
</dd>
<dt class="slds-dl_horizontal__label">
<p class="slds-truncate" title="Diposition">Diposition:</p>
</dt>
<dd class="slds-dl_horizontal__detail slds-tile__meta">
<p> {!task.task.Status}</p>
</dd>
<dt class="slds-dl_horizontal__label">
<p class="slds-truncate" title="Priority">Priority:</p>
</dt>
<dd class="slds-dl_horizontal__detail slds-tile__meta">
<aura:unescapedHtml value="{!task.task.Task_Priority_Color__c}" ></aura:unescapedHtml>
</dd>
<dt class="slds-dl_horizontal__label">
<p class="slds-truncate" title="DueDate">Due Date:</p>
</dt>
<dd class="slds-dl_horizontal__detail slds-tile__meta">
<p> <lightning:formattedDateTime value="{!task.task.ActivityDate}" year="2-digit" month="2-digit" day="2-digit" hour="2-digit" minute="2-digit" ></lightning:formattedDateTime></p>
</dd>
</dl>
<div class="page-note slds-border_bottom" >
<div class="page-header">
<b>Task Notes</b>
</div>
<aura:iteration items="{!task.notes}" var="noteT">
<c:DisplayNoteItem item="{!noteT}"></c:DisplayNoteItem>
</aura:iteration>
</div>
</aura:Iteration>
<aura:set attribute="else">
<p>There are no tasks associated with this project</p>
</aura:set>
</aura:if>
</div>
</lightning:LayoutItem>
</lightning:layout>
</aura:Iteration>
</div>
</aura:component>
---- Controller.js ----
({
doInit : function(component, event, helper) {
helper.getProjectAndTasks(component, event, helper);
// helper.getNotes (component, event, helper);
// helper.getProjectEpics(component, event, helper);
// helper.getNewEpicValue (component,event,helper);
helper.getUserProfile(component, event, helper);
helper.getDepartments(component, event, helper);
},
handleChange: function (component, event, helper) {
// This will contain an array of the "value" attribute of the selected options
var selectedOptionValue = event.getParam("value");
// alert("Option selected with value: '" + selectedOptionValue.toString() + "'");
console.log("Option selected with value: '" + selectedOptionValue.toString() + "'");
helper.getProjectAndTasks(component, event, helper);
}
})
---- Helper.js ---
({
getProjectAndTasks : function(component, event, helper) {
var selectedOptionValue = event.getParam("value");
var action = component.get('c.getProjectWithTaskAndNotesByEpic');
action.setParams({ "Departments" : selectedOptionValue });
action.setCallback(this,function(response)
{
var state= response.getState();
if(state == "SUCCESS")
{
console.log('reponse : ' + response.getReturnValue());
var proj = response.getReturnValue();
component.set('v.lstProject',response.getReturnValue());
}
});
$A.enqueueAction(action);
},
getDepartments : function (component, event, helper){
var action = component.get('c.getDepartments');
action.setCallback(this,function(response)
{
var state= response.getState();
if(state == "SUCCESS")
{
var departments =response.getReturnValue();
console.log('Departments are : ' + departments);
var items =[];
for(var d in departments)
{
var item = {
"label": departments[d] ,
"value": departments[d]
};
items.push(item);
}
component.set('v.options',items);
}
});
$A.enqueueAction(action);
},
getProjectEpics : function (component, event, helper){
var action = component.get('c.getProjectEpics');
action.setCallback(this,function(response)
{
var state= response.getState();
if(state == "SUCCESS")
{
console.log('reponse : ' + response.getReturnValue());
var epic = response.getReturnValue();
component.set('v.lstProjectEpic',response.getReturnValue());
}
});
$A.enqueueAction(action);
} ,
getUserProfile : function (component, event, helper){
var action = component.get('c.fetchUserProfile');
action.setCallback(this,function(response)
{
var state= response.getState();
if(state == "SUCCESS")
{
console.log('reponse : ' + response.getReturnValue());
component.set('v.userProfile',response.getReturnValue());
}
});
$A.enqueueAction(action);
}
})
----- apex controller ----
*** Apex class **
public with sharing class RetrieveProjectNotesController
{
private static List<ID> myLstLinkedEntityID = new list<Id>();
private static List<sfdc_project__c> myLstProject = new List<sfdc_project__c> ();
private static List<ContentDocumentLink> myContentDocLink= new List<ContentDocumentLink>();
private static List<project_department__c> pDepartments = new List<project_department__c>();
public class ProjectWrapper {
@AuraEnabled
public sfdc_project__c project;
@AuraEnabled
public List<TaskWrapper>tasks;
@AuraEnabled
public List<ContentDocumentLink> notes = new List<ContentDocumentLink>();
@AuraEnabled
public List<Project_Assignment__c> accounts = new List<project_assignment__c>();
@TestVisible
ProjectWrapper(sfdc_project__c project, List<TaskWrapper> tasks){
this.project = project;
this.tasks = tasks;
}
}
Public class TaskWrapper{
@AuraEnabled
public Task task;
@AuraEnabled
public List<ContentDocumentLink> notes = new List<ContentDocumentLink>();
@TestVisible
TaskWrapper(Task task){
this.task = task;
}
}
@AuraEnabled
public static List<ProjectWrapper> getProjectWithTaskAndNotesByEpic(List<String> Departments ){
system.debug('Department Selected: ' + Departments + ' szie: ' + Departments.size() );
// if(projectIDs.size()>0 && projectIDs !=null)
//
if (Departments.size() >0 && Departments != null){
myLstProject = [Select id, sfdc_project_name__c,SFDC_Status_Description__c, SFDC_Project_Start_Date__c, SFDC_Project_Status__c, Project_Epic__r.name,
Priority__c,priority_Color__c,
(select id, owner.name,subject, priority, status,description,activityDate , Task_Priority_Color__c from tasks) from sfdc_project__c
where project_department__c in:Departments and sfdc_project_status__c not in ('Completed','Cancelled')
order by createddate desc
] ;
}
else
myLstProject = [Select id, sfdc_project_name__c,SFDC_Status_Description__c, SFDC_Project_Start_Date__c, SFDC_Project_Status__c, Project_Epic__r.name,
Priority__c,priority_Color__c,
(select id, owner.name,subject, priority, status,description,activityDate , Task_Priority_Color__c from tasks) from sfdc_project__c
where sfdc_project_status__c not in ('Completed','Cancelled')
order by createddate desc
] ;
system.debug ('# of projects returned:' + myLstProject.size()) ;
//gather all LinkedEntityId for ContentDocumentLink Query
List<id> linkedEntityIdList = new List<Id>();
List<ContentDocumentLink>contentDocumentLinkList = new List<ContentDocumentLink>();
//create maps for future wrapper
Map<ID, ProjectWrapper> idVsProjectWrapper = new Map<ID, ProjectWrapper> ();
Map<ID, TaskWrapper> idVsTaskWrapper = new Map<ID, TaskWrapper> ();
for(sfdc_project__c pj: myLstProject){
linkedEntityIdList.add(pj.ID);
List<TaskWrapper> taskWrapperList = new List<TaskWrapper>();
for (Task tsk: pj.tasks){
linkedEntityIdList.add(tsk.ID);
TaskWrapper tw = new TaskWrapper (tsk);
taskWrapperList.add(tw);
idVsTaskWrapper.put(tsk.ID, tw);
}
idVsProjectWrapper.put(pj.id, new ProjectWrapper(pj,taskWrapperList));
}
//Query ContentDocumentLink
//
if(linkedEntityIdList.size()>0){
contentDocumentLinkList =[select contentdocumentlink.id, contentdocument.title, contentdocument.description ,linkedentity.name, linkedentity.id , contentdocument.CreatedDate ,contentdocument.CreatedBy.Name
from contentdocumentlink where linkedentityid in: linkedEntityIdList
and sharetype='V' and contentdocument.filetype='SNOTE'];
}
system.debug('# of Notes: ' + contentDocumentLinklist.size());
for(ContentDocumentLink cdl: contentDocumentLinklist){
if(cdl.linkedEntityid.getsobjecttype().getDescribe().getName() == 'sfdc_project__c')
{
system.debug('Project entity Name:' + cdl.linkedEntity.Name + ' Note Title: ' + cdl.ContentDocument.Title );
idVsProjectWrapper.get(cdl.linkedentityid).notes.add(cdl);
}
else
{
idVsTaskWrapper.get(cdl.linkedentityid).notes.add(cdl);
system.debug('Task entity Name:' + cdl.linkedEntity.Name + ' Note Title: ' + cdl.ContentDocument.Title );
}
}
//query the project_assignment__c
List<Project_Assignment__c> accts = [select id, project__r.id, project__r.sfdc_project_name__c, account__r.name, account__c from project_assignment__c where project__r.id in: linkedEntityIdList];
for (Project_Assignment__c pa : accts){
Id pid = pa.Project__c;
system.debug('project id: ' + pID);
idVsProjectWrapper.get(pid).accounts.add(pa);
system.debug('project account size: ' + idVsProjectWrapper.get(pid).accounts[0].Account__r.Name);
}
return idVsProjectWrapper.values();
}
/* @AuraEnabled
public static List<Project_Epic__c> getProjectEpics()
{
return [select ID, Name from project_epic__c];
}
*/
@AuraEnabled
public static String fetchUserProfile(){
Profile p = [select id,Name from profile
Where id =: userInfo.getProfileId()];
system.debug('Profile Name:' + p.Name);
return p.Name;
}
@AuraEnabled
public static List<String> getDepartments(){
List<String> departments = new List<String>();
/* departments = [select name from department__c ];
System.debug(departments.size());
List<String> deptName = new List<String>();
for(department__c d : departments){
deptName.add(d.Name);
}*/
departments.add('Marketing');
departments.add('CS/Marketing');
departments.add('Channel Services');
departments.add('Registry Services');
return departments ;
}
}
getProjectWithTaskAndNotesByEpic
apex method? – Pranay Jaiswal Aug 13 '19 at 13:37