• JohnDurai
  • NEWBIE
  • 85 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 21
    Questions
  • 11
    Replies
Hi - I have one Lightning web Component built in that i am using a field set. there is one  formula field (formula will retun hyperlink) which i am using in field set. I am referring this field set in my LWC component.

I can able to view the field value in component, but when i click on the link it is not redirecting to the record page and throws (This record is no longer available. Ask your administrator for help.) this message can someone have any idea on this?

User-added image
above highlighed in yellow is the hyperlink formula field i am using in fieldset, but while clicking on that i am seeing the below message.

User-added imagecan someone help me wheather it is code problem or something related to permission issue? Note: It is working when i click from the original record only it is ot working on LWC component.
Hi All - Can someone help me out on key points/updates related to "Enable Enhanced Domains"  and "Securely Access Aura Components" topics  with respect to Summer release 21. Thanks!
Hi - I facing error on one of my components when in controller class wrapper method returned the value as null. If the wrapper has some records then my component is working fine, can someone help me on debugging this?

For Example: my component is related list component, if that related list has records then the component is working fine if the record is null then i facing the error. Below is my code.

Controller Class:
Wrapper  Method:
public with sharing class FinancialAccountListControllerRefresh {
    @AuraEnabled(cacheable=true)
    public static FinancialAccountsWrapper getDescribeFinancialAccounts(String recordId, String recordtypesForFinancialAccounts, String fieldSetForFinancialAccount, String fieldSetForFinancialHolding,Boolean includeInActive,Boolean fullView){
            FinancialAccountsWrapper finAccountWrapper = new FinancialAccountsWrapper();
            finAccountWrapper.financialAccounts=getFinancialAccounts(recordId,recordtypesForFinancialAccounts,fieldSetForFinancialAccount,fieldSetForFinancialHolding,includeInActive,fullView);
            finAccountWrapper.fieldDescribe= getFieldDescribe(fieldSetForFinancialAccount,fieldSetForFinancialHolding);
            finAccountWrapper.financialAccountsCount=getFinancialAccountsCount(recordId,recordtypesForFinancialAccounts,fieldSetForFinancialAccount,fieldSetForFinancialHolding,includeInActive,fullView);
            system.debug('result: ' +finAccountWrapper);    
            return finAccountWrapper; 
    }


wire Method:
  @wire (getDescribeFinancialAccounts, { 
        recordId: '$recordId',
        recordtypesForFinancialAccounts: '$recordtypesForFinancialAccounts',
        fieldSetForFinancialAccount: '$fieldSetForFinancialAccount',
        fieldSetForFinancialHolding: '$fieldSetForFinancialHolding',
        includeInActive:'$includeInActive',
        fullView:'$fullView'
 }) 
    wiredFinancialAccount(result) {
        console.log(result);
        this.refreshaccount= result;
        this.financialAccounts = [];
        if (result.error) {
            this.handleError(result.error);
        } else if (result.data) {
            this.loadFinancialAccountAccess();
            //New Code
            //this.loadFinancialAccountDefaultRecordTypeId();
            var fieldData = JSON.parse(JSON.stringify(result.data));
            if(result.data.fieldDescribe){
            fieldData.fieldDescribe = JSON.parse(result.data.fieldDescribe);
            var obj = JSON.parse(result.data.fieldDescribe);
            this.financialAccountFields = obj.financialAccountFields;
            this.financialHoldingFields = obj.financialHoldingFields;
            //this.loadFinancialAccountsCount();
            //this.loadFinancialAccounts();
            }
if(result.data.financialAccounts){
            this.financialAccounts = this.formatData(result.data.financialAccounts, this.financialAccountFields);
                
                if(this.financialAccounts.length > 0){
                    this.hasAccounts = true;
                } 
                if (result.data.financialAccountsCount==0) {
                    this.countForDisplay = result.data.financialAccountsCount; 
                } 
                else {
                this.countForDisplay = result.data.financialAccountsCount;
                    if(this.countForDisplay > MAX_RESULTS && this.fullView==false){
                    this.countForDisplay = MAX_RESULTS + '+';
                    }
                }       
            }
        }
    }; 
 loadFinancialAccountAccess(){       
        isCreateFinancialAccountAccess({
          recordId: this.recordId
        })
        .then(result => {
            this.showNewButton = result;  
            this.error = undefined;  
        })
        .catch(error => {
            this.error = error;
        });
    }
I am trying to create formulat field inside the flow resource  as below condition.

! (ISBLANK {!$Record.Fieldname}) but getting error on saving. can someone suggest where i am going wrong?

User-added imageThanks!
Can someone assist how to give permissions for content related objects?1.) Contentversion
2.) ContentNote
3.) ContentDocument.
 
I can able to see these objects from backend (Dev console) but at profile level these objects are not visible to give permissons
 
Hi All - I have one lookup field and one text field, i need to create validation rule based on lookup filed, if lookup field has value "ABC"  then text field shoud not be updatable or editable. can someone help me on this. Thanks!
Hi - I have created a LWC component for layout section as below, can someone suggest how this can be used as two column layout.
User-added image Here is my code:

