• Matt Eck 15
  • NEWBIE
  • 0 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 3
    Replies
Hey All,
I am currently hitting an issue editing a FeedComment as it is inserted. What I would like to do is append an @ mention to the comment so the Case Owner will be alerted. We have a support portal and we can not rely on customers to use the @ mention functionality but without this, the support team is not being alerted that a new comment has been added.

Here is my current trigger handler:
public class FeedCommentTriggerHandler {
    public static void appendAlert(List<FeedComment> comments){
        Map<Id,Case> caseMap = new Map<Id, Case>();
        for(FeedComment comment : comments){
            if(comment.ParentId.getSObjectType().getDescribe().getName() == 'Case'){
                caseMap.put(comment.ParentId, new Case());
            }
        }

        if(!caseMap.isEmpty()){
            caseMap = new Map<Id, Case>([SELECT Id, OwnerId, Owner.Name FROM Case WHERE Id IN :caseMap.keySet()]);

            for(FeedComment comment : comments){
                if(caseMap.containsKey(comment.ParentId)){
                    comment.CommentBody += ('\n@' + caseMap.get(comment.ParentId).Owner.Name);
                }
            }
        }
    }
}

Currentlythis "works" to add an @ mention by adding literally "@<OwnerId.Name>" but this is just plain text and not actually notifying the owner.

I have found several articles stating I need to utilize the Connect API such as this one: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/connectapi_examples_post_comment_feed_element_2.htm

However, all the articles I find are stating how to create a net new comment with an @mention but I want to append an @mention to an existing comment as it comes in. Is this possible or am I not approaching this the correct way?
Hey All,
Is it possible to display a toast message using ShowToastEvent in LWC for less than 3 seconds? Three seconds seems too long, but it looks like the only options may be dismissable, pester, and sticky. Thank you for the help in advance!
Hey all,
I am currently trying out Lighting Web Components and have been stuck on the same issue for a while now. I have a Wrapper class (progWrap) with a list of another Wrapper class (progList) as one of it's attributes. I want to sort that list using an attribute from the wapper class making up progList.

To do so I want to use JS .sort and my current sort method looks like this:
let sortList = this.progWrap.progList.slice();
        console.log(JSON.stringify(sortList));
        sortList.sort(function(a,b){
            if(a.programCountry < b.programCountry){
                return -1;
            }
            if(a.programCountry > b.programCountry){
                return 1;
            }
            return 0
        });
        console.log(JSON.stringify(sortList));
I know this sort is working correctly because I checked it using the console.logs.
All I want to do is assign this.progWrap.progList = sortList; but everytime I do I get this error:

['set' on proxy: trap returned falsish for property 'progList']

What does this mean, and how can I prevent this?
 
Hello All,
I am currently looking into Lightning Web Components and have hit a wall. I have a wire decorator that calls to an apex function returning a wrapper class. This Wrapper actually contains a Wrapper that contains a Wrapper, so it is nested 3 times. What I would like to do is updated a field on the 3rd Wrapper when a checkbox is checked or unchecked.

important HTML:
<template if:true={progWrap.progList}>
                    <template for:each = {progWrap.progList} for:item = "prog">
                        <tr key = {prog.progAuth.Id} >
                            <td>{prog.programName}</td>
                            <td>{prog.programCountry}</td>
                            <template if:true={prog.checkboxes}>
                                <template for:each={prog.checkboxes} for:item="checkbox">
                                    <template if:true={checkbox.visible}>
                                        <td key={checkbox.section}><lightning-input type="checkbox" value={checkbox.section} checked={checkbox.checked} data-prog-name ={prog.programName} onchange={handleCheckboxChange}></lightning-input></td>
                                    </template>
                                    <template if:false={checkbox.visible}>
                                        <td key={checkbox.section}>-</td>
                                    </template>
                                </template>
                            </template>
                        </tr>
                    </template>
                </template>

JS:
import { LightningElement, api, track, wire } from 'lwc';
import initWrapper from '@salesforce/apex/programAuthComponentController.initWrapper';

export default class programAuthWebComponent extends LightningElement {
    
    @api recordId;
    @track progWrap;
    @track error;
    @wire(initWrapper, {accId: '$recordId'}) 
    progWrapper({
        error,
        data
    }){
        if(data){
            this.progWrap = data;
        }
        else{
            this.error = error;
        }
    }

