• gowtham murugesan
  • NEWBIE
  • 60 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 18
    Questions
  • 8
    Replies
User-added imageTest class

@isTest 
private class KnowledgeAttachmentUpdateTest {
    @isTest
   public static void tstmethod1(){
        knowledge__kav k = new knowledge__kav();
        k.Title = 'testcentre';
        k.Summary = 'testing value';
        k.UrlName = 'test';
        insert k;
        
        //Create Document
        ContentVersion cv = new ContentVersion();
        cv.Title = 'TestDocument';
        cv.PathOnClient = 'TestDocument.pdf';
        cv.VersionData = Blob.valueOf('Test Content');
        cv.IsMajorVersion = true;
        Insert cv;
        
        //Get Content Version
        Id ContentDocumentIds = [SELECT ContentDocumentId FROM ContentVersion WHERE Id =:cv.Id].ContentDocumentId;
        
        //Create ContentDocumentLink 
        ContentDocumentLink cdl = New ContentDocumentLink();
        cdl.LinkedEntityId = k.Id;
        cdl.ContentDocumentId = ContentDocumentIds;
        cdl.shareType = 'V';
        Insert cdl;
                
        knowledge__kav k1 = new knowledge__kav();
        k1.Id = cdl.LinkedEntityId;
        k1.AttachmentName__c = cv.Title;
        k1.AttachmentFileID__c =  cv.ContentDocumentId;
       
        update k1;      
        
    } 
}
Hello everyone,
 
Execute method is not getting coverd in test class, Provide me the solution for this.

global class UpdateInvoiceAccount implements Schedulable,  Database.Batchable<sObject>
{
    global void execute(SchedulableContext SC) {
        Id batch =  Database.executeBatch(new UpdateInvoiceAccount(),100); 
    }
    
   global Database.QueryLocator start(Database.BatchableContext bc)
   {
      string query  =  'select id,Account__c,AccountNumber__c,LeadOn__c from Invoice__c where AccountNumber__c =\'12868\' and LeadOn__c=\'000\' and Account__r.name=\'Echuca Camera House\''; 
      return Database.getQueryLocator(query);
   }
   global void execute(Database.BatchableContext bc, List<Invoice__c> recordstoprocess)
   {
     list <Invoice__c>Invoicenew=new list<Invoice__c>();
     Map<id,Account> acMap=new Map<id,Account>();
      if(!recordstoprocess.isEmpty())
      {
          Account acts =[select id,Name from account where Name ='Raleru Ltd' and Customer_Account_and_Lead_On__c='12868   000' limit 1] ;
          for (Invoice__c inv: recordstoprocess)
          {
              Invoice__c invoice =(Invoice__c) inv;
              acMap.put(invoice.Account__c,acts);
          }
          for (Invoice__c inv: recordstoprocess)
          {
              Invoice__c invoice =(Invoice__c) inv;
              invoice.Account__c=acMap.get(invoice.Account__c).id;
              Invoicenew.add(invoice);
          }
              update Invoicenew;
      }
   }
   
   global void finish(Database.BatchableContext bc){
   }    
}

thanks.
Public Knowledge for Mobile, Web and Facebook  package is not supporting in lighting ?  Anyone have a customized code for this un-managed package?
Any idea about matching rule that account name should need to match partially. Example ( salesforce private limited -- Sf pvt ltd )