<template>
    <div class={sectionClass}>
        <h3 class="slds-section__title">
            <button class="slds-button slds-section__title-action" onclick={handleClick}>
                <lightning-icon
                    icon-name="utility:switch"
                    class="slds-button__icon slds-button__icon_left slds-section__title-action-icon"
                    size="x-small">
                </lightning-icon>
                     <span class="slds-truncate" title={label}>Notes</span>
              </button>
        </h3>
        <div class="slds-section__content">
            <div class="slds-col slds-p-horizontal_medium">
                <lightning-layout>
                    <lightning-layout-item padding="around-small">
                        <div class="header-column">
                            <p class="field-title" title="Field 1">Address Notes</p>
                       </div>
                    </lightning-layout-item>
                    </lightning-layout>
                </div>
                <div class="slds-col slds-p-horizontal_medium">
                    <lightning-layout>
                        <lightning-layout-item padding="around-small">
                            <div class="header-column">
                                <p class="field-title" title="Field 2">Income Notes</p>
                           </div>
                        </lightning-layout-item>
                        </lightning-layout>
                    </div>
                    <div class="slds-col slds-p-horizontal_medium">
                        <lightning-layout>
                            <lightning-layout-item padding="around-small">
                                <div class="header-column">
                                    <p class="field-title" title="Field 3">Health Notes</p>
                               </div>
                            </lightning-layout-item>
                            </lightning-layout>
                        </div>
                        <div class="slds-col slds-p-horizontal_medium">
                            <lightning-layout>
                                <lightning-layout-item padding="around-small">
                                    <div class="header-column">
                                        <p class="field-title" title="Field 4">Expense Notes</p>
                                   </div>
                                </lightning-layout-item>
                                </lightning-layout>
                            </div>
        </div>
    </div>
</template>
Hi - can someone suggest how to create new section using LWC under details secion ?
Hi - Need help on creating custom related list using Lightning web components for an object in details tab section. Example as below and the notes button has been created already and need to use in this new component. can someone help on this. Thanks! 
User-added image
Hi - can someone help me on writting test class for the below code:

public class IncomeRecordService {
    public void processFinancialAccountRecordsForIncome(List<SObject> changedRecords, List<SObject> changedOldRecords)
    {
        Set<Id> financeAccountId = new Set<Id>();
        if(changedRecords != null){
            For (FinServ__FinancialAccount__c financialAccountRec: (List<FinServ__FinancialAccount__c>) changedRecords){
                financeAccountId.add(financialAccountRec.Id);
            }
            if(financeAccountId.size()>0){
                maintainIncomeRecords(financeAccountId); 
            }
        }
    }
    public void processFinancialAccountRoleRecordsForIncome(List<SObject> changedRecords, List<SObject> changedOldRecords){
        Set<Id> financeAccountIds = new Set<Id>();
        Set<Id> financeAccountRoleIds = new Set<Id>();
        For (FinServ__FinancialAccountRole__c finAccountRoleRec: (List<FinServ__FinancialAccountRole__c>) changedRecords){
            financeAccountRoleIds.add(finAccountRoleRec.Id);
        }
        // Id FinancialAccountRoleRecordTypeId = Schema.SObjectType.FinServ__FinancialAccountRole__c.getRecordTypeInfosByDeveloperName().get(FinancialAccountConstants.FAR_OWNER_ROLE).getRecordTypeId();   
        String RecordTypeName = FinancialAccountConstants.FAR_OWNER_ROLE;
        Id FinancialAccountRoleRecordTypeId = RecordTypeUtility.getRecordTypeId('FinServ__FinancialAccountRole__c', RecordTypeName);
        List<FinServ__FinancialAccountRole__c> farList = [select id,FinServ__Active__c,FinServ__FinancialAccount__c,Name__c,Provider_Client_Id__c,FinServ__StartDate__c from FinServ__FinancialAccountRole__c where Id in :financeAccountRoleIds AND FinServ__Active__c = True And RecordTypeId = :FinancialAccountRoleRecordTypeId];
        for(FinServ__FinancialAccountRole__c farRec : farList){
            financeAccountIds.add(farRec.FinServ__FinancialAccount__c);
        }
        if(financeAccountIds.size()>0){
            maintainIncomeRecords(financeAccountIds); 
        }
        
    }
    public void maintainIncomeRecords(Set<Id> FinancialAccountIdSet){
        List<Income__c> listOfIncomeRec = new List<Income__c>();
        // Id FinancialAccountRoleRecordTypeId = Schema.SObjectType.FinServ__FinancialAccountRole__c.getRecordTypeInfosByDeveloperName().get(FinancialAccountConstants.FAR_Owner_Role).getRecordTypeId();   
        String RecordTypeName = FinancialAccountConstants.FAR_OWNER_ROLE;
        Id FinancialAccountRoleRecordTypeId = RecordTypeUtility.getRecordTypeId(FinancialAccountConstants.FINANCIALACCOUNTROLE, RecordTypeName);
        List<FinServ__FinancialAccount__c> financialAccountLst = [select id,(select id,FinServ__Active__c,FinServ__FinancialAccount__c,Name__c,Provider_Client_Id__c,FinServ__StartDate__c from FinServ__FinancialAccountRoles__r where FinServ__Active__c = True And RecordTypeId = :FinancialAccountRoleRecordTypeId) 
                                                                  from FinServ__FinancialAccount__c where Id in :FinancialAccountIdSet
                                                                  AND Income_Amount__c > 0 AND IsActive__c =: FinancialAccountConstants.FA_STATUS_ACTIVE
                                                                  // AND Primary_Owner_Name__c != null
                                                                 ];
        List<Income__c> existingIncomeRecords = [select Id from Income__c where Financial_Account__c in :FinancialAccountIdSet];
        if(existingIncomeRecords.size()>0){
            delete existingIncomeRecords; // isDeleted = true
            Database.emptyRecycleBin(existingIncomeRecords);
        }
        for(FinServ__FinancialAccount__c financialRecord:financialAccountLst){
            Integer countOfFAR = financialRecord.FinServ__FinancialAccountRoles__r.size();
            if(countOfFAR>0){
                for(FinServ__FinancialAccountRole__c financialAccountRolesRecord : financialRecord.FinServ__FinancialAccountRoles__r){
                    Income__c incomeRec = new Income__c();
                    incomeRec.Primary_Owner__c =financialRecord.FinServ__PrimaryOwner__c;
                    incomeRec.Financial_Account__c = financialRecord.Id;
                    incomeRec.Financial_Account_Role__c = financialAccountRolesRecord.Id;
                    incomeRec.Category__c= FinancialAccountConstants.FA_CATEGORY_INVESTMENT_INCOME;
                    incomeRec.Frequency__c= FinancialAccountConstants.FA_FREQUENCY_ANNUALLY;
                    incomeRec.Amount__c=(financialRecord.Income_Amount__c)/countOfFAR; 
                    if(financialRecord.Tax_Status__c==FinancialAccountConstants.FA_Tax_Status_Gross){
                        incomeRec.Taxable__c = FinancialAccountConstants.INCOME_TAXABLE_YES;
                    }else if(financialRecord.Tax_Status__c== FinancialAccountConstants.FA_TAX_STATUS_FREE|| financialRecord.Tax_Status__c==  FinancialAccountConstants.FA_TAX_STATUS_NET)
                    {
                        incomeRec.Taxable__c = FinancialAccountConstants.INCOME_TAXABLE_NO;
                    }else
                    {
                        incomeRec.Taxable__c ='';  
                    }
                    /* incomeRec.RecordTypeId = Schema.SObjectType.Income__c.getRecordTypeInfosByDeveloperName()
.get(FinancialAccountConstants.INCOME_FA_AUTOMATED).getRecordTypeId(); */
                    incomeRec.RecordTypeId = FinancialAccountRoleRecordTypeId;
                    listOfIncomeRec.add(incomeRec);
                }  
            }  
        }
        upsert listOfIncomeRec;
    }
    
