• Venkata Shiva Koushik Rachapudi
  • NEWBIE
  • 15 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 8
    Replies
Hello Everyone, we have enabled account logo in salesforce org. after the Account Logo was enabled, salesforce provided us with few images for known accounts, and when requested for existing small name customers we were told that not all accounts have their logo's associated in salesforce database, so we would require to manually upload the file on our end. so i wanted to know how to associate a logo with an account and how to query it from data migrator tool?
Please look at the campaign member detail page
right on the detail page we notice the contact and campaign to be a lookup which on click redirects us to the page, users requested that we have the same thing for a account. we have a text field on the top for account but it would be great if someone can assist how to get a lookup field.
Thank you
I have a batch class that deletes a query in which the condition states if certain checkbox == true delete that record.
i have got that batch class running perfectly and is scheduled for daily, all i need to know now is, Is there a way to get the list of deleted Scope in Email without the email cutting it short i.e if 200 records are deleted i would need the Name(Fname+LName) and Email Id sent out to my email. or atleast as a CSV file so as to verify if important data is deleted too.
Trigger

trigger SDS_AE_onAccount on Account (before update) {
//load salesmapping table in memory
List<Sales_mapping__c> Shiva = [Select OwnerId, mapping_type__c,AE__c from sales_mapping__c];    
List<Account> UpdateSDSAE = new List<Account>();
    for(account a: Trigger.new)
    {
        if(a.Owner_profile__c == 'SDS' || a.Owner_profile__c == 'SDS Manager')
        {
            a.SDS__c = a.OwnerId;
            UpdateSDSAE.add(a);
        }
        else if(a.Owner_Profile__c=='AE' && trigger.Oldmap.get(a.Id).SDS__c == trigger.Newmap.get(a.Id).SDS__c)
        {
          a.AE__c = a.OwnerId;
            UpdateSDSAE.add(a);
            SDSAD.SSDSD(UpdateSDSAE);
            //look up the salesmapping table in memory
                
        }
        else if(a.AE__c != null && trigger.oldmap.get(a.id).AE__c != trigger.newmap.get(a.id).AE__c){
            SDSAD.SSDSD(UpdateSDSAE);            
        }
        }
}


-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Class  and Method : 

public class SDSAD {
    public static void SSDSD(List<Account>UpdateSDSAE){
    list<account> shiva = [Select Id, AE__c from Account where Id In: UpdateSDSAE];
    list<sales_mapping__c> Koushik = [Select Id, AE__c, mapping_type__c,SDS__c from Sales_mapping__c];
        for(account a : shiva){
            for(sales_mapping__c s: koushik) {
                if (a.AE__c == s.AE__c && s.mapping_type__c == 'AE/SDS'){
                a.SDS__c = s.SDS__c;                    
                }
                else if(a.AE__c == s.AE__c && s.mapping_type__c == 'AE/IWAE'){
                    a.iWayAE__c = s.sds__c; 
                }
            }
        }
    }
}

The trigger calls the class based on condition, but i need to bulkify the class without changing the functionality.

Note : Account and Sales_Mapping__c Objects are not related in any way, the sales mapping Object has all mapped AE and SDS users, hence i need to get SDS value from Sales_mapping__c object when AE is the account owner.
I am loading the user table data to datatable using LWC, the users who has not logging past two months. When the page loads first time I load all the list to front end and using pagination Im going through the records instead going to the server again. Based on the list we can deactivate the users or exclude the user using a checkbox.

Initially all checkbox should come as true but only first page will checked as true. The other pages checkboxes are not checked. Pre selected Row Ids are send to the UI via controller to checked or unchecked. Another issue I faced is the selected checkboxes are not selected when move to another page and coming back to the same page. The selected Ids will be send to the system by clicking the Deactivate Users button.

The Page 1 Checkboxes are pre selected as below when page loads first time,
The Page 1 Checkboxes are pre selected as below,

Page 2 other any other pages checkboxes are not selected. (selected-rows= {preSelectedRows})
Page 2 other any other pages checkboxes are not selected. (selected-rows= {preSelectedRows})

Wrapper Class
 
public class UserMngtWrapper {

//User Id
public String UserId {get; set;}
public String FullName {get; set;}
public String Email {get; set;}
//User ProfileName
public String ProfileName {get; set;}
//User RoleName
public String RoleName {get; set;}
//User is Frozen
public String isFrozen {get; set;}
//User Last Login Date
public Datetime LastLoginDate {get; set;}
//User Last Modified Date by user
public String LastModifiedDate {get; set;}
//User Created Date
public String CreatedDate {get; set;}
//User is Active
public String isActive {get; set;}
//User is Deactivated
public String isDeactivate {get; set;}
}

