• The new Learner
  • NEWBIE
  • 195 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 3
    Likes Received
  • 0
    Likes Given
  • 78
    Questions
  • 115
    Replies
Hi Experts,
 
I have the below requirements, can anyone help me out?


-Mass Reassigning of opportunties also transfers the assignement of the related open activities to the new opportunity owner(Opportunity should not be Closed Lost and Closed Won)

-Be able to multi-select opportunities to reassign allowing a manual selection of a single, multiple, or all opportunities.
Hi Experts,
 
I am struggling to cover the below if condition line( if(minutes <60)) in the test class can anyone help me out, please?
 
for(campaignmember cm:listcamps)
        {
            Long customFieldLong = cm.CreatedDate.getTime();
            Long dt2Long = DateTime.now().getTime();
            Long milliSeconds = dt2Long - customFieldLong;
            Long seconds = milliSeconds / 1000;
            Long minutes = seconds / 60;
            
            if(cm.status=='Form' || cm.status=='submit')
            {
                if(minutes<60)
                {
                    cammemleadId.add(cm.leadId);
                }

 
Hi Experts,

I want to do mass reparenting of specified contacts to an account using LWC, can anyone help me out, please?  for example, there are three contacts(contact names just con1, con2, and con3) for account A, I want to change the account field value only to those contacts which I selected  with Account B(which is another account record)
Hi Experts,
 
I have a requirement where I need to delete Manually assigned territories for the accounts.
On Account, we have checkboxes like AccountManager__c, and InsideSales__c when I uncheck these checkboxes I need to delete related Assigned territories. I have written code that is working perfectly for the one checkbox, however, when I included the next condition that is InsideSales__c problem started, even if I uncheck one checkbox it is removing both the territories. can anyone help me out?
public class Accounthandler
{
    public static void manualTerritory(list<account>newAccounts,Map<id,Account>oldAccounts)
    {  
        list<Id>accountIds= new list<Id>();
        list<Id>accountuserterritaryIds=new list<Id>();
        list<Id>territoryIds= New list<Id>();
        list<Id>userterritaryAsication= new list<Id>();
        list<Id>deletedterrirotarIds= new list<Id>();
        
        for(Account acc: newAccounts)
        {
            Account oldAcc=oldAccounts.get(acc.id);
            
            if((acc.AccountManager__c==False && acc.AccountManager__c !=oldAcc.AccountManager__c)
			||(acc.InsideSales__c==False && acc.InsideSales__c !=oldAcc.InsideSales__c))
            {
                accountIds.add(acc.id);
                
            }
            
        }
        if(accountIds.size()>0)
        {
            list<AccountUserTerritory2View>accuserTerrtrView=[select id,RoleInTerritory2,Territory2Id,AccountId from AccountUserTerritory2View where accountid in: accountIds];
            if(accuserTerrtrView.size()>0)
            {
                For(AccountUserTerritory2View accuserview: accuserTerrtrView)
                {
                    if((accuserview.RoleInTerritory2=='Z2' && accuserview.account.AccountManager__c==False && accuserview.account.AccountManager__c !=oldAcc.AccountManager__c)
					||(accuserview.RoleInTerritory2=='Z4' && accuserview.account.InsideSales__c==False && accuserview.account.InsideSales__c !=oldAcc.InsideSales__c))
                    {
                        accountuserterritaryIds.add(accuserview.AccountId);
                        territoryIds.add(accuserview.Territory2Id);
                    }
                }
                
                List<ObjectTerritory2Association> manualTerritoryAssignments = [SELECT Id,ObjectId,Territory2Id,SobjectType  FROM ObjectTerritory2Association WHERE AssociationCause = 'Territory2Manual' AND Territory2Id IN :territoryIds AND ObjectId in:accountuserterritaryIds ];
                
                if(manualTerritoryAssignments.size()>0)
                {
                    delete manualTerritoryAssignments;
                }
                
            }
        }
    } 
}

 
Hi Experts,
 
 I need to create quick action on the opportunity record with the following details(this action is on the opportunity record page only). can anyone help me out?
 
--The record owner of the new record is the currently logged-in user who pressed the button --the 'created by' of the new record is the currently logged-in user who pressed the button
--Account that is related to the opportunity record from which the new opportunity is created.
--It should not be possible to create a new Opportunity record from the quick action  any other way for anyone who does not have a Sys Admin or sales admin user.
Hi Experts,
 
I have to populate the Closed date with in the weekdays that is system.today+10 days, can anyone help me out , if I pass system.today(), 10 its showing to 31st, as per the logic it should show May 30th, even I dont know how worst it will behave for weekends when the record is created on weekends.. Below my logic can anyone help me out.
Public class BusinessDayCalculation  
    {
        Public static Date addBussinessDays(Date startDate, Integer iDays)
        {
            Integer businessDaysAdded = 0;
            Date currentDate = startDate;
            while (businessDaysAdded < iDays) {
                currentDate = currentDate.addDays(1);
                Datetime d = datetime.newInstance(currentDate.year(), currentDate.month(),currentDate.day());
                
                if (d.format('E') != 'Sat' && d.format('E') != 'Sun' && checkifItisWorkingDay(currentDate))
                {
         
                    businessDaysAdded = businessDaysAdded + 1;
                } 
            }       
            return currentDate;
        } 
        
        Public static boolean checkifItisWorkingDay(Date currentDate)
        {
            Date weekStart  = currentDate.toStartofWeek();
            if(weekStart.daysBetween(currentDate) ==0 || weekStart.daysBetween(currentDate) == 6)
            {
                return false;
            } 
            else
            {
                return true;
            }
        } 
    }
This is how I am calling above class in the main class
 if(dayOfWeek == 'Sunday')
                    {
                    opportunityToInsert.CloseDate = BusinessDayCalculation.addBussinessDays(myDate ,12);
                    }
                    else if(dayOfWeek == 'Saturday')
                    {
                       opportunityToInsert.CloseDate = BusinessDayCalculation.addBussinessDays(myDate ,11);
                    }
                    else
                    {
                      opportunityToInsert.CloseDate = BusinessDayCalculation.addBussinessDays(myDate,10);
                    }

 
Hi Experts,
 
I need to write LWC component for the Reassign button for the approval process, can anyone help me out, please
Hi Experts, 
 
Need to send a mass email to selected contacts, just like send list email button using lwc. can anyone help me out
Hi Experts,

Can anyone help me out, how to create list view along with filter criteria using LWC.
Hi Experts,
 
I have requirement , when ever the Lead status is Other on lead object , then only I have to show the quick action called "New Lead".  I have tried this by adding filter criteria in the flexi page, however, this button is assigned to couple of layouts, so this option is flopped. So,   Can anyone help me out, how can i do this.
Hi Experts,
 
I need to create a record on the selection of record type,  I have created a Combobox and populated the record type, now my requirement is that on the selection of that record type I need to create a record.
 
<template>
    <div if:true={objectInfo.data}>
        <lightning-combobox name="recordType" label="Record Type" placeholder="Choose Status"
        value={value} 
        options={recordTypeId1}>
        </lightning-combobox>
        </div> 
</template>

jS:
import { LightningElement, track, wire, api } from 'lwc';
import { getObjectInfo } from 'lightning/uiObjectInfoApi';
import CONTACT_OBJECT from '@salesforce/schema/Support_Request__c';

export default class CreateContact extends LightningElement {

    @track statusOptions;
    @track value;
    @api objectApiName;

    @track objectInfo;

    @wire(getObjectInfo, { objectApiName: CONTACT_OBJECT,})
    objectInfo;


    get recordTypeId1() {
        var recordtypeinfo = this.objectInfo.data.recordTypeInfos;
        var uiCombobox = [];
        console.log("recordtype" + recordtypeinfo);
        for(var eachRecordtype in  recordtypeinfo)//this is to match structure of lightning combo box
        {
          if(recordtypeinfo.hasOwnProperty(eachRecordtype))
          uiCombobox.push({ label: recordtypeinfo[eachRecordtype].name, value: recordtypeinfo[eachRecordtype].name })
        }
        console.log('uiCombobox' + JSON.stringify(uiCombobox));
      return uiCombobox;
    }

}
Meta:
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>52.0</apiVersion>
    <isExposed>true</isExposed>
    <targets>
     <target>lightning__AppPage</target>
     <target>lightning__RecordPage</target>
     <target>lightning__HomePage</target>
 </targets>
  
</LightningComponentBundle>

 
HI Experts,

My below code is working fine, however, while creating a new child record, parentid is not populating automatically, again I am selecting to add that child record to parent, can anyone help me out. For example, in the account record related list if we create contact record automatically that specific accountid(name) will come on the record detail page of contact. Same functionality I need in my below component. can anyone help me out?
 
TEmpate:

<template>
<lightning-card title={titleWithCount} icon-name="standard:record">
    <lightning-button label="New" slot="actions" onclick={createNew}></lightning-button>
    <div slot="footer">
        <div  if:true={countBool}>
            <lightning-button label="View All" onclick={navigateToRelatedList}></lightning-button>
        </div>
    </div> 
    <div class="slds-m-around_medium">   
        <div if:true={listRecords}>   
            <template for:each={listRecords} for:item="rec">    
                <div key={rec.Id} class="slds-box">                         
                    <lightning-record-view-form record-id={rec.id} object-api-name={objectName}>
                        <div class="slds-grid">
                            <div class="slds-col slds-size_1-of-2">
                                <lightning-output-field field-name={field1}></lightning-output-field>
                                <lightning-output-field field-name={field2}></lightning-output-field>
                            </div>
                            <div class="slds-col slds-size_1-of-2">
                                <lightning-output-field field-name={field3}></lightning-output-field>
                                <lightning-output-field field-name={field4}></lightning-output-field>
                            </div>
                        </div>
                    </lightning-record-view-form><br/><br/>
                </div>                       
            </template>   
        </div>   
    </div>   
</lightning-card>       
</template>


JS:

import { LightningElement, api, wire, track } from 'lwc'; 
import fetchRecords from '@salesforce/apex/RelatedListController.fetchRecords'; 
import { NavigationMixin } from 'lightning/navigation';
 
export default class RelatedList extends NavigationMixin( LightningElement ) { 
 
    @api objectName; 
    @api parentObjectName;
    @api fieldName; 
    @api fieldValue; 
    @api parentFieldAPIName; 
    @api recordId; 
    @api strTitle; 
    @api filterType; 
    @api operator; 
    @api fieldsList;
    @api relationshipApiName;
    @track field1;
    @track field2;
    @track field3;
    @track field4;
    @track listRecords;
    @track titleWithCount;
    @track countBool = false;
    //@api recordid;

    connectedCallback() {

        var listFields = this.fieldsList.split( ',' );
        console.log( 'Fields are ' + listFields );
        this.field1 = listFields[ 0 ].trim();
        this.field2 = listFields[ 1 ].trim();
        this.field3 = listFields[ 2 ].trim();
        this.field4 = listFields[ 3 ].trim();
        console.log( 'Field 1 is ' + this.field1 );
        console.log( 'Field 2 is ' + this.field2 );
        console.log( 'Field 3 is ' + this.field3 );
        console.log( 'Field 4 is ' + this.field4 );

    }

    get vals() { 

        return this.recordId + '-' + this.objectName + '-' +  
               this.parentFieldAPIName + '-' + this.fieldName + '-' +  
               this.fieldValue + '-' + this.filterType + '-' + this.operator + '-' + this.fieldsList; 

    } 
     
    @wire(fetchRecords, { listValues: '$vals' }) 
    accountData( { error, data } ) {

        if ( data ) {
          
            this.listRecords = data.listRecords;
            console.log(JSON.stringify(this.listRecords));
            if ( data.recordCount ) {
               
                if ( data.recordCount > 3 ) {

                    this.titleWithCount = this.strTitle + '(3+)';
                    this.countBool = true;
               
                } else {

                    this.countBool = false;
                    this.titleWithCount = this.strTitle + '(' + data.recordCount + ')';

                }
            }

        }

    }

    createNew() {

        this[NavigationMixin.Navigate]({
            type: 'standard__objectPage',
            attributes: {
                objectApiName: this.objectName,
                actionName: 'new'
            }
        });

    }

    navigateToRelatedList() {
       
        this[NavigationMixin.Navigate]({
            type: 'standard__recordRelationshipPage',
            attributes: {
                recordId: this.recordId,
                objectApiName: this.parentObjectName,
                relationshipApiName: this.relationshipApiName,
                actionName: 'view'
            }
        });

    }
 
}

Meta:

<?xml version="1.0" encoding="UTF-8"?> 
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata" fqn="RelatedList"> 
    <apiVersion>52.0</apiVersion> 
    <isExposed>true</isExposed> 
    <targets> 
        <target>lightning__RecordPage</target> 
    </targets> 
    <targetConfigs> 
        <targetConfig targets="lightning__RecordPage"> 
            <property name="strTitle" type="String" label="Title" description="Enter the title"/> 
            <property name="objectName" type="String" label="Object Name" description="Enter the object name"/> 
            <property name="parentObjectName" type="String" label="Parent Object Name" description="Enter the parent object name"/> 
            <property name="relationshipApiName" type="String" label="Relationship Name" description="Enter the relationship API name"/> 
            <property name="parentFieldAPIName" type="String" label="Parent Field API Name" description="Enter the parent field API Name"/> 
            <property name="fieldName" type="String" label="Field Name" description="Enter the field name"/> 
            <property name="fieldValue" type="String" label="Field Value" description="Enter the field value"/> 
            <property name="filterType" type="String" label="Filter Type" description="Enter the filter type"/> 
            <property name="operator" type="String" label="Operator" description="Enter the operator"/> 
            <property name="fieldsList" type="String" label="Fields List" description="Enter the field API names separated by coma. Do not enter more than 4 fields"/> 
        </targetConfig> 
    </targetConfigs> 
</LightningComponentBundle>

 
Hi Experts,
 
How to create or edit a record based on the record type in LWC(component should be generic) can anyone help me out? 
Hi Experts,
 
Need to create a button two new buttons Record Create and Record Edit, by clicking on  Record Create button it has to open Record create a form with record type. similarly, by click on the Record Edit button, it has to open the Edit record form with record type. Can anyone help me out?
Hi  Experts,
 
I have requirement as follows , need to create a dropdown of accounts and on selecting specific account get a related list of contact with a specific field of that account with pagination
Hi Experts,

I need to create a button called Edit record, it will open the current record in edit view and the user can change details and save. can anyone help me, I have written below however it's not working for me.
 
Template:

<template>
    <template if:true={showRecScreen}>
        <lightning-record-edit-form
    object-api-name={objectApiName}
    record-id={recordId}>
        <lightning-input-field
            field-name={nameField}>
        </lightning-input-field>
        <div class="slds-var-m-top_medium">
            <lightning-button
                variant="brand"
                type="submit"
                label="Save">
            </lightning-button>
        </div>
</lightning-record-edit-form> 
    </template>
    <lightning-button name="Update" label="Updateedit" onclick={handleUpdate}></lightning-button>
</template>

JS:

import { LightningElement,api } from 'lwc';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';

import NAME_FIELD from '@salesforce/schema/Account.Name';

export default class Editrecordeditformpage extends LightningElement {
    @api objectApiName = 'Account';
	showRecScreen = false;

    nameField = NAME_FIELD;

 
	
	handleUpdate(){
	this.showRecScreen = true;  
	}

    handleSuccess(event) {
        const evt = new ShowToastEvent({
            title: "Account created",
            message: "Record ID: " + event.detail.id,
            variant: "success"
        });
        this.dispatchEvent(evt);
    }

}

 
Hi Experts,

I have a requirement, if a user clicks on a button it needs to open the record create form and a user can create a related object record on save. can anyone help me on this?
Hi Experts, 
 
I need allow to edit the field called assitance__c on accountcontactrelationship record  by the Users in Assigned Territories (related list of an account) and system admin, account manager. can anyone help me out. how to achieve this.
Hi Experts,
 
I have written a trigger, when the opportunity contain inactive product I need to throw an error, however, its working fine for one product, when it have more than one , when I am trying to delete it's not working its throwing an error by saying  "select correct product"
can anyone help me out? 
 
public static void products(Set<Id> oppIds, List<Opportunity> opplist)
    {
        
        List<OpportunityLineItem> opplineitems = [SELECT OpportunityId FROM OpportunityLineItem WHERE Product2.IsActive = false AND OpportunityId IN: OppIds];
        
        Set<Id> opptyId = New Set<Id>();
        for(OpportunityLineItem opplt:opplineitems)
        {
            
            opptyId.add(opplt.OpportunityId);
        }
        
        for (Opportunity opp :opplist) 
        {
            
            if(opptyId.contains(opp.Id))
            {
                
                opp.addError('select correct product');

            }
        }
            
    }

 
Hi Experts,

I want to post a chatter on the event record on a daily basis when the event status-completed and When the Event Date is passed. Chatter should not update the same record in their next batch . Kindly help me out.
HI Experts,

My below code is working fine, however, while creating a new child record, parentid is not populating automatically, again I am selecting to add that child record to parent, can anyone help me out. For example, in the account record related list if we create contact record automatically that specific accountid(name) will come on the record detail page of contact. Same functionality I need in my below component. can anyone help me out?
 
TEmpate:

<template>
<lightning-card title={titleWithCount} icon-name="standard:record">
    <lightning-button label="New" slot="actions" onclick={createNew}></lightning-button>
    <div slot="footer">
        <div  if:true={countBool}>
            <lightning-button label="View All" onclick={navigateToRelatedList}></lightning-button>
        </div>
    </div> 
    <div class="slds-m-around_medium">   
        <div if:true={listRecords}>   
            <template for:each={listRecords} for:item="rec">    
                <div key={rec.Id} class="slds-box">                         
                    <lightning-record-view-form record-id={rec.id} object-api-name={objectName}>
                        <div class="slds-grid">
                            <div class="slds-col slds-size_1-of-2">
                                <lightning-output-field field-name={field1}></lightning-output-field>
                                <lightning-output-field field-name={field2}></lightning-output-field>
                            </div>
                            <div class="slds-col slds-size_1-of-2">
                                <lightning-output-field field-name={field3}></lightning-output-field>
                                <lightning-output-field field-name={field4}></lightning-output-field>
                            </div>
                        </div>
                    </lightning-record-view-form><br/><br/>
                </div>                       
            </template>   
        </div>   
    </div>   
</lightning-card>       
</template>


JS:

import { LightningElement, api, wire, track } from 'lwc'; 
import fetchRecords from '@salesforce/apex/RelatedListController.fetchRecords'; 
import { NavigationMixin } from 'lightning/navigation';
 
export default class RelatedList extends NavigationMixin( LightningElement ) { 
 
    @api objectName; 
    @api parentObjectName;
    @api fieldName; 
    @api fieldValue; 
    @api parentFieldAPIName; 
    @api recordId; 
    @api strTitle; 
    @api filterType; 
    @api operator; 
    @api fieldsList;
    @api relationshipApiName;
    @track field1;
    @track field2;
    @track field3;
    @track field4;
    @track listRecords;
    @track titleWithCount;
    @track countBool = false;
    //@api recordid;

    connectedCallback() {

        var listFields = this.fieldsList.split( ',' );
        console.log( 'Fields are ' + listFields );
        this.field1 = listFields[ 0 ].trim();
        this.field2 = listFields[ 1 ].trim();
        this.field3 = listFields[ 2 ].trim();
        this.field4 = listFields[ 3 ].trim();
        console.log( 'Field 1 is ' + this.field1 );
        console.log( 'Field 2 is ' + this.field2 );
        console.log( 'Field 3 is ' + this.field3 );
        console.log( 'Field 4 is ' + this.field4 );

    }

    get vals() { 

        return this.recordId + '-' + this.objectName + '-' +  
               this.parentFieldAPIName + '-' + this.fieldName + '-' +  
               this.fieldValue + '-' + this.filterType + '-' + this.operator + '-' + this.fieldsList; 

    } 
     
    @wire(fetchRecords, { listValues: '$vals' }) 
    accountData( { error, data } ) {

        if ( data ) {
          
            this.listRecords = data.listRecords;
            console.log(JSON.stringify(this.listRecords));
            if ( data.recordCount ) {
               
                if ( data.recordCount > 3 ) {

                    this.titleWithCount = this.strTitle + '(3+)';
                    this.countBool = true;
               
                } else {

                    this.countBool = false;
                    this.titleWithCount = this.strTitle + '(' + data.recordCount + ')';

                }
            }

        }

    }

    createNew() {

        this[NavigationMixin.Navigate]({
            type: 'standard__objectPage',
            attributes: {
                objectApiName: this.objectName,
                actionName: 'new'
            }
        });

    }

    navigateToRelatedList() {
       
        this[NavigationMixin.Navigate]({
            type: 'standard__recordRelationshipPage',
            attributes: {
                recordId: this.recordId,
                objectApiName: this.parentObjectName,
                relationshipApiName: this.relationshipApiName,
                actionName: 'view'
            }
        });

    }
 
}

Meta:

<?xml version="1.0" encoding="UTF-8"?> 
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata" fqn="RelatedList"> 
    <apiVersion>52.0</apiVersion> 
    <isExposed>true</isExposed> 
    <targets> 
        <target>lightning__RecordPage</target> 
    </targets> 
    <targetConfigs> 
        <targetConfig targets="lightning__RecordPage"> 
            <property name="strTitle" type="String" label="Title" description="Enter the title"/> 
            <property name="objectName" type="String" label="Object Name" description="Enter the object name"/> 
            <property name="parentObjectName" type="String" label="Parent Object Name" description="Enter the parent object name"/> 
            <property name="relationshipApiName" type="String" label="Relationship Name" description="Enter the relationship API name"/> 
            <property name="parentFieldAPIName" type="String" label="Parent Field API Name" description="Enter the parent field API Name"/> 
            <property name="fieldName" type="String" label="Field Name" description="Enter the field name"/> 
            <property name="fieldValue" type="String" label="Field Value" description="Enter the field value"/> 
            <property name="filterType" type="String" label="Filter Type" description="Enter the filter type"/> 
            <property name="operator" type="String" label="Operator" description="Enter the operator"/> 
            <property name="fieldsList" type="String" label="Fields List" description="Enter the field API names separated by coma. Do not enter more than 4 fields"/> 
        </targetConfig> 
    </targetConfigs> 
</LightningComponentBundle>

 
Hi Experts,

Can anyone help me how to write test class for the below method.

public override void onCommit(){
        
        OM_ManageService manageRemittanceSVC = (OM_ManageRService)this.svc;
        String accJSON = OM_WorkService.getJSONAttribute(manageRemittanceSVC.jsonString, 'AccountInfo');
        Map<String, List<SObject>> accObjects =  OM_WorkService.getSObjects(accJSON);
        Account acc = (Account)accObjects.get('Account')[0];
        
        if(acc!= null){
            upsert acc;
            super.onCommit();
            
            }
            
        Below is the OM_WorkService.getJSONAttribut    
             
             public static String getJSONAttribute(String jsonStr, String attr){
        Map<String, Object> m = (Map<String, Object>)JSON.deserializeUntyped(jsonStr);
        if(m.containsKey(attr))
            return (String)m.get(attr);
        
        return null;
    }
 
Hi Experts,
 
I have the below requirements, can anyone help me out?


-Mass Reassigning of opportunties also transfers the assignement of the related open activities to the new opportunity owner(Opportunity should not be Closed Lost and Closed Won)

-Be able to multi-select opportunities to reassign allowing a manual selection of a single, multiple, or all opportunities.
Hi Experts,
 
I am struggling to cover the below if condition line( if(minutes <60)) in the test class can anyone help me out, please?
 
for(campaignmember cm:listcamps)
        {
            Long customFieldLong = cm.CreatedDate.getTime();
            Long dt2Long = DateTime.now().getTime();
            Long milliSeconds = dt2Long - customFieldLong;
            Long seconds = milliSeconds / 1000;
            Long minutes = seconds / 60;
            
            if(cm.status=='Form' || cm.status=='submit')
            {
                if(minutes<60)
                {
                    cammemleadId.add(cm.leadId);
                }

 
Hi Experts,
 
I have a requirement where I need to delete Manually assigned territories for the accounts.
On Account, we have checkboxes like AccountManager__c, and InsideSales__c when I uncheck these checkboxes I need to delete related Assigned territories. I have written code that is working perfectly for the one checkbox, however, when I included the next condition that is InsideSales__c problem started, even if I uncheck one checkbox it is removing both the territories. can anyone help me out?
public class Accounthandler
{
    public static void manualTerritory(list<account>newAccounts,Map<id,Account>oldAccounts)
    {  
        list<Id>accountIds= new list<Id>();
        list<Id>accountuserterritaryIds=new list<Id>();
        list<Id>territoryIds= New list<Id>();
        list<Id>userterritaryAsication= new list<Id>();
        list<Id>deletedterrirotarIds= new list<Id>();
        
        for(Account acc: newAccounts)
        {
            Account oldAcc=oldAccounts.get(acc.id);
            
            if((acc.AccountManager__c==False && acc.AccountManager__c !=oldAcc.AccountManager__c)
			||(acc.InsideSales__c==False && acc.InsideSales__c !=oldAcc.InsideSales__c))
            {
                accountIds.add(acc.id);
                
            }
            
        }
        if(accountIds.size()>0)
        {
            list<AccountUserTerritory2View>accuserTerrtrView=[select id,RoleInTerritory2,Territory2Id,AccountId from AccountUserTerritory2View where accountid in: accountIds];
            if(accuserTerrtrView.size()>0)
            {
                For(AccountUserTerritory2View accuserview: accuserTerrtrView)
                {
                    if((accuserview.RoleInTerritory2=='Z2' && accuserview.account.AccountManager__c==False && accuserview.account.AccountManager__c !=oldAcc.AccountManager__c)
					||(accuserview.RoleInTerritory2=='Z4' && accuserview.account.InsideSales__c==False && accuserview.account.InsideSales__c !=oldAcc.InsideSales__c))
                    {
                        accountuserterritaryIds.add(accuserview.AccountId);
                        territoryIds.add(accuserview.Territory2Id);
                    }
                }
                
                List<ObjectTerritory2Association> manualTerritoryAssignments = [SELECT Id,ObjectId,Territory2Id,SobjectType  FROM ObjectTerritory2Association WHERE AssociationCause = 'Territory2Manual' AND Territory2Id IN :territoryIds AND ObjectId in:accountuserterritaryIds ];
                
                if(manualTerritoryAssignments.size()>0)
                {
                    delete manualTerritoryAssignments;
                }
                
            }
        }
    } 
}

 
Hi Experts,
 
 I need to create quick action on the opportunity record with the following details(this action is on the opportunity record page only). can anyone help me out?
 
--The record owner of the new record is the currently logged-in user who pressed the button --the 'created by' of the new record is the currently logged-in user who pressed the button
--Account that is related to the opportunity record from which the new opportunity is created.
--It should not be possible to create a new Opportunity record from the quick action  any other way for anyone who does not have a Sys Admin or sales admin user.
Hi Experts, 
 
Need to send a mass email to selected contacts, just like send list email button using lwc. can anyone help me out
Hi Experts,

Can anyone help me out, how to create list view along with filter criteria using LWC.
HI Experts,

My below code is working fine, however, while creating a new child record, parentid is not populating automatically, again I am selecting to add that child record to parent, can anyone help me out. For example, in the account record related list if we create contact record automatically that specific accountid(name) will come on the record detail page of contact. Same functionality I need in my below component. can anyone help me out?
 
TEmpate:

<template>
<lightning-card title={titleWithCount} icon-name="standard:record">
    <lightning-button label="New" slot="actions" onclick={createNew}></lightning-button>
    <div slot="footer">
        <div  if:true={countBool}>
            <lightning-button label="View All" onclick={navigateToRelatedList}></lightning-button>
        </div>
    </div> 
    <div class="slds-m-around_medium">   
        <div if:true={listRecords}>   
            <template for:each={listRecords} for:item="rec">    
                <div key={rec.Id} class="slds-box">                         
                    <lightning-record-view-form record-id={rec.id} object-api-name={objectName}>
                        <div class="slds-grid">
                            <div class="slds-col slds-size_1-of-2">
                                <lightning-output-field field-name={field1}></lightning-output-field>
                                <lightning-output-field field-name={field2}></lightning-output-field>
                            </div>
                            <div class="slds-col slds-size_1-of-2">
                                <lightning-output-field field-name={field3}></lightning-output-field>
                                <lightning-output-field field-name={field4}></lightning-output-field>
                            </div>
                        </div>
                    </lightning-record-view-form><br/><br/>
                </div>                       
            </template>   
        </div>   
    </div>   
</lightning-card>       
</template>


JS:

import { LightningElement, api, wire, track } from 'lwc'; 
import fetchRecords from '@salesforce/apex/RelatedListController.fetchRecords'; 
import { NavigationMixin } from 'lightning/navigation';
 
export default class RelatedList extends NavigationMixin( LightningElement ) { 
 
    @api objectName; 
    @api parentObjectName;
    @api fieldName; 
    @api fieldValue; 
    @api parentFieldAPIName; 
    @api recordId; 
    @api strTitle; 
    @api filterType; 
    @api operator; 
    @api fieldsList;
    @api relationshipApiName;
    @track field1;
    @track field2;
    @track field3;
    @track field4;
    @track listRecords;
    @track titleWithCount;
    @track countBool = false;
    //@api recordid;

    connectedCallback() {

        var listFields = this.fieldsList.split( ',' );
        console.log( 'Fields are ' + listFields );
        this.field1 = listFields[ 0 ].trim();
        this.field2 = listFields[ 1 ].trim();
        this.field3 = listFields[ 2 ].trim();
        this.field4 = listFields[ 3 ].trim();
        console.log( 'Field 1 is ' + this.field1 );
        console.log( 'Field 2 is ' + this.field2 );
        console.log( 'Field 3 is ' + this.field3 );
        console.log( 'Field 4 is ' + this.field4 );

    }

    get vals() { 

        return this.recordId + '-' + this.objectName + '-' +  
               this.parentFieldAPIName + '-' + this.fieldName + '-' +  
               this.fieldValue + '-' + this.filterType + '-' + this.operator + '-' + this.fieldsList; 

    } 
     
    @wire(fetchRecords, { listValues: '$vals' }) 
    accountData( { error, data } ) {

        if ( data ) {
          
            this.listRecords = data.listRecords;
            console.log(JSON.stringify(this.listRecords));
            if ( data.recordCount ) {
               
                if ( data.recordCount > 3 ) {

                    this.titleWithCount = this.strTitle + '(3+)';
                    this.countBool = true;
               
                } else {

                    this.countBool = false;
                    this.titleWithCount = this.strTitle + '(' + data.recordCount + ')';

                }
            }

        }

    }

    createNew() {

        this[NavigationMixin.Navigate]({
            type: 'standard__objectPage',
            attributes: {
                objectApiName: this.objectName,
                actionName: 'new'
            }
        });

    }

    navigateToRelatedList() {
       
        this[NavigationMixin.Navigate]({
            type: 'standard__recordRelationshipPage',
            attributes: {
                recordId: this.recordId,
                objectApiName: this.parentObjectName,
                relationshipApiName: this.relationshipApiName,
                actionName: 'view'
            }
        });

    }
 
}

Meta:

<?xml version="1.0" encoding="UTF-8"?> 
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata" fqn="RelatedList"> 
    <apiVersion>52.0</apiVersion> 
    <isExposed>true</isExposed> 
    <targets> 
        <target>lightning__RecordPage</target> 
    </targets> 
    <targetConfigs> 
        <targetConfig targets="lightning__RecordPage"> 
            <property name="strTitle" type="String" label="Title" description="Enter the title"/> 
            <property name="objectName" type="String" label="Object Name" description="Enter the object name"/> 
            <property name="parentObjectName" type="String" label="Parent Object Name" description="Enter the parent object name"/> 
            <property name="relationshipApiName" type="String" label="Relationship Name" description="Enter the relationship API name"/> 
            <property name="parentFieldAPIName" type="String" label="Parent Field API Name" description="Enter the parent field API Name"/> 
            <property name="fieldName" type="String" label="Field Name" description="Enter the field name"/> 
            <property name="fieldValue" type="String" label="Field Value" description="Enter the field value"/> 
            <property name="filterType" type="String" label="Filter Type" description="Enter the filter type"/> 
            <property name="operator" type="String" label="Operator" description="Enter the operator"/> 
            <property name="fieldsList" type="String" label="Fields List" description="Enter the field API names separated by coma. Do not enter more than 4 fields"/> 
        </targetConfig> 
    </targetConfigs> 
</LightningComponentBundle>

 
Hi Experts,
 
How to create or edit a record based on the record type in LWC(component should be generic) can anyone help me out? 
Hi  Experts,
 
I have requirement as follows , need to create a dropdown of accounts and on selecting specific account get a related list of contact with a specific field of that account with pagination