    public void processForclearIncomeRecords(List<SObject> changedRecords, List<SObject> changedOldRecords){
        if(changedOldRecords !=null){
           Set<Id> financeAccountIds = new Set<Id>();
        Set<Id> financeAccountRoleIds = new Set<Id>();
        For (FinServ__FinancialAccountRole__c finAccountRoleRec: (List<FinServ__FinancialAccountRole__c>) changedOldRecords){
            financeAccountRoleIds.add(finAccountRoleRec.Id);
        }
        // Id FinancialAccountRoleRecordTypeId = Schema.SObjectType.FinServ__FinancialAccountRole__c.getRecordTypeInfosByDeveloperName().get(FinancialAccountConstants.FAR_OWNER_ROLE).getRecordTypeId();   
        String RecordTypeName = FinancialAccountConstants.FAR_OWNER_ROLE;
        Id FinancialAccountRoleRecordTypeId = RecordTypeUtility.getRecordTypeId(FinancialAccountConstants.FINANCIALACCOUNTROLE, RecordTypeName);
        List<FinServ__FinancialAccountRole__c> farList = [select id,FinServ__Active__c,FinServ__FinancialAccount__c,Name__c,Provider_Client_Id__c,FinServ__StartDate__c from FinServ__FinancialAccountRole__c where Id in :financeAccountRoleIds AND FinServ__Active__c = True And RecordTypeId = :FinancialAccountRoleRecordTypeId];
        for(FinServ__FinancialAccountRole__c farRec : farList){
            financeAccountIds.add(farRec.FinServ__FinancialAccount__c);
        }
        if(financeAccountIds.size()>0){
            clearIncomeRecords(financeAccountIds); 
        }
        }
    } 
    public void clearIncomeRecords(Set<Id> IdSet)
    {
        //  delete[select id from Income__c where (Financial_Account__c in :IdSet Or Financial_Account_Role__c  in :IdSet) AND recordTypeId =:Schema.SObjectType.Income__c.getRecordTypeInfosByDeveloperName().get(FinancialAccountConstants.INCOME_FA_AUTOMATED).getRecordTypeId()];   
        
        List<Income__C> incomeList = [select id,recordtypeId from Income__c where Financial_Account__c =:IdSet Or Financial_Account_Role__c=:IdSet];
        delete incomeList;
        Database.emptyRecycleBin(incomeList);
    }
}

Hi All - I have a LWC modal notes component in record page, when i enter something in notes and click save button then it is getting saved which is expected behaviour and working fine but when user tries to open the notes component again and enter something but not saved the updated one rather he clicks either cancel or close icon, then opens the modal component again the user is able to see the drafted notes which should not happen in my case only when it is saved then it should show.

For example - in the below snap, only "Take a note" is saved and "drafted note" is not saved just user drafted and clicks either cancel or close but when again the modal component opens it shows the drafted one also. can someone help me how to resolve this issue?

User-added image

Here is my HTML and JS code:

HTML -