Controller
 
public class UserManagementController {

@AuraEnabled(cacheable=true)
public static string getUserList() {
    List<UserMngtWrapper> userMngtWrapperList = new List<UserMngtWrapper>();
    UserListMngtWrapper userListMngtWrapper = new UserListMngtWrapper();
    Set<Id> selectedIdSet = new Set<Id>();
    //Get last two months inactive users
    Set<ID> inactiveUserIds = new Map<Id,User>([SELECT id From User
                                                WHERE LastLoginDate < LAST_N_DAYS: 60
                                                      AND IsActive = TRUE                                                                                                                
                                                      AND CreatedDate < LAST_N_DAYS: 60
                                                ]).keySet();
    //Get last two months inactive users Data
    List<User> userList = [Select  id,Profile.Name,Name,Email,UserRole.Name,LastLoginDate,LastModifiedDate,CreatedDate,IsActive,IsDeactivate__c   FROM User where id= : inactiveUserIds order by Profile.Name asc,Name asc];
    
    for (User u : userList)
    {
        UserMngtWrapper userMngtWrapper = new UserMngtWrapper();
        userMngtWrapper.UserId = u.id;
        userMngtWrapper.FullName = (u.Name != null ) ? u.Name: '';
        userMngtWrapper.Email = (u.Email != null ) ? u.Email: '';
        userMngtWrapper.LastLoginDate =  u.LastLoginDate;
        userMngtWrapper.ProfileName =  (u.Profile.Name != null ) ? u.Profile.Name: '';
        userMngtWrapper.RoleName =  (u.UserRole.Name != null ) ? u.UserRole.Name: '';
        userMngtWrapper.isDeactivate =  (u.IsDeactivate__c == false  ) ? 'FALSE': 'TRUE' ;
        userMngtWrapperList.add(userMngtWrapper);
        selectedIdSet.add(u.Id);
    }

    userListMngtWrapper.userMngtWrapperList = userMngtWrapperList;
    userListMngtWrapper.selectedUserIdSet = selectedIdSet;
    return JSON.serialize(userListMngtWrapper);
}


@AuraEnabled(cacheable=true)
public static Boolean userRecordsUpdate() {
   // inprogress
    Return true;
}

//Wrapper List Class
public class UserListMngtWrapper{
    @AuraEnabled public List<UserMngtWrapper> userMngtWrapperList {get; set;}
    @AuraEnabled public set<Id> selectedUserIdSet {get; set;}
}

JS
 
import { LightningElement , track, wire,api } from 'lwc';
import getUserList from '@salesforce/apex/UserManagementController.getUserList';
import userRecordsUpdate from '@salesforce/apex/UserManagementController.userRecordsUpdate';
import {refreshApex} from '@salesforce/apex';

export default class Usermanagement extends LightningElement {
 @track  columns = [
    { label: 'User Id',fieldName: 'UserId',type: 'text',sortable: false,cellAttributes: { alignment: 'left' },initialWidth: 200,},
    { label: 'Name',fieldName: 'FullName',type: 'text',sortable: false,cellAttributes: { alignment: 'left' },initialWidth: 200,},
    { label: 'Email',fieldName: 'Email',type: 'text',sortable: false,cellAttributes: { alignment: 'left' },initialWidth: 200,},
    { label: 'Profile Name',fieldName: 'ProfileName',type: 'text',sortable: false,cellAttributes: { alignment: 'left' },initialWidth: 200,},
    { label: 'Role Name',fieldName: 'RoleName',type: 'text',sortable: false,cellAttributes: { alignment: 'left' },initialWidth: 200,},
    {
            label: "Last Login Date",
            fieldName: "LastLoginDate",
            type: "date",
            typeAttributes:{
                year: "numeric",
                month: "2-digit",
                day: "2-digit",
                hour: "2-digit",
                minute: "2-digit",
                second: "2-digit"
            },
            sortable: false,cellAttributes: { alignment: 'left' },
            initialWidth: 200,
        },
        { label: 'Deactivate',fieldName: 'isDeactivate',type: 'text',sortable: false,cellAttributes: { alignment: 'left' },initialWidth: 200,}

];