Note: Here Account record not related with lead so I cannot use Fuzzy company name.
Hi all Am facing this issue ,
here whats the mistake?

 set<Id> tIds = new set<Id>();
         List<UserTerritory2Association> lstUserTerritory = [SELECT Id, User.FirstName, User.LastName,Territory2.Name,Territory2Id, Territory2.Territory2Model.Name FROM UserTerritory2Association WHERE UserId =: userinfo.getUserId() and IsActive = True];
        system.debug('lstUserTerritory::::::'+lstUserTerritory);

            for(UserTerritory ut : lstUserTerritory) {
             if(lstUserTerritory != null && !lstUserTerritory.isEmpty()) {
                tIds.add(ut.TerritoryId);
            }
            system.debug('tIds::::::'+tIds);


am getting Invalid type: UserTerritory2Association How to fix this error ?
Trigger :

trigger AccountUpdateTrigger on Invoice__c (after insert) {
    Set<String> customerLeadon = new Set<String>();
    Set<Id> accountId = new Set<Id>();
    Map<Id,String> invoiceMap = new Map<Id,String>();
    Map<String,Id> accountMap = new Map<String,Id>();
    Map<Id,String> accountNameMap = new Map<Id,String>();
    List<Invoice__c> invoiceUpd = new List<Invoice__c>();
    if(Trigger.isAfter && Trigger.isInsert && RecursiveStopping.isRecursive == True){
        RecursiveStopping.isRecursive = false;
        for(Invoice__c inv:Trigger.new){
            if(inv.AccountNumber__c.contains('12868') && inv.LeadOn__c.contains('000')){
                accountId.add(inv.Account__c);
                
              }
          }
        System.debug('ACCId=='+accountId);
        if(accountId.size()>0){
            for(Account acc:[SELECT Id,Name FROM Account WHERE Id IN:accountId]){
                accountNameMap.put(acc.Id,acc.Name);
            }
            for(Invoice__c inv:Trigger.new){
                System.debug('Acc='+inv.Account__c);
                String accName = accountNameMap.get(inv.Account__c);
                if(accName.contains('Echuca Camera House') && inv.AccountNumber__c.contains('12868') && inv.LeadOn__c.contains('000')){
                    customerLeadon.add(inv.AccountNumber__c+'   '+inv.LeadOn__c);
                    invoiceMap.put(inv.Id,inv.AccountNumber__c+'   '+inv.LeadOn__c);
                }
            }
            System.debug('CUST=='+customerLeadon);
            
            if(customerLeadon.size()>0){
                for(Account acc:[SELECT Id,Name,Customer_Account_and_Lead_On__c FROM Account WHERE Customer_Account_and_Lead_On__c IN: customerLeadon]){
                    accountMap.put(acc.Customer_Account_and_Lead_On__c,acc.Id);
                } 
            }
            if(accountMap.size()>0){
                for(Invoice__c inv:Trigger.new){
                    Invoice__c invUpd = new Invoice__c();
                    invUpd.Id = inv.Id ;
                    if(accountMap.get(invoiceMap.get(inv.Id)) != null){
                        invUpd.Account__c = accountMap.get(invoiceMap.get(inv.Id));
                    }
                    invoiceUpd.add(invUpd);
                }
                update invoiceUpd;
            }
        }
    }
}




My Test Class:


@istest
public class AccountUpdateTriggerTest {
    
    @istest
    public static void testData(){
       Account acc = new Account();
       acc.Name = 'Raleru Account';
       acc.Shipping_Address_Maps_To__c = '12868   000';
       acc.Customer_Account_and_Lead_On__c = '12868   000';
       insert acc;
       
       Account acc1 = new Account();
       acc1.Name = 'Echuca Camera House';
       acc1.Shipping_Address_Maps_To__c = '12868   600';
       acc1.Customer_Account_and_Lead_On__c = '12868   600';
       insert acc1;
        
      System.debug('ACC=='+acc);
      System.debug('Acc1=='+acc1);
        
      Invoice__c inv  = new Invoice__c();
      inv.Name = '332456';
      inv.InvoiceNumber__c = '332456';
      inv.Account__c = acc1.Id;
      inv.AccountNumber__c = '12868';
      inv.LeadOn__c = '000';
      insert inv;
      System.debug('CUST SQL='+[SELECT Id,Name,Customer_Account_and_Lead_On__c FROM Account WHERE Customer_Account_and_Lead_On__c =: '12868   000']);  
      
    }
    
}

 
Hi all,

I want to show Account with activity report except last 90 days , I can only show all the "account with activity" but that is not a right one.
so what is the contion for this ,how to achive this?

Kindly provide me the solution for this.
Hi all,

T.adderror('<span><b>Enter Name in format</b></br><b>john smith</b></span>',false);


I used this error message for custom validation in trigger ..its working fine in classic but in lightning is not working ..."error is showing in same line"how to separate this into two line?
Hi all,

I have a custom field called "Amount" 
this my input "123456"
But need to display as "123  456" like this format.
How to include space in this using trigger?
thanks in advance 
Need to send "Generate Password and Notify user"  Link to user Email ,How to achive this,Kindly help me out

This is my code


<apex:page standardController="User" extensions="CreateNewUser" tabStyle="User">

    <apex:form >
        <apex:pageBlock mode="edit">
            <apex:pageMessages />
            <apex:pageBlockButtons >
                <apex:commandButton action="{!save}" value=" Save "></apex:commandButton>
                <apex:commandButton action="{!cancel}" value="Cancel"></apex:commandButton>
                
            </apex:pageBlockButtons>
            
            <apex:pageBlockSection title="User Information" columns="2" collapsible="false">  
                
                <apex:inputField value="{!User.FirstName}"/>
                <apex:inputField value="{!User.UserRoleId}"/>
                <apex:inputField value="{!User.LastName}"/>
                
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="License" for="lic"></apex:outputLabel>
                <apex:selectList id="mgr" value="{!User.Name}" size="1" title="Manager">
                    <apex:selectOptions value="{!license}"></apex:selectOptions>
                    <apex:actionSupport event="onchange" rerender="selectedProfileId"/>
                </apex:selectList>
                </apex:pageBlockSectionItem>
                <apex:inputField value="{!User.alias}"/>
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="Profile" for="pro"></apex:outputLabel>
                    <apex:selectList value="{!User.ProfileId}"  size="1" id="selectedProfileId" >
                    <apex:selectOptions value="{!profile}" />    
                    <apex:selectOptions value="{!profile1}" />
                    </apex:selectList>
                </apex:pageBlockSectionItem>
                <apex:inputField value="{!User.Email}"/>
                <apex:inputField value="{!User.IsActive}"/>
                <apex:inputField value="{!User.Username}"/>
            </apex:pageBlockSection>
            
            <apex:pageBlockSection >
                <apex:inputField value="{!User.CommunityNickName}"/>
                <apex:inputField value="{!User.Extension}"/>
                <apex:inputField value="{!User.Fax}"/>
                <apex:inputField value="{!User.EmployeeNumber}"/>
                <apex:inputField value="{!User.Title}"/>
                <apex:inputField value="{!User.CompanyName}"/>
                <apex:inputField value="{!User.Division}"/>
                <apex:inputField value="{!User.Department}"/>
                <apex:inputField value="{!User.Phone}"/>
                <apex:inputField value="{!User.ReceivesInfoEmails}" />
            </apex:pageBlockSection>
            
            <apex:pageBlockSection columns="1" showHeader="false" title="License">
            </apex:pageBlockSection> 
            <apex:pageBlockSection title="Other Information" columns="1" collapsible="false">
                <apex:inputField value="{!User.EmailEncodingKey}"/>
                <apex:inputField value="{!User.TimeZoneSidKey}"/> 
                <apex:inputField value="{!User.LocaleSidKey}"/>
                <apex:inputField value="{!User.LanguageLocaleKey}"/>
                 </apex:pageBlockSection>
                       
        </apex:pageBlock>
    </apex:form>
</apex:page>
==============
Controller:

public class CreateNewUser{

    
    public User user;
   
    public CreateNewUser(ApexPages.StandardController controller)
    { 
        this.user= (User)controller.getrecord();
        
    }

    
    
    public List<selectOption> getLicense()
    {
        List<selectOption> options = new List<selectOption>();
        options.add(new selectOption('', '- None -')); 
        for (UserLicense users :[SELECT Id,Name FROM UserLicense where Name = 'Partner Community' OR Name='Salesforce'])  
        {    
            options.add(new selectOption(users.Id, users.Name));
            
        }
        return options; 
    }
    
    public List<selectOption> getProfile() {
        List<selectOption> options1 = new List<selectOption>(); 
        options1.add(new selectOption('', '- None -'));
        for (Profile users1 :[SELECT Id,Name FROM Profile where Usertype = 'PowerPartner'])  { 
            options1.add(new selectOption(users1.Id, users1.Name)); 
        } 
        return options1;
    }
}      
Need to add Generate new password and notify user immediately check box  in Visualforce page? kindly help me out
 
This is my code,


global class OpportunityInvoiceReport implements Database.Batchable<sObject>,Schedulable {
    
    global void execute(SchedulableContext SC) {
        Id batch = Database.executeBatch(new OpportunityInvoiceReport(),100);
    }
    global Database.QueryLocator start(Database.BatchableContext BC){
        String query = 'SELECT Id,AccountId,Invoice_Number__c FROM Opportunity WHERE StageName = \'Implementation Complete (MED)\'';
        return Database.getQueryLocator(query);
    }
    
    global void execute(Database.BatchableContext BC, List<Opportunity> scope){
        Set<String> invoiceNumber = new Set<String>();
        Map<String,Opportunity> oppMap = new Map<String,Opportunity>();
        List<Opportunity_Invoices__c> oppInvoiceInsert = new  List<Opportunity_Invoices__c>();
        for(Opportunity opp:scope){
            invoiceNumber.add(opp.Invoice_Number__c);
            oppMap.put(opp.Invoice_Number__c,opp);
        }
        for(Invoice__c invoice:[SELECT Id,Name FROM Invoice__c WHERE Name =:invoiceNumber]){
            Opportunity_Invoices__c oppInvoice = new Opportunity_Invoices__c();
            oppInvoice.Invoice__c = invoice.Id;
            oppInvoice.Account__c = oppMap.get(invoice.Name).AccountId;
            oppInvoice.Opportunity__c = oppMap.get(invoice.Name).Id;
            oppInvoiceInsert.add(oppInvoice);
        }
        insert oppInvoiceInsert;
    }
    
    global void finish(Database.BatchableContext BC){
        System.debug('OpportunityInvoiceReport Batch Successfully COmpleted..!');
    }
}
User-added image







 Am having trouble on dashbord level dynamic filter.

If Lead object have custom Pick list field name "Dealers".
        
        Dealers values are:
            Dealer_A
            Dealer_B    
            Dealer_C

    I Have Two Partner Users called User1,user2

    I have a  dashboard attached above in picture for lead count with dashboard filters(Filter in dashboard level).

    When user1 loggin only Dashboard filter visible like below,
        
        -Dealers equals Dealer_A
        -Dealers equals Dealer_B

    When user2 loggin only Dashboard filter visible  like below,
        
        -Dealers equals Dealer_B
        -Dealers equals Dealer_C
How to achive this? Kindly provide me a solution.
My below  batch class is working fine,kindly give me test class for this,its totally new for me.

global class AccountUndeleteBatchApex implements Database.Batchable<sObject>{
    global Database.queryLocator start(Database.BatchableContext bc){
        String query = 'SELECT Id,Name FROM Account WHERE     IsDeleted = True ALL ROWS ';
        return Database.getQueryLocator(query);
    }
    
    global void execute(Database.BatchableContext bc, List<Account> scope){
        List<Account> accList = new List<Account>();
        list<Deleted_Record_ID__c> DelRe = new list<Deleted_Record_ID__c>();
        for(Account s:scope){
            accList.add(s);
        }
        System.debug('account list' + accList );
        for(Account ac:accList){
            Deleted_Record_ID__c dr=new Deleted_Record_ID__c();
            dr.Name = ac.id;
            dr.Name__c = ac.Name;
            DelRe.add(dr);
        } 
        insert DelRe;
        Undelete accList;
    }
    global void finish(Database.BatchableContext bc){
    }
}
Need to fetch the deleted record id for every 3 minutes and want to save that id into some custom object.Please give me a solution.
Thanks in advance.
Need to add a filter condition for records and want to assign that for user in profile level.Based on that filterd records  only should   show for users.How to  achive this ? Kindly help me out
This is my code:


trigger attachmentopp on Attachment (After Insert) {
    String parentId;
    String TitleName;    
    Set<Id> oppId = new Set<Id>();
    Map<Id,Opportunity> oppMap = new  Map<Id,Opportunity>(); 
    List<Opportunity> oppUpd = new List<Opportunity>();
    String baseUrl = System.URL.getSalesforceBaseUrl().toExternalForm();
    if(Trigger.isAfter && (Trigger.isInsert || Trigger.isUpdate)){
        for(Attachment att:Trigger.new){
            parentId = att.parentId;
            TitleName = att.Name;                            
            if(parentId.startsWith('006') && TitleName.startsWith('qrs') ){
                oppId.add(att.parentId); 
            }
        }
        for(Attachment att: [SELECT Id,ParentId FROM Attachment WHERE ParentId IN:
                             oppId ORDER BY Createddate ASC]){
                                 Opportunity opp = new Opportunity();
                                 opp.Id = att.ParentId;
                                 opp.Attachment_Link__c = baseUrl+'/'+att.Id;
                                 oppMap.put(opp.Id, opp);
                             }
        update oppMap.values();
    }
}
Data Loader should export all the data in standard or custom object from Salesforce on daily basis in scheduled time and store it in to the local drive...how to  achieve this ? Thanks in advance.
Hello- I'm trying to create a trigger that uses a SOQL query to find a record on a custom object matching criteria and then populate a lookup on the Opportunity with that record. My code is below, but I keep running into an error: "Illegal assignment from Schema.SObjectField to ID" on line 4.
trigger SalesPerformance on Opportunity (before insert, before update) {
    for (Opportunity o : [SELECT Sales_Performance__c.OwnerId FROM Sales_Performance__c WHERE Sales_Performance__c.OwnerId IN (SELECT Opportunity.OwnerId FROM Opportunity)]) { 
        if (Sales_Performance__c.Performance_Start__c == Opportunity.Client_Services_Launch_Date__c) {
            o.Sales_Performance__c = Sales_Performance__c.Id;
        }
    }
}
Thank you! 
 

Hi, I want to change my column from 'Name' into 'Queue Name'. Is it possible?

User-added image

my VF code

 

<apex:page controller="Search_For_User">
<apex:form style="width: 500px" >
       <apex:pageBlock tabStyle="Account" >

              <apex:inputText value="{!keyword}"/>
              <apex:commandButton value="Search" action="{!searchUser}"/>

            <Apex:pageblockTable value="{!results}" var="r" style="width: 450px">
                  <apex:column value="{!r.FirstName}" />
                  <apex:column value="{!r.LastName}" />
                  <apex:column value="{!r.ProfileId}"/>
            </Apex:pageblockTable>
              <Apex:pageblockTable value="{!groupMembers}" var="g" style="width: 200px">
                  <apex:column value="{!g.Group.Name}"/>
           </Apex:pageblockTable>
            
       </apex:pageBlock>
</apex:form>
</apex:page>
Hi all,

I have a custom field called "Amount" 
this my input "123456"
But need to display as "123  456" like this format.
How to include space in this using trigger?
thanks in advance 
This is my code:


trigger attachmentopp on Attachment (After Insert) {
    String parentId;
    String TitleName;    
    Set<Id> oppId = new Set<Id>();
    Map<Id,Opportunity> oppMap = new  Map<Id,Opportunity>(); 
    List<Opportunity> oppUpd = new List<Opportunity>();
    String baseUrl = System.URL.getSalesforceBaseUrl().toExternalForm();
    if(Trigger.isAfter && (Trigger.isInsert || Trigger.isUpdate)){
        for(Attachment att:Trigger.new){
            parentId = att.parentId;
            TitleName = att.Name;                            
            if(parentId.startsWith('006') && TitleName.startsWith('qrs') ){
                oppId.add(att.parentId); 
            }
        }
        for(Attachment att: [SELECT Id,ParentId FROM Attachment WHERE ParentId IN:
                             oppId ORDER BY Createddate ASC]){
                                 Opportunity opp = new Opportunity();
                                 opp.Id = att.ParentId;
                                 opp.Attachment_Link__c = baseUrl+'/'+att.Id;
                                 oppMap.put(opp.Id, opp);
                             }
        update oppMap.values();
    }
}
Data Loader should export all the data in standard or custom object from Salesforce on daily basis in scheduled time and store it in to the local drive...how to  achieve this ? Thanks in advance.
Hi Board. Has anyone had any success completing the Lightning Component Basics - Attributes & Expressions module?   I attempted the challenge using the Trailhead playground. And think what I did is correct. Yet I get the following error... 

"Challenge Not yet complete... here's what's wrong: The Quantity field is not using the correct output component."

Following is the component I have written:

Component Bundle Name : "campingListItem"
<aura:component >
    
    <aura:attribute name="item" type="Camping_Item__c" required="True"/>
    
    <ui:outputText value="{!item.Name}"/>
    <ui:outputCurrency value="{!item.Price__c}"/>
    <ui:outputNumber value="{!item.Quantity__c}"/>
    <ui:outputCheckbox value="{!item.Packed__c}"/>
	
</aura:component>

User-added image

Object schema is :   Name - Text (80),  Packed__c - Checkbox,  Price__c - Currency (16,2), Quantity__c - Number (18,0).

What could I be doing wrong. Any advice?

 

Hi All,

 

I am using addError method in a trigger to show some error messages.  I need to show the error message in two different lines, like below

 

***DO NOT ISSUE THIS ORDER***

***The order is currently with the DEV team***

 

I am unable to add the break between the lines. I tried the below:

 

AMet[0].addError('***DO NOT ISSUE THIS ORDER***'+BR()+'***The order is currently with the DEV team***');

 

But it says, there is no BR() method.

 

Help!!!

 

Thanks,

community