<template>
    <template if:true={accessible}>
    <lightning-button variant="neutral"
        label={buttonLabel} 
        title={buttonLabel} 
        icon-name={iconName}
        onclick={openNotesModal}></lightning-button>
    <!--Use template if:true to display/hide popup based on isModalOpen value--> 
    <template if:true={isNotesModalOpen}>
        <!-- Modal/Popup Box LWC starts here -->
        <section role="dialog" tabindex="-1" aria-labelledby="notes-modal-heading" aria-modal="true" aria-describedby="notes-modal-content" class="slds-modal slds-fade-in-open">
            <!--we need this relative tag so that the spinner shows up inside the modal-->
            <div class="slds-modal__container sjp-cfr">
            <div class="slds-is-relative">
                <!--Loading icon-->
                <template if:true={isLoading}>
                    <div>
                        <lightning-spinner alternative-text="Loading" size="large" variant="brand"></lightning-spinner>
                    </div>
                </template>
                
                    <!-- Modal/Popup Box LWC header here -->
                    <header class="slds-modal__header">
                        <button class="slds-button slds-button_icon slds-modal__close slds-button_icon-inverse" title="Close" onclick={closeNotesModal}>
                            <lightning-icon icon-name="utility:close"
                                alternative-text="close"
                                variant="inverse"
                                size="small" ></lightning-icon>
                            <span class="slds-assistive-text">Close</span>
                        </button>
                        <h2 id="notes-modal-heading" class="slds-text-heading_medium slds-hyphenate">{modalTitle}</h2>
                    </header>
                    <!-- Modal/Popup Box LWC body starts here -->
                    <div class="slds-modal__content slds-p-around_medium" id="notes-modal-content">
                        <!-- TODO: Replace with Custom Input Field -->
                           <template if:false={enableNotes}>
                             <lightning-textarea name="notesInput" 
                                maxlength={fieldlength}
                                label="Notes"
                                placeholder="Type here…"
                                value={fieldValue}
                                onchange={handleChange}
                                variant="label-hidden"
                                disabled ={disabled}> </lightning-textarea>
                            </template> 
                    </div>
                    <!-- Modal/Popup Box LWC footer starts here -->
                    <footer class="slds-modal__footer">
                        <lightning-button variant="neutral" 
                            label="Cancel" 
                            title="Cancel" 
                            class="slds-m-left_x-small"
                            onclick={closeNotesModal}></lightning-button>
                            <template if:true={updateable}>
                        <lightning-button variant="brand" 
                            label="Save" 
                            title="Save" 
                            class="slds-m-left_x-small"
                            onclick={saveNotes}></lightning-button>
                        </template>
                    </footer>
                </div>
            </div>
        </section>
        <div class="slds-backdrop slds-backdrop_open"></div>
    </template>
</template> 
</template>


JS code:

import { LightningElement, api, wire, track } from 'lwc';
import { loadStyle } from 'lightning/platformResourceLoader';
import getFieldInfo from '@salesforce/apex/CFRNotesController.getFieldInfo';
import saveNotesInfo from '@salesforce/apex/CFRNotesController.saveNotesInfo';
import cfrCustomStyles from '@salesforce/resourceUrl/cfrCustomStyles';
import { showToast } from 'c/commonUtils';
const EMPTY_NOTE_ICON = 'action:new';
const FILLED_NOTE_ICON = 'action:new_note';
export default class CfrNotes extends LightningElement {
    
    @api recordId;
    @api fieldName;
    @api modalTitle;
    @api buttonLabel = 'Notes';
    @track isNotesModalOpen = false;
    @track fieldValue = '';
    @track iconName = EMPTY_NOTE_ICON;
    @track isLoading = false;
    @track accessible = false;
    @track updateable = false;
    @track disabled = false;
    @track fieldlength=0;
    /* -----------------------------------------
        ON LOAD 
       ----------------------------------------- */
    renderedCallback() {
        Promise.all([
            loadStyle(this, cfrCustomStyles)
        ]);
    }
    /* -----------------------------------------
        WIRE METHODS 
       ----------------------------------------- */
    @wire(getFieldInfo, { recordId: '$recordId', fieldName: '$fieldName' })
    wiredFieldInfo({error, data}){
        if(error){
            this.processError(error);
        } else if(data){
            var fieldData = JSON.parse(JSON.stringify(data));
            if(data.fieldDescribe){
                fieldData.fieldDescribe = JSON.parse(data.fieldDescribe);
                if(!this.modalTitle){
                    this.modalTitle = fieldData.fieldDescribe.label;
                }
                  this.accessible = data.fieldAccess;
                  this.updateable= fieldData.fieldDescribe.updateable;
                  this.disabled = !(this.updateable);
                  this.fieldlength = fieldData.fieldDescribe.length;
            }
            if(data.fieldValue){
                this.fieldValue = data.fieldValue;
                this.iconName = FILLED_NOTE_ICON;
            }
        }
    };
    /* -----------------------------------------
        HANDLER METHODS 
       ----------------------------------------- */
    openNotesModal(){
        this.isNotesModalOpen = true;
    }
    handleChange(event){
        this.fieldValue = event.target.value;
    }
    closeNotesModal(){
        this.isNotesModalOpen = false;
    }
    saveNotes(){
        var context = this;
        this.isLoading = true;
        saveNotesInfo({recordId: this.recordId, fieldName: this.fieldName, fieldValue: this.fieldValue})
            .then((result) => {
                context.showSuccessToast('Success', context.modalTitle + ' successfully saved');
            })
            .catch((error) => {
                context.processError(error);
            })
            .finally(() => {
                context.isNotesModalOpen = false;
                this.isLoading = false;
                if (this.fieldValue === '') {
                    this.iconName = EMPTY_NOTE_ICON;
                    
                } else {
                    this.iconName=FILLED_NOTE_ICON;
                    
                }
            });
    }
    /* -----------------------------------------
        PRIVATE METHODS 
       ----------------------------------------- */
    processError(error){
        console.error(error);
        let message = 'Unknown error';
        try{
            if (typeof error === 'string') {
                message = error;
            } else if (Array.isArray(error.body)) {
                message = error.body.map(e => e.message).join(', ');
            } else if (typeof error.body.message === 'string') {
                message = error.body.message;
            }
        } catch (e){
        }
        this.showErrorToast('Error', message);
    }
    showErrorToast(title, message){
        showToast(this, title, message, 'error');
    }
    showSuccessToast(title, message){
        showToast(this, title, message, 'success');
    }
}