     @track showLoadingSpinner = false;
     @track error;
     @track page = 1;
     @track perpage = 5;
     @track pages = [];
     @track disabledConditionNext =false;
     @track disabledConditionPrev =false;
     @track disabledCondition = true;
     @track preSelectedRows=[];
     @track totalRecordCount=0;
     data=[];
     @track numberOfPages =1;
     numOfPreviousPages;
     set_size = 5;
     
     connectedCallback() {
        this.init();
     }
    
     async init()
     {
                 try {
                this.disabledCondition = true;
                this.showLoadingSpinner = true;
                await getUserList()
                 .then((result,error) => {
                     var userList = JSON.parse(result);

                     if (userList) {
this.data=userList.userMngtWrapperList;
                         this.preSelectedRows = userList.selectedUserIdSet;
                         this.data = this.data;
                        this.totalRecordCount = this.data.length;
                     } else if (error) {
                         console.error(error);
                     }
                 });
                    this.disabledConditionPrev =false;
                    this.disabledConditionNext =false;
                    this.disabledCondition = false;
                    this.setPages(this.data);
                    this.showLoadingSpinner = false;

             } catch (error) {
                      this.error = error;
                  } finally {
                      this.showLoadingSpinner = false;
                  }
         }
         
         get currentPageData(){
                       return this.pageData();
                    }
         
         get pagesList(){
        let mid = Math.floor(this.set_size/2) + 1 ;
        if(this.page > mid){
            return this.pages.slice(this.page-mid, this.page+mid-1);
        }
            return this.pages.slice(0,this.set_size);
     }
     
        pageData = ()=>{
                             let numberOfPages = Math.ceil(this.data.length / this.perpage);
                             this.numberOfPages = numberOfPages;
                             let page = this.page;
                             let perpage = this.perpage;
                             let startIndex = (page*perpage) - perpage;
                             let endIndex = (page*perpage);
                             if(this.numberOfPages < 1)
                             {
                                this.disabledConditionPrev =true;
                                this.disabledConditionNext =true;
                             }
                             return this.data.slice(startIndex,endIndex);
                          }

        setPages = (data)=>{
                                      let numberOfPages = Math.ceil(data.length / this.perpage);
                                      this.numOfPreviousPages = numberOfPages;

                                  }


        onNext = ()=>{
                                      if(this.page < this.numberOfPages){
                                         ++this.page;
                                          this.disabledConditionNext =false;
                                          this.disabledConditionPrev =false;
                                          this.hasPageChanged =true;
                                         
                                      }
                                      else {
                                          this.disabledConditionNext =true;                            this.disabledConditionPrev =false;

                                      }

                                  }

        onPrev = ()=>{
                                      if(this.page > 1){
                                            --this.page;
                                            this.disabledConditionPrev =false;
                                            this.disabledConditionNext =false;
                                      }
                                      else {
                                            this.disabledConditionPrev =true;
                                            this.disabledConditionNext =false;
                                      }
                                  }

      onFirst = ()=>{
              this.page = 1;
              }

      onLast = ()=>{
              this.page = this.numberOfPages;
              }

              onPageClick = (e)=>{
                        this.page = parseInt(e.target.dataset.id,10);
                        if(this.numberOfPages < 1)
                        {
                            this.disabledConditionPrev =true;
                            this.disabledConditionNext =true;
                        }
                        else
                        {
                             this.disabledConditionPrev =false;
                             this.disabledConditionNext =false;
                        }
                    }