    handleCheckboxChange(event){
        var checkValue = event.target.value;
        var checkValue2;
        var programName = event.target.dataset.progName;

        if(checkValue === 'Spring / Semester 1'){
            checkValue = 'Spring';
            checkValue2 = 'Semester 1';
        }
        else if(checkValue === 'Fall / Semester 2'){
            checkValue = 'Fall';
            checkValue2 = 'Semester 2';
        }

        for(let i = 0; i < this.progWrap.progList.length; i++){
            if(this.progWrap.progList[i].programName === programName){
                //console.log(this.progWrap.progList[i].checkboxes.length);
                for(let j = 0; j < this.progWrap.progList[i].checkboxes.length; j++){
                    if(this.progWrap.progList[i].checkboxes[j].section === checkValue){
                        console.log(JSON.stringify(this.progWrap.progList[i].checkboxes[j]));
                        this.progWrap.progList[i].checkboxes[j].checked = true;
                    }
                }
            }
        }
    }
}

Apex Wrappers:
public class wrapperClass{
        @AuraEnabled public List<progAuthWrapperClass> progList{get;set;}
        @AuraEnabled public List<String> sections{get;set;}
        @AuraEnabled public List<String> modifiedSections{get;set;}
    }

    public class progAuthWrapperClass{
        @AuraEnabled public String programName {get;set;}
        @AuraEnabled public String programCountry {get;set;}
        @AuraEnabled public Program_Authorization__c progAuth {get;set;}
        @AuraEnabled public Boolean updated {get;set;}
        @AuraEnabled public Set<String> avaliableTerms {get;set;}
        @AuraEnabled public List<checkboxWrapper> checkboxes {get;set;}
    }

    public class checkboxWrapper{
        @AuraEnabled public Boolean visible {get;set;}
        @AuraEnabled public Boolean checked {get;set;}
        @AuraEnabled public String section {get;set;}
    }

    @AuraEnabled(cacheable=true)
    public static wrapperClass initWrapper(Id accId){
        wrapperClass returnWrapper = new wrapperClass();
        returnWrapper.sections = returnSections();
        returnWrapper.modifiedSections = returnModifiedSections(returnWrapper.sections);
        returnWrapper.progList = returnPrograms(accId);
        return returnWrapper;
    }
The UI Looks like this currently (this is a work in progress):

User-added image

Essentially what we want to have happen is when on of these checkboxes is clicked, it updates the checked boolean on the checkboxWrapper. I thought I could update the this.progWrap.progList[i].checkboxes[j].checked in my for loop but everytime I do this I get an error from salesforce that says this: ['set' on proxy: trap returned falsish for property 'checked'].

This may be too much information but really my question is, what does that mean? and How do I actually update this field?

Thank you all for any help!
Hey All,
I am currently hitting an issue editing a FeedComment as it is inserted. What I would like to do is append an @ mention to the comment so the Case Owner will be alerted. We have a support portal and we can not rely on customers to use the @ mention functionality but without this, the support team is not being alerted that a new comment has been added.

Here is my current trigger handler:
public class FeedCommentTriggerHandler {
    public static void appendAlert(List<FeedComment> comments){
        Map<Id,Case> caseMap = new Map<Id, Case>();
        for(FeedComment comment : comments){
            if(comment.ParentId.getSObjectType().getDescribe().getName() == 'Case'){
                caseMap.put(comment.ParentId, new Case());
            }
        }

        if(!caseMap.isEmpty()){
            caseMap = new Map<Id, Case>([SELECT Id, OwnerId, Owner.Name FROM Case WHERE Id IN :caseMap.keySet()]);

            for(FeedComment comment : comments){
                if(caseMap.containsKey(comment.ParentId)){
                    comment.CommentBody += ('\n@' + caseMap.get(comment.ParentId).Owner.Name);
                }
            }
        }
    }
}

Currentlythis "works" to add an @ mention by adding literally "@<OwnerId.Name>" but this is just plain text and not actually notifying the owner.

I have found several articles stating I need to utilize the Connect API such as this one: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/connectapi_examples_post_comment_feed_element_2.htm

However, all the articles I find are stating how to create a net new comment with an @mention but I want to append an @mention to an existing comment as it comes in. Is this possible or am I not approaching this the correct way?

I am writing a SOQL in DataLoader to pull all Contacts created in the last hour.  However, I cannot find any date function to use.  I tried CREATEDDATE >=LAST_N_DAYS:0.0417, but it only accepts integers.  Is there a function I can use?

 

Thanks in advance
PS Sorry if I put this in the wrong topic group.  I was not sure where it would go.  This is my first posted question.

Hey all,
I am currently trying out Lighting Web Components and have been stuck on the same issue for a while now. I have a Wrapper class (progWrap) with a list of another Wrapper class (progList) as one of it's attributes. I want to sort that list using an attribute from the wapper class making up progList.

To do so I want to use JS .sort and my current sort method looks like this:
let sortList = this.progWrap.progList.slice();
        console.log(JSON.stringify(sortList));
        sortList.sort(function(a,b){
            if(a.programCountry < b.programCountry){
                return -1;
            }
            if(a.programCountry > b.programCountry){
                return 1;
            }
            return 0
        });
        console.log(JSON.stringify(sortList));