I have Notes component placed on record page which will refer field, the coponent is getting refreshed in UI when we update something inside component but when i refresh the whole page then only it is getting updated on record page, I need to referesh record page as well on updating the component. I am aware that ther is somethingn called "Apedrefresh" can someone help me on this, 

This is my wire method:

* -----------------------------------------
        WIRE METHODS 
       ----------------------------------------- */
    @wire(getFieldInfo, { recordId: '$recordId', fieldName: '$fieldName' })
    wiredFieldInfo({error, data}){
        if(error){
            this.processError(error);
        } else if(data){
            var fieldData = JSON.parse(JSON.stringify(data));
            if(data.fieldDescribe){
                fieldData.fieldDescribe = JSON.parse(data.fieldDescribe);
                if(!this.modalTitle){
                    this.modalTitle = fieldData.fieldDescribe.label;
                }
                  this.accessible = data.fieldAccess;
                  this.updateable= fieldData.fieldDescribe.updateable;
                  this.disabled = !(this.updateable);
                  this.fieldlength = fieldData.fieldDescribe.length;
            }
            if(data.fieldValue){
                this.fieldValue = data.fieldValue;
                this.iconName = FILLED_NOTE_ICON;
            }
        }
    };

this is my save notes handler:

 saveNotes(){
        var context = this;
        this.isLoading = true;
        saveNotesInfo({recordId: this.recordId, fieldName: this.fieldName, fieldValue: this.fieldValue})
            .then((result) => {
                context.showSuccessToast('Success', context.modalTitle + ' successfully saved');
            })
            .catch((error) => {
                context.processError(error);
            })
            .finally(() => {
                context.isNotesModalOpen = false;
                this.isLoading = false;
                if (this.fieldValue === '') {
                    this.iconName = EMPTY_NOTE_ICON;
                    
                } else {
                    this.iconName=FILLED_NOTE_ICON;
                    
                }
            });
    }
Hi All - I have a model button component as below, now the icon is static but i need when i enter some notes and save the component then the icon should behave dynamic. for example the icon style should change tick mark. can someone suggest how we can acheive this using LWC.

User-added image
Hi All - Below is the controller class for my custom component, can someone help me with test class for this controller.