       // Method didnt develop and test
    updateRecords(){
             var selectedRecords =
              this.template.querySelector("lightning-datatable").getSelectedRows();
              let arrset = [];
              selectedRecords.forEach(row => {
                                 arrset.push(row.userId);
                             });
              userRecordsUpdate()
             .then(result=>{
               return refreshApex(this.refreshTable);
             })
             .catch(error=>{
               alert('Could not update(error));
             })
           }
 
<template>
    <lightning-card   title="User Management" icon-name="standard:user" class="slds-col slds-size_12-of-12 slds-p-top_small">
        <lightning-button slot="actions" label="Deactivate Users" onclick={updateRecords}></lightning-button>
        <div class="slds-p-left_medium">
            <div class="slds-col slds-size_12-of-12 slds-p-top_medium">
                <div class="slds-p-around_medium lgc-bg">

                    <lightning-datatable
                            key-field="UserId"
                            columns={columns}
                            data={currentPageData}
                            selected-rows= {preSelectedRows}
                            onrowaction={getRowActions}
                            >
                    </lightning-datatable>
                </div>

                <div class="slds-col slds-size_10-of-12 slds-p-top_medium">
                    <lightning-layout multiple-rows="true">
                        <lightning-layout-item size = "12" margin= "around-small">
                            <div class="slds-align_absolute-center">
                                <ul class="slds-button-group-row">
                                    <li class="slds-button-group-item" >
                                        <button class="slds-button slds-button_neutral" disabled={disabledCondition} onclick ={onFirst}> First
                                        </button>
                                    </li>
                                    <li class="slds-button-group-item" >
                                        <button class="slds-button slds-button_neutral" disabled={disabledConditionPrev} onclick ={onPrev}> Prev
                                        </button>
                                    </li>

                                    <li class="slds-button-group-item" >
                                        <button class="slds-button slds-button_neutral"  disabled={disabledConditionNext} onclick={onNext} >Next</button>
                                    </li>
                                    <li class="slds-button-group-item" >
                                        <button class="slds-button slds-button_neutral"  disabled={disabledCondition} onclick ={onLast}> Last
                                        </button>
                                    </li>
                                </ul>
                            </div>
                            </br>
                            <div class="slds-align_absolute-center" >
                                <span>Total Records: {totalRecordCount} </span>
                            </div>
                            <div class="slds-align_absolute-center" >
                                <span>Page ({page} of {numberOfPages}) </span>
                            </div>


                        </lightning-layout-item>
                    </lightning-layout>
                </div>
            </div>
        </div>
        <div if:true={showLoadingSpinner}>
            <lightning-spinner alternative-text="Loading" size="large"></lightning-spinner>
        </div>
    </lightning-card>
</template>



Summarizing the Issues are,
  1. Pre selected Row Ids are only selected or checked in page 1. Not checked in other pages.(selected-rows= {preSelectedRows})
  2. The selected checkboxes are not selected(checked box unchecked) after move to another page and coming back to the same page. Selected items should remain even going though any paginations and come back to the same page.
Could you please help me on this.Thank you in advance


 
Hello Everyone, we have enabled account logo in salesforce org. after the Account Logo was enabled, salesforce provided us with few images for known accounts, and when requested for existing small name customers we were told that not all accounts have their logo's associated in salesforce database, so we would require to manually upload the file on our end. so i wanted to know how to associate a logo with an account and how to query it from data migrator tool?
Hi,
I am trying to convert a trigger I wrote into an apex class and call the class from the trigger. I am receiving two errors when I copy the code into the class. I am hoping that someone on here can help me or give me a few pointers on what I can do to fix the problem. This is the trigger that fires correctly as a trigger.
trigger RunAssignmentRule on Lead (after update) {
    List<Lead> ls = new List<Lead>();

    for (Lead l : Trigger.new) {
    
    String oldVal = trigger.oldMap.get(l.id).Status;
    
        if (l.Status == 'Open/Requalified' && oldVal <> 'Open/Requalified') {
            ls.add(new Lead(id = l.id));
        }
    }
    
    if (ls.size() > 0) {
    Database.DMLOptions dmo = new Database.DMLOptions();
    dmo.assignmentRuleHeader.useDefaultRule = true;
    Database.update(ls, dmo);
}

}

The trigger makes a lead run back through the lead assignment when its status his open requalified. When I add it to an apen class I get two errors. An unexpected token error on the list and an error on for because it says it expected a } instead of the for. 

Thanks for your help,
Edward

 
Please look at the campaign member detail page
right on the detail page we notice the contact and campaign to be a lookup which on click redirects us to the page, users requested that we have the same thing for a account. we have a text field on the top for account but it would be great if someone can assist how to get a lookup field.
Thank you
I have a batch class that deletes a query in which the condition states if certain checkbox == true delete that record.
i have got that batch class running perfectly and is scheduled for daily, all i need to know now is, Is there a way to get the list of deleted Scope in Email without the email cutting it short i.e if 200 records are deleted i would need the Name(Fname+LName) and Email Id sent out to my email. or atleast as a CSV file so as to verify if important data is deleted too.
What is the maximum list size I can pass to Messaging.sendEmail(list<SingleEmailMessage>)?  I'm sending the email to internal users by specifying their userId using setTargetObjectId, so daily limits shouldn't be a factor.
Hello,
Iam looking a a way to hide a particular section in the standard layout of Account object. What is the better way to do this? If you have any thoughts, please let me know.
JP.