• JohnDurai
  • NEWBIE
  • 125 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 47
    Questions
  • 29
    Replies
Hi All - Is there a way to Suppress email verification notification for only experience user which should not affect internal SF users.

I have gone through the below article to disable email notification but i think it would supress for other SF internal users as well.
https://help.salesforce.com/s/articleView?id=release-notes.rn_identity_confirm_email_address.htm&release=222&type=5

if there is any way to supress only for community users? any thoughts would help. Thanks!
I have community page, inside that I have component with submit button once i click on submit button it should trigger email to the email id stored in Custom metadata/custom settings. can some one suggest how to do it in aura framework.

onclick="{!c.submitFormForEmail}">
                                                    Submit
                                                </button>
Hi All - I am trying to embed external web page in Salesforce Account record page using Aura component, I am trying the below approach which is working for me but need better way without harding the URL and passing the account id as well. can some one help me out on this.

<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes" access="global" >
    <iframe src="https://externalwebpage?id=XXXXXX"            
            width="100%"
            height="500px"
            sandbox="allow-same-origin allow-scripts allow-forms"
            scrolling="auto"/>
    
</aura:component>
Hi All - I am Deleting the records using Btach class, but it is hard deleting it and not getting stored in Recycle bin, as part of business purpose we need this data to be stored for few days in Recycle bin, So i am trying to Soft Delete the records by making isDeleted field to true, but I am getting error that the field is not writtable, is there any alternative way to soft delete the records using apex code. Thanks! Here is my execute method code.

 global void execute(Database.BatchableContext BC , List<CampaignMember> campaignMemberScope) {
        
        system.debug('CM Records' + campaignMemberScope);
        for(CampaignMember camMemberIsDeletedTrue:campaignMemberScope){
            if(campaignMemberScope !=NULL && campaignMemberScope.size()>0){
                try{
                    //camMemberIsDeletedTrue.IsDeleted = true;
                    //Database.DeleteResult[] result =  Database.delete(campaignMemberScope, false);
                } catch(Exception e){
                    system.debug('Exception Caught:' +e.getmessage());
                }
            }
        }
    }
 
Hi All - I am trying to cover the test class for batch apex, but i could not able to cover execute method since my test record does not match the query condition (lastmodifiedDate) in batch apex so scope does not returning record. can some one help how to cover the execute method here. Thanks!

User-added image
Here is my Test Class:

@isTest
public class TestpurgeCampaignRecords {
    static testMethod void TestpurgeCampaignRecordsMethod(){
           
          //List<CampaignMember> campaignMembers = new List<CampaignMember>();
          Contact c = new Contact(
                FirstName = 'User',
                LastName = 'Test ' );
           insert c;
           Id cMRecordId = Schema.SObjectType.CampaignMember.getRecordTypeInfosByName().get('Hypercare Customer').getRecordTypeId();
           Campaign campaign = new Campaign(Name = 'Test Campaign ',IsActive = true, CampaignMemberRecordTypeId=cMRecordId);
           insert campaign;
           string recordTypeId =system.Label.CampaignMemberRecordtype;
           system.debug('recordTypeId'  +recordTypeId);
           integer dayCounts = Integer.valueof(system.label.LastmodifiedDateforCM);
           system.debug('dayCounts'  +dayCounts);
            list<CampaignMember> cmList = new List<CampaignMember>();
            CampaignMember campaignMember = new CampaignMember();
            campaignMember.ContactId = c.Id;
            //campaignMember.RecordTypeId = cMRecordId;
            campaignMember.CampaignId = campaign.Id;
            campaignMember.LeadId=null;
            campaignMember.Status = 'Open';
            campaignMember.Locked_By__c = null;
            campaignMember.Root_Cause__c ='Address discrepancy';
            campaignMember.Resolution_Status__c ='Resolved';
            //campaignMember.LastModifiedDate = System.today() - 1;
            //insert campaignMember;
            cmList.add(campaignMember);
            insert cmList;
           
       
   //insert campaignMembers;
        Test.startTest();
        String schTime = '0 0 12 * * ?';
        purgeCampaignRecords pcr = new purgeCampaignRecords();
        system.schedule('TestUpdateConAccJob', schTime, pcr);
        //system.AssertException;
        database.executeBatch(pcr);
        //System.assertEquals(1, [SELECT COUNT() FROM CampaignMember WHERE Id = :cmList[0].id]);
        Test.stopTest();
        
    }
 
Hi All - I am trying to cover the test class for batch apex, but i could not able to cover execute method since my test record does not match the query condition in batch apex so scope does not returning record. can some one help how to cover this?
User-added image
Here is my test class:
@isTest
public class TestpurgeCampaignRecords {
    static testMethod void TestpurgeCampaignRecordsMethod(){
           
          //List<CampaignMember> campaignMembers = new List<CampaignMember>();
          Contact c = new Contact(
                FirstName = 'User',
                LastName = 'Test ' );
           insert c;
           Id cMRecordId = Schema.SObjectType.CampaignMember.getRecordTypeInfosByName().get('Hypercare Customer').getRecordTypeId();
           Campaign campaign = new Campaign(Name = 'Test Campaign ',IsActive = true, CampaignMemberRecordTypeId=cMRecordId);
           insert campaign;
        
               list<CampaignMember> cmList = new List<CampaignMember>();
            CampaignMember campaignMember = new CampaignMember();
            campaignMember.ContactId = c.Id;
            //campaignMember.RecordTypeId = cMRecordId;
            campaignMember.CampaignId = campaign.Id;
            campaignMember.LeadId=null;
            campaignMember.Status = 'Open';
            campaignMember.Locked_By__c = null;
            campaignMember.Root_Cause__c ='Address discrepancy';
            campaignMember.Resolution_Status__c ='Resolved';
            //campaignMember.LastModifiedDate = System.today() - 1;
            //insert campaignMember;
            cmList.add(campaignMember);
            insert cmList;
            
   
        
        //insert campaignMembers;
        Test.startTest();
        String schTime = '0 0 12 * * ?';
        purgeCampaignRecords pcr = new purgeCampaignRecords();
        system.schedule('TestUpdateConAccJob', schTime, pcr);
        //system.AssertException;
        database.executeBatch(pcr);
        Test.stopTest();
        
    }

}
Hi - I am trying to user below query in batch class querylocator, I want to change the lastmodified date from configuration level without touching code. So, I am using custom label and my custom label input field as number and i am passing it in query, but getting error can someone suggest how to fix?

return Database.getQueryLocator([SELECT Id, Status,RecordTypeId, Resolution_Status__c, LastModifiedDate FROM CampaignMember where RecordTypeId ='0120p000000Fy09AAC' AND (Resolution_Status__c ='Resolved' OR Resolution_Status__c ='Closed') AND LastModifiedDate < LAST_N_DAYS:Integer.valueOf(system.Label.LastmodifiedDateforCM)]);

Error: Missing 'INTEGER_LITERAL' at 'Integer.valueOf'
Extra 'IDENTIFIER', at '('.
expecting a number, found 'Integer.valueOf'
Hi - I have created a LWC button to create case using Navigation and I placed in CampaignMember Object. my question here is from my scenario CamapiagnMember is child object and Case is Parent object, I have custom lookup (case__C) field in Camapaign member object. Now, from camapaign member record page i am clicking create case button and creating a case after saving it navigates case reocrd page, but after this i want to get this caserecord id and map it with case__C field in campaign object. is it possible to make or suggest some solution for this? Below is my JS. Thanks!

import { LightningElement, api } from 'lwc';
import {NavigationMixin} from 'lightning/navigation';
import {encodeDefaultFieldValues} from 'lightning/pageReferenceUtils';
import getCMRecord from '@salesforce/apex/HypercareCMManagement.getCMRecord';
//import Case_OBJECT from '@salesforce/schema/Case';
export default class CreateCaseHypercare extends NavigationMixin(LightningElement) {
    campaignMemberRecord;
    error;
    @api recordId;
    //***Navigate to Case Record Page***//
    handleNavigateToCase(){
        getCMRecord({recordID : this.recordId})
       
        .then(result => {
            this.campaignMemberRecord = result;
           
            console.log('caseRecord value is : ' +this.caseRecord);
            const defaultValueCase = encodeDefaultFieldValues({
                RecordTypeId:'0122v000001XBmvAAG',
                AccountId : this.campaignMemberRecord.AccountId__c,
                ContactId: this.campaignMemberRecord.ContactId
            })
            this[NavigationMixin.Navigate]({
                type:'standard__objectPage',
                attributes:{
                    objectApiName: 'Case',
                    actionName:'new'
               
                },
                state:{
                    defaultFieldValues: defaultValueCase
                }
               
             
            })
        })
        .catch(error => {
            this.error = error;
            console.log('error msg'+this.error);
        });

    }
 
}
Hi - I want to create a lightning button (LWC) which should create case and place it in Campaign Member object page layout, also it should auto autopopulate few values from case object such as accountid, contactid, recordtype. can someone help me out. Thanks!
Hi - i want to create handler method for trigger to update the date field for the below scenario.
A BEFORE Trigger (INSERT / UPDATE) on Custom object to update Status_Changed_Date__c and Investigation_Completed_Date__c fields when the Resolution_Status__c field is updated.
For example, when Resolution_Status__c moved from "New" to "Resolved","In Progress" then I want to update Status_Changed_Date__c to today. 
Hi - Recently I have refreshed one of my sandbox, we are using Docusign managed package, we will send the docusign to the users with set of informations those information will be fetched from salesforce from opportunity. 

But after sandbox refreshed, we are facing the issue docusign is not fetching data in salesforce. any idea or resolution how to debug or resolve this issue?
Hi - Below is my get record element block (Contact Object) where I am getting the all related contact record of an account but i want to get based on only one particular Account reccord type.
can someone help how to get this. Thanks!
User-added image

 
Hi - Below is my get record element block where I am getting the all related contact record related to account but i want to get only one particular Account reccord type.

how to get contact records from Account with particular record type from Account.
User-added image
I have lightning flow built in way that if Account has Multiple Contact records , if one contact has been choosed as Primay contact (PrimayContact Checkbox field in Contact object) then other records will set as false in Primary contact checkbox field. 

But, I want to display a alert message in UI when they try to change other contact as primay its accepted to change but need to show alert or warning message stating that (" would to like to change the existing primary contact to new one" )something like that. could someone suggest how can i implement this? Below is flow blocks. Thanks.

User-added image 
Hi - I have this scenario, One Account has multiple contacts and in Contact object we have field called Primary contact checkbox field.

If any one of the related contact  is true in  Primary contact checkbox field then other contacts shoud not have option to check that checkbox field.

How to do this lightning flow? can someone suggest ideas. Thanks

Hi All - I just want to call the apex method which has two paramaeters in when on click button. I have created the Button using LWC and trying to call the apex method , below is my code. can someone correct me if my approach is correct. New to LWC trying to implement this want best way and suggestions.

Apex Method :
@AuraEnabled(cacheable=true)
    public static void recountAssets(Id b2bAccountId, Id b2bOrderId){
        String sDISCOCouponCode;
        List<Id> lstB2BOrderIds = new List<Id>();
        List<String> lstPkgDefCodes = new List<String>();
        List<OrderItem> lstB2BOrderItems = new List<OrderItem>(); //List of all B2B Order Items that requires reconciliation
        //List<Order> lstB2BOrders = new List<Order>();//List of all B2B Orders that requires reconciliation
        
        
        if(b2bAccountId != null){
            Account objB2BAccount = [SELECT ID, DISCOCouponCode__c FROM Account WHERE ID =: b2bAccountId AND RecordType.DeveloperName = 'ACC_B2BCustomer' LIMIT 1];
            if(objB2BAccount != null){
                sDISCOCouponCode = objB2BAccount.DISCOCouponCode__c;
                if(!String.isEmpty(sDISCOCouponCode)){
                    if(b2bOrderId != null){
                        // for(Order o:b2bOrders){
                        //     lstB2BOrderIds.add(o.Id);
                        //     system.debug('lstB2BOrderIds' +lstB2BOrderIds);
                        // }
                        
                        lstB2BOrderItems = [SELECT  Id, OrderId, Package_Definition_Code__c, DISCOCouponCode__c, NoOfActiveSubscriptionsExclBuffer__c, Quantity, Order.NumberOfDigitalSubscriptionSold__c
                            FROM OrderItem WHERE TECH_OrderCategory__c ='Corporate' AND (OrderId =: b2bOrderId OR Order.Original_Subscription__r.Id =: b2bOrderId) AND DISCOCouponCode__c =: sDISCOCouponCode AND Order.Status = 'ACTIVE' AND Order.StartDate__c <= TODAY AND Order.End_Date__c >= TODAY AND Order.B2BProduct__c != 'Anonymous' ORDER BY Order.StartDate__c ASC];
                        system.debug('lstB2BOrderItems' +lstB2BOrderItems);
                    }
                    else{
                        lstB2BOrderItems = [SELECT  Id, OrderId, Package_Definition_Code__c, DISCOCouponCode__c, NoOfActiveSubscriptionsExclBuffer__c, Quantity, Order.NumberOfDigitalSubscriptionSold__c
                            FROM OrderItem WHERE TECH_OrderCategory__c ='Corporate' AND DISCOCouponCode__c =: sDISCOCouponCode AND Order.Status = 'ACTIVE' AND Order.StartDate__c <= TODAY AND Order.End_Date__c >= TODAY AND Order.B2BProduct__c != 'Anonymous' ORDER BY Order.StartDate__c ASC];
                    }

                    // lstB2BOrderIds.clear(); //Repurposing the variable for further use
                    // system.debug('lstB2BOrderIds' +lstB2BOrderIds);
                    if(lstB2BOrderItems.size()>0){
                        
                        for(OrderItem oi:lstB2BOrderItems){
                            lstPkgDefCodes.add(oi.Package_Definition_Code__c); //Prepare the list of package definition codes
                            lstB2BOrderIds.add(oi.OrderId); //Prepare the list of ids of all the B2B orders that will go through active sub count reconciliation
                            oi.NoOfActiveSubscriptionsExclBuffer__c = 0; //Reset the current asset count
                            system.debug(' oi.NoOfActiveSubscriptionsExclBuffer__c ' + oi.NoOfActiveSubscriptionsExclBuffer__c);
                        }
                    }

                    if(lstPkgDefCodes.size()>0){
                        Map<String, Decimal> mapActiveAssetCount = new Map<String, Decimal>(); //Count of all the active assets that requires recounting, grouped by Package Definition Code
                        List<Asset> lstActiveAssets = [SELECT Package_Definition_Code__c, Id FROM Asset
                            WHERE Package_Definition_Code__c IN: lstPkgDefCodes AND Order_Product__r.DISCOCouponCode__c =: sDISCOCouponCode AND Status = 'ACTIVE'];
                        for (Asset a : lstActiveAssets)  {
                            if(mapActiveAssetCount.containsKey(a.Package_Definition_Code__c)){
                                //System.debug('a.Package_Definition_Code__c : ' + a.Package_Definition_Code__c );
                                Decimal nAssetCount = (Decimal) mapActiveAssetCount.get(a.Package_Definition_Code__c);
                                nAssetCount++;
                                system.debug('nAssetCount' +nAssetCount);
                                mapActiveAssetCount.put(a.Package_Definition_Code__c, nAssetCount);
                            }
                            else{
                                mapActiveAssetCount.put(a.Package_Definition_Code__c, 1);
                            }
                        }

                        Map<Id,Decimal> mapTotalActiveSubsInB2BOrder = new map<Id,Decimal>();
                        for(OrderItem oi:lstB2BOrderItems){
                            Decimal nB2BOrderTotalActiveSubs;
                            if(mapTotalActiveSubsInB2BOrder.containsKey(oi.OrderId)){
                                nB2BOrderTotalActiveSubs = mapTotalActiveSubsInB2BOrder.get(oi.OrderId);
                                system.debug('nB2BOrderTotalActiveSubs' +nB2BOrderTotalActiveSubs);
                            }
                            else{
                                nB2BOrderTotalActiveSubs = 0;
                                system.debug('nB2BOrderTotalActiveSubs' +nB2BOrderTotalActiveSubs);
                            }

                            if(mapActiveAssetCount.containsKey(oi.Package_Definition_Code__c)){
                                Decimal nCurrentAssetCountByPkgDefCode = (Decimal) mapActiveAssetCount.get(oi.Package_Definition_Code__c);
                                system.debug('nCurrentAssetCountByPkgDefCode' +nCurrentAssetCountByPkgDefCode);
                                if(nCurrentAssetCountByPkgDefCode > 0){
                                    // System.debug('Package_Definition_Code__c : ' + oi.Package_Definition_Code__c );
                                    // System.debug('nCurrentAssetCountByPkgDefCode : ' + nCurrentAssetCountByPkgDefCode );
                                    
                                    // System.debug('Order.NumberOfDigitalSubscriptionSold__c : ' + oi.Order.NumberOfDigitalSubscriptionSold__c );
                                    // System.debug('nB2BOrderTotalActiveSubs : ' + nB2BOrderTotalActiveSubs );
                                    
                                    if((oi.Order.NumberOfDigitalSubscriptionSold__c >= nCurrentAssetCountByPkgDefCode) && (nB2BOrderTotalActiveSubs < nCurrentAssetCountByPkgDefCode)){
                                        Decimal nCountUp = nCurrentAssetCountByPkgDefCode - nB2BOrderTotalActiveSubs;
                                        oi.NoOfActiveSubscriptionsExclBuffer__c += nCountUp;
                                        nB2BOrderTotalActiveSubs += nCountUp;
                                        nCurrentAssetCountByPkgDefCode -= nCountUp;
                                        system.debug('nCountUp' +nCountUp);
                                    }
                                    else if((oi.Order.NumberOfDigitalSubscriptionSold__c < nCurrentAssetCountByPkgDefCode) && (nB2BOrderTotalActiveSubs < oi.Order.NumberOfDigitalSubscriptionSold__c)){
                                        Decimal nCountUp = oi.Order.NumberOfDigitalSubscriptionSold__c - nB2BOrderTotalActiveSubs;
                                        oi.NoOfActiveSubscriptionsExclBuffer__c += nCountUp;
                                        nB2BOrderTotalActiveSubs += nCountUp;
                                        nCurrentAssetCountByPkgDefCode -= nCountUp;
                                        system.debug('nCountUp' +nCountUp);
                                    }
                                    mapTotalActiveSubsInB2BOrder.put(oi.OrderId, nB2BOrderTotalActiveSubs);
                                    mapActiveAssetCount.put(oi.Package_Definition_Code__c, nCurrentAssetCountByPkgDefCode);
                                }
                            }
                        }

                        update lstB2BOrderItems;
                        system.debug('lstB2BOrderItems' +lstB2BOrderItems);

                        //Reconciling NumberofDigitalSubscriptionsActive__c in B2B Orders
                        if(lstB2BOrderIds.size()>0){
                            List<Order> lstB2BOrders = [SELECT Id, NumberofDigitalSubscriptionsActive__c, TECH_TotalNumberofActiveSubscription__c FROM Order WHERE Id IN: lstB2BOrderIds];
                            system.debug('lstB2BOrders' +lstB2BOrders);
                            if(lstB2BOrders.size()>0){
                                for(Order o : lstB2BOrders){
                                    o.NumberofDigitalSubscriptionsActive__c = o.TECH_TotalNumberofActiveSubscription__c;
                                }
                                update lstB2BOrders;
                            }
                        }
                    }
                }
            }
        }


LWC JS:
import { LightningElement,track  } from 'lwc';
import recountAssets from '@salesforce/apex/B2BActiveAssetsRecountHandler.recountAssets';
export default class ReCountMechforAssetManagement extends LightningElement {
    clickedButtonLabel;
    @track b2bAccountId;
    @track b2bOrderId;
    @track error;
    handleClick(event) {
        this.clickedButtonLabel = event.target.value;
        recountAssets()
        .then(result =>{
            this.b2bAccountId = result;
            this.b2bOrderId = result;
        })
        .catch(error => {
            this.error = error;
        });
        //this.clickedButtonLabel = event.target.label;
    }
}

HTML:

<template>
    <div class="slds-m-top_small slds-m-bottom_medium">
        <!-- Brand outline variant: Identifies the primary action in a group of buttons, but has a lighter look -->
        <lightning-button variant="brand-outline" label="Recount" title="Primary action with lighter look" onclick={handleClick} class="slds-m-left_x-small"></lightning-button>
    </div>
</template>
</template>

Hi - I have one formula field (PackageDefCode) in Asset object which is getting the value from lookup object (this is the formula Rate_Code__r.Package_Definition_Code__c)

In my test class, I am trying to populate the valud for PackageDefCode in Asset object by inserting lookup record with value but in Asset recrod value shows NULL in test class. is ther any soluiton ?

 
Hi - I have this scenario, One Account has multiple contacts and in Contact object we have field called Primary contact checkbox field.

If any one of the related contact  is true in  Primary contact checkbox field then other contacts shoud not have option to check that checkbox field.

Can someone suggest what will be the best solution for this and how we can proceed?
Hi Everyone - I am trying to get the field value of relationhip object and putting in the set though it is not throwing any error but when i try to do system.debug it returns null value. when i tried to do query it returns value. below is my code can some one suggest is my approach is correct or somehwhere i am going wrong?

 Set<String> assetCouponCodes = new Set<String>();
set<id>newOrderItemId = new set<id>();
for (Asset asset : newAssetList) {
            assetCouponCodes.add(asset.Order_Product__r.DISCOCouponCode__c);
             system.debug('assetCouponCodes' +assetCouponCodes);
newOrderItemId.add(asset.Order_Product__r.id);
             system.debug('newOrderItemId' +newOrderItemId);

Thanks!
Hi All - I am facing the below error for trigger though i have filtered the condition using where clause. is there any best practise or suggestable way that i can finetune/tweak the query here?

Error : System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, AssetTrigger2: execution of AfterInsert caused by: System.QueryException: Non-selective query against large object type (more than 200000 rows). Consider an indexed filter or contact salesforce.com about custom indexing. Even if a field is indexed a filter might still not be selective when: 1. The filter value includes null (for instance binding with a list that contains null) 2. Data skew exists whereby the number of matching rows is very large (for instance, filtering for a particular foreign key value that occurs many times) Failing Query: SELECT id, OrderId, Package_Definition_Code__c, DISCOCouponCode__c, TotalActiveSubscriptions__c FROM orderitem WHERE (Package_Definition_Code__c = :tmpVar1 AND DISCOCouponCode__c = :tmpVar2) Current Apex position: AssetTrigger2Helper [47,1] Apex stack: Trigger.AssetTrigger2: line 22, column 1 Class.AssetTrigger2Helper.activeSubsCountB2B: line 47, column 1 Trigger.AssetTrigger2: line 22, column 1: []


Syntax:

public static void activeSubsCountB2B( List<Asset> newAssetList,Map<Id,Asset> oldAssetMap) {
       
        Set<String> assetCouponCodes = new Set<String>();
          Set<String> assetPkgDefs = new Set<String>();
        Map<Id, Asset> assetIdAssetMap = new Map<Id, Asset>();
        
        Set<Id> activeAssetIds = new Set<Id>();
        Set<Id> cancelledAssetIds = new Set<Id>();
        
         for (Asset asset : newAssetList) {
            assetCouponCodes.add(asset.Order_Product__r.DISCOCouponCode__c);
            assetPkgDefs.add(asset.Package_Definition_Code__c);    
            assetIdAssetMap.put(asset.Id, asset);
            if (asset.Status.equals('ACTIVE')) {
                activeAssetIds.add(asset.Id);
            } else if (asset.Status.equals('CANCELLED'))  {
                cancelledAssetIds.add(asset.Id);
            } 
        }
        
        Map<String, Set<Asset>> pkdCCAssetsMap = new Map<String, Set<Asset>>();
        for (Asset asset: newAssetList) {
         
            String pkgDefCCKey = asset.Order_Product__r.DISCOCouponCode__c+'-'+ asset.Package_Definition_Code__c;
            Set<Asset> pkdCCAssets =  pkdCCAssetsMap.containsKey(pkgDefCCKey) ? pkdCCAssetsMap.get(pkgDefCCKey) : new Set<Asset>();
            pkdCCAssets.add(asset);
            pkdCCAssetsMap.put(pkgDefCCKey, pkdCCAssets);
        }
        
       List<OrderItem> assetOrderItems =  [select id,OrderId, Package_Definition_Code__c, DISCOCouponCode__c, TotalActiveSubscriptions__c from orderitem where
         Package_Definition_Code__c =: assetPkgDefs and DISCOCouponCode__c =: assetCouponCodes];
        
           Map<Id, OrderItem> assetOrderItemsMap = new Map<Id, OrderItem>();
        Map<Id, OrderItem> updateableOrderItems = new Map<Id, OrderItem>();
        Map<Id, Set<Asset>> orderItemIdAssetsMap = new Map<Id, Set<Asset>>();
        Map<Id, Order> orderMap = new Map<Id, Order>(); 
Hi All - I am trying to embed external web page in Salesforce Account record page using Aura component, I am trying the below approach which is working for me but need better way without harding the URL and passing the account id as well. can some one help me out on this.

<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes" access="global" >
    <iframe src="https://externalwebpage?id=XXXXXX"            
            width="100%"
            height="500px"
            sandbox="allow-same-origin allow-scripts allow-forms"
            scrolling="auto"/>
    
</aura:component>
Hi All - I am Deleting the records using Btach class, but it is hard deleting it and not getting stored in Recycle bin, as part of business purpose we need this data to be stored for few days in Recycle bin, So i am trying to Soft Delete the records by making isDeleted field to true, but I am getting error that the field is not writtable, is there any alternative way to soft delete the records using apex code. Thanks! Here is my execute method code.

 global void execute(Database.BatchableContext BC , List<CampaignMember> campaignMemberScope) {
        
        system.debug('CM Records' + campaignMemberScope);
        for(CampaignMember camMemberIsDeletedTrue:campaignMemberScope){
            if(campaignMemberScope !=NULL && campaignMemberScope.size()>0){
                try{
                    //camMemberIsDeletedTrue.IsDeleted = true;
                    //Database.DeleteResult[] result =  Database.delete(campaignMemberScope, false);
                } catch(Exception e){
                    system.debug('Exception Caught:' +e.getmessage());
                }
            }
        }
    }
 
Hi All - I am trying to cover the test class for batch apex, but i could not able to cover execute method since my test record does not match the query condition (lastmodifiedDate) in batch apex so scope does not returning record. can some one help how to cover the execute method here. Thanks!

User-added image
Here is my Test Class:

@isTest
public class TestpurgeCampaignRecords {
    static testMethod void TestpurgeCampaignRecordsMethod(){
           
          //List<CampaignMember> campaignMembers = new List<CampaignMember>();
          Contact c = new Contact(
                FirstName = 'User',
                LastName = 'Test ' );
           insert c;
           Id cMRecordId = Schema.SObjectType.CampaignMember.getRecordTypeInfosByName().get('Hypercare Customer').getRecordTypeId();
           Campaign campaign = new Campaign(Name = 'Test Campaign ',IsActive = true, CampaignMemberRecordTypeId=cMRecordId);
           insert campaign;
           string recordTypeId =system.Label.CampaignMemberRecordtype;
           system.debug('recordTypeId'  +recordTypeId);
           integer dayCounts = Integer.valueof(system.label.LastmodifiedDateforCM);
           system.debug('dayCounts'  +dayCounts);
            list<CampaignMember> cmList = new List<CampaignMember>();
            CampaignMember campaignMember = new CampaignMember();
            campaignMember.ContactId = c.Id;
            //campaignMember.RecordTypeId = cMRecordId;
            campaignMember.CampaignId = campaign.Id;
            campaignMember.LeadId=null;
            campaignMember.Status = 'Open';
            campaignMember.Locked_By__c = null;
            campaignMember.Root_Cause__c ='Address discrepancy';
            campaignMember.Resolution_Status__c ='Resolved';
            //campaignMember.LastModifiedDate = System.today() - 1;
            //insert campaignMember;
            cmList.add(campaignMember);
            insert cmList;
           
       
   //insert campaignMembers;
        Test.startTest();
        String schTime = '0 0 12 * * ?';
        purgeCampaignRecords pcr = new purgeCampaignRecords();
        system.schedule('TestUpdateConAccJob', schTime, pcr);
        //system.AssertException;
        database.executeBatch(pcr);
        //System.assertEquals(1, [SELECT COUNT() FROM CampaignMember WHERE Id = :cmList[0].id]);
        Test.stopTest();
        
    }
 
Hi - i want to create handler method for trigger to update the date field for the below scenario.
A BEFORE Trigger (INSERT / UPDATE) on Custom object to update Status_Changed_Date__c and Investigation_Completed_Date__c fields when the Resolution_Status__c field is updated.
For example, when Resolution_Status__c moved from "New" to "Resolved","In Progress" then I want to update Status_Changed_Date__c to today. 
Hi - Below is my get record element block (Contact Object) where I am getting the all related contact record of an account but i want to get based on only one particular Account reccord type.
can someone help how to get this. Thanks!
User-added image

 
Hi - Below is my get record element block where I am getting the all related contact record related to account but i want to get only one particular Account reccord type.

how to get contact records from Account with particular record type from Account.
User-added image
Hi - I have this scenario, One Account has multiple contacts and in Contact object we have field called Primary contact checkbox field.

If any one of the related contact  is true in  Primary contact checkbox field then other contacts shoud not have option to check that checkbox field.

How to do this lightning flow? can someone suggest ideas. Thanks

Hi All - I just want to call the apex method which has two paramaeters in when on click button. I have created the Button using LWC and trying to call the apex method , below is my code. can someone correct me if my approach is correct. New to LWC trying to implement this want best way and suggestions.

Apex Method :
@AuraEnabled(cacheable=true)
    public static void recountAssets(Id b2bAccountId, Id b2bOrderId){
        String sDISCOCouponCode;
        List<Id> lstB2BOrderIds = new List<Id>();
        List<String> lstPkgDefCodes = new List<String>();
        List<OrderItem> lstB2BOrderItems = new List<OrderItem>(); //List of all B2B Order Items that requires reconciliation
        //List<Order> lstB2BOrders = new List<Order>();//List of all B2B Orders that requires reconciliation
        
        
        if(b2bAccountId != null){
            Account objB2BAccount = [SELECT ID, DISCOCouponCode__c FROM Account WHERE ID =: b2bAccountId AND RecordType.DeveloperName = 'ACC_B2BCustomer' LIMIT 1];
            if(objB2BAccount != null){
                sDISCOCouponCode = objB2BAccount.DISCOCouponCode__c;
                if(!String.isEmpty(sDISCOCouponCode)){
                    if(b2bOrderId != null){
                        // for(Order o:b2bOrders){
                        //     lstB2BOrderIds.add(o.Id);
                        //     system.debug('lstB2BOrderIds' +lstB2BOrderIds);
                        // }
                        
                        lstB2BOrderItems = [SELECT  Id, OrderId, Package_Definition_Code__c, DISCOCouponCode__c, NoOfActiveSubscriptionsExclBuffer__c, Quantity, Order.NumberOfDigitalSubscriptionSold__c
                            FROM OrderItem WHERE TECH_OrderCategory__c ='Corporate' AND (OrderId =: b2bOrderId OR Order.Original_Subscription__r.Id =: b2bOrderId) AND DISCOCouponCode__c =: sDISCOCouponCode AND Order.Status = 'ACTIVE' AND Order.StartDate__c <= TODAY AND Order.End_Date__c >= TODAY AND Order.B2BProduct__c != 'Anonymous' ORDER BY Order.StartDate__c ASC];
                        system.debug('lstB2BOrderItems' +lstB2BOrderItems);
                    }
                    else{
                        lstB2BOrderItems = [SELECT  Id, OrderId, Package_Definition_Code__c, DISCOCouponCode__c, NoOfActiveSubscriptionsExclBuffer__c, Quantity, Order.NumberOfDigitalSubscriptionSold__c
                            FROM OrderItem WHERE TECH_OrderCategory__c ='Corporate' AND DISCOCouponCode__c =: sDISCOCouponCode AND Order.Status = 'ACTIVE' AND Order.StartDate__c <= TODAY AND Order.End_Date__c >= TODAY AND Order.B2BProduct__c != 'Anonymous' ORDER BY Order.StartDate__c ASC];
                    }

                    // lstB2BOrderIds.clear(); //Repurposing the variable for further use
                    // system.debug('lstB2BOrderIds' +lstB2BOrderIds);
                    if(lstB2BOrderItems.size()>0){
                        
                        for(OrderItem oi:lstB2BOrderItems){
                            lstPkgDefCodes.add(oi.Package_Definition_Code__c); //Prepare the list of package definition codes
                            lstB2BOrderIds.add(oi.OrderId); //Prepare the list of ids of all the B2B orders that will go through active sub count reconciliation
                            oi.NoOfActiveSubscriptionsExclBuffer__c = 0; //Reset the current asset count
                            system.debug(' oi.NoOfActiveSubscriptionsExclBuffer__c ' + oi.NoOfActiveSubscriptionsExclBuffer__c);
                        }
                    }

                    if(lstPkgDefCodes.size()>0){
                        Map<String, Decimal> mapActiveAssetCount = new Map<String, Decimal>(); //Count of all the active assets that requires recounting, grouped by Package Definition Code
                        List<Asset> lstActiveAssets = [SELECT Package_Definition_Code__c, Id FROM Asset
                            WHERE Package_Definition_Code__c IN: lstPkgDefCodes AND Order_Product__r.DISCOCouponCode__c =: sDISCOCouponCode AND Status = 'ACTIVE'];
                        for (Asset a : lstActiveAssets)  {
                            if(mapActiveAssetCount.containsKey(a.Package_Definition_Code__c)){
                                //System.debug('a.Package_Definition_Code__c : ' + a.Package_Definition_Code__c );
                                Decimal nAssetCount = (Decimal) mapActiveAssetCount.get(a.Package_Definition_Code__c);
                                nAssetCount++;
                                system.debug('nAssetCount' +nAssetCount);
                                mapActiveAssetCount.put(a.Package_Definition_Code__c, nAssetCount);
                            }
                            else{
                                mapActiveAssetCount.put(a.Package_Definition_Code__c, 1);
                            }
                        }

                        Map<Id,Decimal> mapTotalActiveSubsInB2BOrder = new map<Id,Decimal>();
                        for(OrderItem oi:lstB2BOrderItems){
                            Decimal nB2BOrderTotalActiveSubs;
                            if(mapTotalActiveSubsInB2BOrder.containsKey(oi.OrderId)){
                                nB2BOrderTotalActiveSubs = mapTotalActiveSubsInB2BOrder.get(oi.OrderId);
                                system.debug('nB2BOrderTotalActiveSubs' +nB2BOrderTotalActiveSubs);
                            }
                            else{
                                nB2BOrderTotalActiveSubs = 0;
                                system.debug('nB2BOrderTotalActiveSubs' +nB2BOrderTotalActiveSubs);
                            }

                            if(mapActiveAssetCount.containsKey(oi.Package_Definition_Code__c)){
                                Decimal nCurrentAssetCountByPkgDefCode = (Decimal) mapActiveAssetCount.get(oi.Package_Definition_Code__c);
                                system.debug('nCurrentAssetCountByPkgDefCode' +nCurrentAssetCountByPkgDefCode);
                                if(nCurrentAssetCountByPkgDefCode > 0){
                                    // System.debug('Package_Definition_Code__c : ' + oi.Package_Definition_Code__c );
                                    // System.debug('nCurrentAssetCountByPkgDefCode : ' + nCurrentAssetCountByPkgDefCode );
                                    
                                    // System.debug('Order.NumberOfDigitalSubscriptionSold__c : ' + oi.Order.NumberOfDigitalSubscriptionSold__c );
                                    // System.debug('nB2BOrderTotalActiveSubs : ' + nB2BOrderTotalActiveSubs );
                                    
                                    if((oi.Order.NumberOfDigitalSubscriptionSold__c >= nCurrentAssetCountByPkgDefCode) && (nB2BOrderTotalActiveSubs < nCurrentAssetCountByPkgDefCode)){
                                        Decimal nCountUp = nCurrentAssetCountByPkgDefCode - nB2BOrderTotalActiveSubs;
                                        oi.NoOfActiveSubscriptionsExclBuffer__c += nCountUp;
                                        nB2BOrderTotalActiveSubs += nCountUp;
                                        nCurrentAssetCountByPkgDefCode -= nCountUp;
                                        system.debug('nCountUp' +nCountUp);
                                    }
                                    else if((oi.Order.NumberOfDigitalSubscriptionSold__c < nCurrentAssetCountByPkgDefCode) && (nB2BOrderTotalActiveSubs < oi.Order.NumberOfDigitalSubscriptionSold__c)){
                                        Decimal nCountUp = oi.Order.NumberOfDigitalSubscriptionSold__c - nB2BOrderTotalActiveSubs;
                                        oi.NoOfActiveSubscriptionsExclBuffer__c += nCountUp;
                                        nB2BOrderTotalActiveSubs += nCountUp;
                                        nCurrentAssetCountByPkgDefCode -= nCountUp;
                                        system.debug('nCountUp' +nCountUp);
                                    }
                                    mapTotalActiveSubsInB2BOrder.put(oi.OrderId, nB2BOrderTotalActiveSubs);
                                    mapActiveAssetCount.put(oi.Package_Definition_Code__c, nCurrentAssetCountByPkgDefCode);
                                }
                            }
                        }

                        update lstB2BOrderItems;
                        system.debug('lstB2BOrderItems' +lstB2BOrderItems);

                        //Reconciling NumberofDigitalSubscriptionsActive__c in B2B Orders
                        if(lstB2BOrderIds.size()>0){
                            List<Order> lstB2BOrders = [SELECT Id, NumberofDigitalSubscriptionsActive__c, TECH_TotalNumberofActiveSubscription__c FROM Order WHERE Id IN: lstB2BOrderIds];
                            system.debug('lstB2BOrders' +lstB2BOrders);
                            if(lstB2BOrders.size()>0){
                                for(Order o : lstB2BOrders){
                                    o.NumberofDigitalSubscriptionsActive__c = o.TECH_TotalNumberofActiveSubscription__c;
                                }
                                update lstB2BOrders;
                            }
                        }
                    }
                }
            }
        }


LWC JS:
import { LightningElement,track  } from 'lwc';
import recountAssets from '@salesforce/apex/B2BActiveAssetsRecountHandler.recountAssets';
export default class ReCountMechforAssetManagement extends LightningElement {
    clickedButtonLabel;
    @track b2bAccountId;
    @track b2bOrderId;
    @track error;
    handleClick(event) {
        this.clickedButtonLabel = event.target.value;
        recountAssets()
        .then(result =>{
            this.b2bAccountId = result;
            this.b2bOrderId = result;
        })
        .catch(error => {
            this.error = error;
        });
        //this.clickedButtonLabel = event.target.label;
    }
}

HTML:

<template>
    <div class="slds-m-top_small slds-m-bottom_medium">
        <!-- Brand outline variant: Identifies the primary action in a group of buttons, but has a lighter look -->
        <lightning-button variant="brand-outline" label="Recount" title="Primary action with lighter look" onclick={handleClick} class="slds-m-left_x-small"></lightning-button>
    </div>
</template>
</template>

Hi - I have one formula field (PackageDefCode) in Asset object which is getting the value from lookup object (this is the formula Rate_Code__r.Package_Definition_Code__c)

In my test class, I am trying to populate the valud for PackageDefCode in Asset object by inserting lookup record with value but in Asset recrod value shows NULL in test class. is ther any soluiton ?

 
Hi Everyone - I am trying to get the field value of relationhip object and putting in the set though it is not throwing any error but when i try to do system.debug it returns null value. when i tried to do query it returns value. below is my code can some one suggest is my approach is correct or somehwhere i am going wrong?

 Set<String> assetCouponCodes = new Set<String>();
set<id>newOrderItemId = new set<id>();
for (Asset asset : newAssetList) {
            assetCouponCodes.add(asset.Order_Product__r.DISCOCouponCode__c);
             system.debug('assetCouponCodes' +assetCouponCodes);
newOrderItemId.add(asset.Order_Product__r.id);
             system.debug('newOrderItemId' +newOrderItemId);

Thanks!
Hi All - I am facing the below error for trigger though i have filtered the condition using where clause. is there any best practise or suggestable way that i can finetune/tweak the query here?

Error : System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, AssetTrigger2: execution of AfterInsert caused by: System.QueryException: Non-selective query against large object type (more than 200000 rows). Consider an indexed filter or contact salesforce.com about custom indexing. Even if a field is indexed a filter might still not be selective when: 1. The filter value includes null (for instance binding with a list that contains null) 2. Data skew exists whereby the number of matching rows is very large (for instance, filtering for a particular foreign key value that occurs many times) Failing Query: SELECT id, OrderId, Package_Definition_Code__c, DISCOCouponCode__c, TotalActiveSubscriptions__c FROM orderitem WHERE (Package_Definition_Code__c = :tmpVar1 AND DISCOCouponCode__c = :tmpVar2) Current Apex position: AssetTrigger2Helper [47,1] Apex stack: Trigger.AssetTrigger2: line 22, column 1 Class.AssetTrigger2Helper.activeSubsCountB2B: line 47, column 1 Trigger.AssetTrigger2: line 22, column 1: []


Syntax:

public static void activeSubsCountB2B( List<Asset> newAssetList,Map<Id,Asset> oldAssetMap) {
       
        Set<String> assetCouponCodes = new Set<String>();
          Set<String> assetPkgDefs = new Set<String>();
        Map<Id, Asset> assetIdAssetMap = new Map<Id, Asset>();
        
        Set<Id> activeAssetIds = new Set<Id>();
        Set<Id> cancelledAssetIds = new Set<Id>();
        
         for (Asset asset : newAssetList) {
            assetCouponCodes.add(asset.Order_Product__r.DISCOCouponCode__c);
            assetPkgDefs.add(asset.Package_Definition_Code__c);    
            assetIdAssetMap.put(asset.Id, asset);
            if (asset.Status.equals('ACTIVE')) {
                activeAssetIds.add(asset.Id);
            } else if (asset.Status.equals('CANCELLED'))  {
                cancelledAssetIds.add(asset.Id);
            } 
        }
        
        Map<String, Set<Asset>> pkdCCAssetsMap = new Map<String, Set<Asset>>();
        for (Asset asset: newAssetList) {
         
            String pkgDefCCKey = asset.Order_Product__r.DISCOCouponCode__c+'-'+ asset.Package_Definition_Code__c;
            Set<Asset> pkdCCAssets =  pkdCCAssetsMap.containsKey(pkgDefCCKey) ? pkdCCAssetsMap.get(pkgDefCCKey) : new Set<Asset>();
            pkdCCAssets.add(asset);
            pkdCCAssetsMap.put(pkgDefCCKey, pkdCCAssets);
        }
        
       List<OrderItem> assetOrderItems =  [select id,OrderId, Package_Definition_Code__c, DISCOCouponCode__c, TotalActiveSubscriptions__c from orderitem where
         Package_Definition_Code__c =: assetPkgDefs and DISCOCouponCode__c =: assetCouponCodes];
        
           Map<Id, OrderItem> assetOrderItemsMap = new Map<Id, OrderItem>();
        Map<Id, OrderItem> updateableOrderItems = new Map<Id, OrderItem>();
        Map<Id, Set<Asset>> orderItemIdAssetsMap = new Map<Id, Set<Asset>>();
        Map<Id, Order> orderMap = new Map<Id, Order>(); 
Hi - Click2Create button from SF maps is autopoulating the address fields based on the address we choose from the map and also based on field set crearted, but now it not auto-populating since it is salesforce standard functionality does anyone facing the same issue or any know issue raised? can someone help on this?
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>