public inherited sharing class CFRNotesControllerPOC {
    public class CFRNotesControllerException extends Exception {}

    @AuraEnabled(cacheable=true)
    public static NotesFieldWrapper getFieldInfo(String recordId, String fieldName){
        return new NotesFieldWrapper(recordId, fieldName);
    }

    @AuraEnabled
    public static void saveNotesInfo(String recordId, String fieldName, String fieldValue){
        SObject sobjectRecord = ((Id)recordId).getSObjectType().newSObject(recordId);
        sobjectRecord.put('Id', recordId);
        sobjectRecord.put(fieldName, fieldValue);
        Database.update(sobjectRecord);
    }

    public class NotesFieldWrapper {
        @auraEnabled
        public String fieldValue;
        @AuraEnabled
        public String fieldDescribe;
        //to check FLS
        @AuraEnabled
        public Boolean fieldAccess;
            
        public NotesFieldWrapper(String recordId, String fieldName) {
            Schema.DescribeSObjectResult objDescribe = ((Id)recordId).getSObjectType().getDescribe();
            String objName = objDescribe.getName();

            Map<String, Schema.SObjectField> fields = objDescribe.fields.getMap();
            if(String.isNotEmpty(fieldName)){
                Schema.SObjectField fieldToken = fields.get(fieldName);
                this.fieldDescribe = JSON.serialize(fieldToken.getDescribe());
                this.fieldAccess = fieldToken.getDescribe().isAccessible();

                String query = 'SELECT Id, ' + fieldName + ' FROM ' + objName + ' WHERE Id = \'' + recordId + '\'';
                SObject sobj = (SObject) Database.query(query);
                if(sobj != null){
                    this.fieldValue = (String) sobj.get(fieldName);
                }
            }
        }
    }
Hi All - Below is the controller class for my custom component, can someone help me with test class for this controller. Thanks!

public inherited sharing class CFRNotesControllerPOC {
    public class CFRNotesControllerException extends Exception {}

    @AuraEnabled(cacheable=true)
    public static NotesFieldWrapper getFieldInfo(String recordId, String fieldName){
        return new NotesFieldWrapper(recordId, fieldName);
    }

    @AuraEnabled
    public static void saveNotesInfo(String recordId, String fieldName, String fieldValue){
        SObject sobjectRecord = ((Id)recordId).getSObjectType().newSObject(recordId);
        sobjectRecord.put('Id', recordId);
        sobjectRecord.put(fieldName, fieldValue);
        Database.update(sobjectRecord);
    }

    public class NotesFieldWrapper {
        @auraEnabled
        public String fieldValue;
        @AuraEnabled
        public String fieldDescribe;
        //to check FLS
        @AuraEnabled
        public Boolean fieldAccess;
            
        public NotesFieldWrapper(String recordId, String fieldName) {
            Schema.DescribeSObjectResult objDescribe = ((Id)recordId).getSObjectType().getDescribe();
            String objName = objDescribe.getName();

            Map<String, Schema.SObjectField> fields = objDescribe.fields.getMap();
            if(String.isNotEmpty(fieldName)){
                Schema.SObjectField fieldToken = fields.get(fieldName);
                this.fieldDescribe = JSON.serialize(fieldToken.getDescribe());
                this.fieldAccess = fieldToken.getDescribe().isAccessible();

                String query = 'SELECT Id, ' + fieldName + ' FROM ' + objName + ' WHERE Id = \'' + recordId + '\'';
                SObject sobj = (SObject) Database.query(query);
                if(sobj != null){
                    this.fieldValue = (String) sobj.get(fieldName);
                }
            }
        }
    }
Hi All - I have custom LWC coponent (Notes Button) which is reusable for accorss the application. Now, I need to check permssion set based on the permisson set and if the permssion set has read only access, then the below pop up shoud disable the save and cancel button for non editable and it the permssions set has both read and edit then it can be editable.

User-added image
Hi, I have LWC component called "Notes" button, now i need to call this component in another test component or another LWC component to test the notes button functionalit. Notes button component is created by the way to use across the components. can someone help me or suggest ideas. Thanks!
I have created Printablle view Button, user needs see the print preview  button open in a new browser window which contains all Detail fields visible and related list fields to be visible. can someone suggest/help for code. Thanks!
I need to add "Printable View" Button to the Record page of Account object for only two Record types. If they click Printable view button it navigate to next tab and show the Account Detail Record as well as the related list records. Any suggestion would be helpful to implement this functonality. Thanks! 
Hi All - while completing Create Reports and Dashboards for Sales and Marketing Managers module i facing issue with  Visualize Your Data unit. below are the error i am getting while checking the challenge.

The 'Sales Rep Win Rates' report chart's title is not set to 'Sales Rep Win Rates'

I did gave the report name and followed the same procedure as per instruced in unit. Any thouhts and help would be greatly appreciated.

Thanks,
Harish S

 
Hi - I have created a LWC component for layout section as below, can someone suggest how this can be used as two column layout.
User-added image Here is my code:

<template>
    <div class={sectionClass}>
        <h3 class="slds-section__title">
            <button class="slds-button slds-section__title-action" onclick={handleClick}>
                <lightning-icon
                    icon-name="utility:switch"
                    class="slds-button__icon slds-button__icon_left slds-section__title-action-icon"
                    size="x-small">
                </lightning-icon>
                     <span class="slds-truncate" title={label}>Notes</span>
              </button>
        </h3>
        <div class="slds-section__content">
            <div class="slds-col slds-p-horizontal_medium">
                <lightning-layout>
                    <lightning-layout-item padding="around-small">
                        <div class="header-column">
                            <p class="field-title" title="Field 1">Address Notes</p>
                       </div>
                    </lightning-layout-item>
                    </lightning-layout>
                </div>
                <div class="slds-col slds-p-horizontal_medium">
                    <lightning-layout>
                        <lightning-layout-item padding="around-small">
                            <div class="header-column">
                                <p class="field-title" title="Field 2">Income Notes</p>
                           </div>
                        </lightning-layout-item>
                        </lightning-layout>
                    </div>
                    <div class="slds-col slds-p-horizontal_medium">
                        <lightning-layout>
                            <lightning-layout-item padding="around-small">
                                <div class="header-column">
                                    <p class="field-title" title="Field 3">Health Notes</p>
                               </div>
                            </lightning-layout-item>
                            </lightning-layout>
                        </div>
                        <div class="slds-col slds-p-horizontal_medium">
                            <lightning-layout>
                                <lightning-layout-item padding="around-small">
                                    <div class="header-column">
                                        <p class="field-title" title="Field 4">Expense Notes</p>
                                   </div>
                                </lightning-layout-item>
                                </lightning-layout>
                            </div>
        </div>
    </div>
</template>
Hi - can someone suggest how to create new section using LWC under details secion ?

Hi All - I have a LWC modal notes component in record page, when i enter something in notes and click save button then it is getting saved which is expected behaviour and working fine but when user tries to open the notes component again and enter something but not saved the updated one rather he clicks either cancel or close icon, then opens the modal component again the user is able to see the drafted notes which should not happen in my case only when it is saved then it should show.

For example - in the below snap, only "Take a note" is saved and "drafted note" is not saved just user drafted and clicks either cancel or close but when again the modal component opens it shows the drafted one also. can someone help me how to resolve this issue?

User-added image

Here is my HTML and JS code:

HTML -

<template>
    <template if:true={accessible}>
    <lightning-button variant="neutral"
        label={buttonLabel} 
        title={buttonLabel} 
        icon-name={iconName}
        onclick={openNotesModal}></lightning-button>
    <!--Use template if:true to display/hide popup based on isModalOpen value--> 
    <template if:true={isNotesModalOpen}>
        <!-- Modal/Popup Box LWC starts here -->
        <section role="dialog" tabindex="-1" aria-labelledby="notes-modal-heading" aria-modal="true" aria-describedby="notes-modal-content" class="slds-modal slds-fade-in-open">
            <!--we need this relative tag so that the spinner shows up inside the modal-->
            <div class="slds-modal__container sjp-cfr">
            <div class="slds-is-relative">
                <!--Loading icon-->
                <template if:true={isLoading}>
                    <div>
                        <lightning-spinner alternative-text="Loading" size="large" variant="brand"></lightning-spinner>
                    </div>
                </template>
                
                    <!-- Modal/Popup Box LWC header here -->
                    <header class="slds-modal__header">
                        <button class="slds-button slds-button_icon slds-modal__close slds-button_icon-inverse" title="Close" onclick={closeNotesModal}>
                            <lightning-icon icon-name="utility:close"
                                alternative-text="close"
                                variant="inverse"
                                size="small" ></lightning-icon>
                            <span class="slds-assistive-text">Close</span>
                        </button>
                        <h2 id="notes-modal-heading" class="slds-text-heading_medium slds-hyphenate">{modalTitle}</h2>
                    </header>
                    <!-- Modal/Popup Box LWC body starts here -->
                    <div class="slds-modal__content slds-p-around_medium" id="notes-modal-content">
                        <!-- TODO: Replace with Custom Input Field -->
                           <template if:false={enableNotes}>
                             <lightning-textarea name="notesInput" 
                                maxlength={fieldlength}
                                label="Notes"
                                placeholder="Type here…"
                                value={fieldValue}
                                onchange={handleChange}
                                variant="label-hidden"
                                disabled ={disabled}> </lightning-textarea>
                            </template> 
                    </div>
                    <!-- Modal/Popup Box LWC footer starts here -->
                    <footer class="slds-modal__footer">
                        <lightning-button variant="neutral" 
                            label="Cancel" 
                            title="Cancel" 
                            class="slds-m-left_x-small"
                            onclick={closeNotesModal}></lightning-button>
                            <template if:true={updateable}>
                        <lightning-button variant="brand" 
                            label="Save" 
                            title="Save" 
                            class="slds-m-left_x-small"
                            onclick={saveNotes}></lightning-button>
                        </template>
                    </footer>
                </div>
            </div>
        </section>
        <div class="slds-backdrop slds-backdrop_open"></div>
    </template>
</template> 
</template>


JS code:

import { LightningElement, api, wire, track } from 'lwc';
import { loadStyle } from 'lightning/platformResourceLoader';
import getFieldInfo from '@salesforce/apex/CFRNotesController.getFieldInfo';
import saveNotesInfo from '@salesforce/apex/CFRNotesController.saveNotesInfo';
import cfrCustomStyles from '@salesforce/resourceUrl/cfrCustomStyles';
import { showToast } from 'c/commonUtils';
const EMPTY_NOTE_ICON = 'action:new';
const FILLED_NOTE_ICON = 'action:new_note';
export default class CfrNotes extends LightningElement {
    
    @api recordId;
    @api fieldName;
    @api modalTitle;
    @api buttonLabel = 'Notes';
    @track isNotesModalOpen = false;
    @track fieldValue = '';
    @track iconName = EMPTY_NOTE_ICON;
    @track isLoading = false;
    @track accessible = false;
    @track updateable = false;
    @track disabled = false;
    @track fieldlength=0;
    /* -----------------------------------------
        ON LOAD 
       ----------------------------------------- */
    renderedCallback() {
        Promise.all([
            loadStyle(this, cfrCustomStyles)
        ]);
    }
    /* -----------------------------------------
        WIRE METHODS 
       ----------------------------------------- */
    @wire(getFieldInfo, { recordId: '$recordId', fieldName: '$fieldName' })
    wiredFieldInfo({error, data}){
        if(error){
            this.processError(error);
        } else if(data){
            var fieldData = JSON.parse(JSON.stringify(data));
            if(data.fieldDescribe){
                fieldData.fieldDescribe = JSON.parse(data.fieldDescribe);
                if(!this.modalTitle){
                    this.modalTitle = fieldData.fieldDescribe.label;
                }
                  this.accessible = data.fieldAccess;
                  this.updateable= fieldData.fieldDescribe.updateable;
                  this.disabled = !(this.updateable);
                  this.fieldlength = fieldData.fieldDescribe.length;
            }
            if(data.fieldValue){
                this.fieldValue = data.fieldValue;
                this.iconName = FILLED_NOTE_ICON;
            }
        }
    };
    /* -----------------------------------------
        HANDLER METHODS 
       ----------------------------------------- */
    openNotesModal(){
        this.isNotesModalOpen = true;
    }
    handleChange(event){
        this.fieldValue = event.target.value;
    }
    closeNotesModal(){
        this.isNotesModalOpen = false;
    }
    saveNotes(){
        var context = this;
        this.isLoading = true;
        saveNotesInfo({recordId: this.recordId, fieldName: this.fieldName, fieldValue: this.fieldValue})
            .then((result) => {
                context.showSuccessToast('Success', context.modalTitle + ' successfully saved');
            })
            .catch((error) => {
                context.processError(error);
            })
            .finally(() => {
                context.isNotesModalOpen = false;
                this.isLoading = false;
                if (this.fieldValue === '') {
                    this.iconName = EMPTY_NOTE_ICON;
                    
                } else {
                    this.iconName=FILLED_NOTE_ICON;
                    
                }
            });
    }
    /* -----------------------------------------
        PRIVATE METHODS 
       ----------------------------------------- */
    processError(error){
        console.error(error);
        let message = 'Unknown error';
        try{
            if (typeof error === 'string') {
                message = error;
            } else if (Array.isArray(error.body)) {
                message = error.body.map(e => e.message).join(', ');
            } else if (typeof error.body.message === 'string') {
                message = error.body.message;
            }
        } catch (e){
        }
        this.showErrorToast('Error', message);
    }
    showErrorToast(title, message){
        showToast(this, title, message, 'error');
    }
    showSuccessToast(title, message){
        showToast(this, title, message, 'success');
    }
}

I have Notes component placed on record page which will refer field, the coponent is getting refreshed in UI when we update something inside component but when i refresh the whole page then only it is getting updated on record page, I need to referesh record page as well on updating the component. I am aware that ther is somethingn called "Apedrefresh" can someone help me on this, 

This is my wire method:

* -----------------------------------------
        WIRE METHODS 
       ----------------------------------------- */
    @wire(getFieldInfo, { recordId: '$recordId', fieldName: '$fieldName' })
    wiredFieldInfo({error, data}){
        if(error){
            this.processError(error);
        } else if(data){
            var fieldData = JSON.parse(JSON.stringify(data));
            if(data.fieldDescribe){
                fieldData.fieldDescribe = JSON.parse(data.fieldDescribe);
                if(!this.modalTitle){
                    this.modalTitle = fieldData.fieldDescribe.label;
                }
                  this.accessible = data.fieldAccess;
                  this.updateable= fieldData.fieldDescribe.updateable;
                  this.disabled = !(this.updateable);
                  this.fieldlength = fieldData.fieldDescribe.length;
            }
            if(data.fieldValue){
                this.fieldValue = data.fieldValue;
                this.iconName = FILLED_NOTE_ICON;
            }
        }
    };

this is my save notes handler:

 saveNotes(){
        var context = this;
        this.isLoading = true;
        saveNotesInfo({recordId: this.recordId, fieldName: this.fieldName, fieldValue: this.fieldValue})
            .then((result) => {
                context.showSuccessToast('Success', context.modalTitle + ' successfully saved');
            })
            .catch((error) => {
                context.processError(error);
            })
            .finally(() => {
                context.isNotesModalOpen = false;
                this.isLoading = false;
                if (this.fieldValue === '') {
                    this.iconName = EMPTY_NOTE_ICON;
                    
                } else {
                    this.iconName=FILLED_NOTE_ICON;
                    
                }
            });
    }
Hi All - Below is the controller class for my custom component, can someone help me with test class for this controller.

public inherited sharing class CFRNotesControllerPOC {
    public class CFRNotesControllerException extends Exception {}

    @AuraEnabled(cacheable=true)
    public static NotesFieldWrapper getFieldInfo(String recordId, String fieldName){
        return new NotesFieldWrapper(recordId, fieldName);
    }

    @AuraEnabled
    public static void saveNotesInfo(String recordId, String fieldName, String fieldValue){
        SObject sobjectRecord = ((Id)recordId).getSObjectType().newSObject(recordId);
        sobjectRecord.put('Id', recordId);
        sobjectRecord.put(fieldName, fieldValue);
        Database.update(sobjectRecord);
    }

    public class NotesFieldWrapper {
        @auraEnabled
        public String fieldValue;
        @AuraEnabled
        public String fieldDescribe;
        //to check FLS
        @AuraEnabled
        public Boolean fieldAccess;
            
        public NotesFieldWrapper(String recordId, String fieldName) {
            Schema.DescribeSObjectResult objDescribe = ((Id)recordId).getSObjectType().getDescribe();
            String objName = objDescribe.getName();

            Map<String, Schema.SObjectField> fields = objDescribe.fields.getMap();
            if(String.isNotEmpty(fieldName)){
                Schema.SObjectField fieldToken = fields.get(fieldName);
                this.fieldDescribe = JSON.serialize(fieldToken.getDescribe());
                this.fieldAccess = fieldToken.getDescribe().isAccessible();

                String query = 'SELECT Id, ' + fieldName + ' FROM ' + objName + ' WHERE Id = \'' + recordId + '\'';
                SObject sobj = (SObject) Database.query(query);
                if(sobj != null){
                    this.fieldValue = (String) sobj.get(fieldName);
                }
            }
        }
    }
I need to add "Printable View" Button to the Record page of Account object for only two Record types. If they click Printable view button it navigate to next tab and show the Account Detail Record as well as the related list records. Any suggestion would be helpful to implement this functonality. Thanks! 
I have a custom object customer project relationship with Opportunity. in my custom object i have status field and if the satus field is active then it shoud automatically check the checkbox in opportunity object ( I have created custom checkbox field in opportunity object). Below is my attempt to try but could not able to proceed further can someone guide me?


trigger Activeprojectopp4 on Customer_Project__c (after insert, after update) {
//storing the list of customer project recodrs added  or updated
    List<Customer_Project__c> cprecords=new list<Customer_Project__c>();
    if(trigger.isinsert){
        for(Customer_Project__c cp: trigger.new){
            cprecords.add(cp);    
        }
    }
//fetching the activerecords from customer project and puting into map
    Map<id,Customer_Project__c> activerecords = new Map <id,Customer_Project__c>([select id,name,Opportunity__c from Customer_Project__c where status__c='Active']);
 
}


Thanks