I know this sort is working correctly because I checked it using the console.logs.
All I want to do is assign this.progWrap.progList = sortList; but everytime I do I get this error:

['set' on proxy: trap returned falsish for property 'progList']

What does this mean, and how can I prevent this?
 
Hello All,
I am currently looking into Lightning Web Components and have hit a wall. I have a wire decorator that calls to an apex function returning a wrapper class. This Wrapper actually contains a Wrapper that contains a Wrapper, so it is nested 3 times. What I would like to do is updated a field on the 3rd Wrapper when a checkbox is checked or unchecked.

important HTML:
<template if:true={progWrap.progList}>
                    <template for:each = {progWrap.progList} for:item = "prog">
                        <tr key = {prog.progAuth.Id} >
                            <td>{prog.programName}</td>
                            <td>{prog.programCountry}</td>
                            <template if:true={prog.checkboxes}>
                                <template for:each={prog.checkboxes} for:item="checkbox">
                                    <template if:true={checkbox.visible}>
                                        <td key={checkbox.section}><lightning-input type="checkbox" value={checkbox.section} checked={checkbox.checked} data-prog-name ={prog.programName} onchange={handleCheckboxChange}></lightning-input></td>
                                    </template>
                                    <template if:false={checkbox.visible}>
                                        <td key={checkbox.section}>-</td>
                                    </template>
                                </template>
                            </template>
                        </tr>
                    </template>
                </template>

JS:
import { LightningElement, api, track, wire } from 'lwc';
import initWrapper from '@salesforce/apex/programAuthComponentController.initWrapper';

export default class programAuthWebComponent extends LightningElement {
    
    @api recordId;
    @track progWrap;
    @track error;
    @wire(initWrapper, {accId: '$recordId'}) 
    progWrapper({
        error,
        data
    }){
        if(data){
            this.progWrap = data;
        }
        else{
            this.error = error;
        }
    }

    handleCheckboxChange(event){
        var checkValue = event.target.value;
        var checkValue2;
        var programName = event.target.dataset.progName;

        if(checkValue === 'Spring / Semester 1'){
            checkValue = 'Spring';
            checkValue2 = 'Semester 1';
        }
        else if(checkValue === 'Fall / Semester 2'){
            checkValue = 'Fall';
            checkValue2 = 'Semester 2';
        }

        for(let i = 0; i < this.progWrap.progList.length; i++){
            if(this.progWrap.progList[i].programName === programName){
                //console.log(this.progWrap.progList[i].checkboxes.length);
                for(let j = 0; j < this.progWrap.progList[i].checkboxes.length; j++){
                    if(this.progWrap.progList[i].checkboxes[j].section === checkValue){
                        console.log(JSON.stringify(this.progWrap.progList[i].checkboxes[j]));
                        this.progWrap.progList[i].checkboxes[j].checked = true;
                    }
                }
            }
        }
    }
}

Apex Wrappers:
public class wrapperClass{
        @AuraEnabled public List<progAuthWrapperClass> progList{get;set;}
        @AuraEnabled public List<String> sections{get;set;}
        @AuraEnabled public List<String> modifiedSections{get;set;}
    }

    public class progAuthWrapperClass{
        @AuraEnabled public String programName {get;set;}
        @AuraEnabled public String programCountry {get;set;}
        @AuraEnabled public Program_Authorization__c progAuth {get;set;}
        @AuraEnabled public Boolean updated {get;set;}
        @AuraEnabled public Set<String> avaliableTerms {get;set;}
        @AuraEnabled public List<checkboxWrapper> checkboxes {get;set;}
    }

    public class checkboxWrapper{
        @AuraEnabled public Boolean visible {get;set;}
        @AuraEnabled public Boolean checked {get;set;}
        @AuraEnabled public String section {get;set;}
    }

    @AuraEnabled(cacheable=true)
    public static wrapperClass initWrapper(Id accId){
        wrapperClass returnWrapper = new wrapperClass();
        returnWrapper.sections = returnSections();
        returnWrapper.modifiedSections = returnModifiedSections(returnWrapper.sections);
        returnWrapper.progList = returnPrograms(accId);
        return returnWrapper;
    }
The UI Looks like this currently (this is a work in progress):

User-added image

Essentially what we want to have happen is when on of these checkboxes is clicked, it updates the checked boolean on the checkboxWrapper. I thought I could update the this.progWrap.progList[i].checkboxes[j].checked in my for loop but everytime I do this I get an error from salesforce that says this: ['set' on proxy: trap returned falsish for property 'checked'].

This may be too much information but really my question is, what does that mean? and How do I actually update this field?

Thank you all for any help!