• Subodh Shukla 16
  • NEWBIE
  • 30 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 2
    Replies
on first load of lwc component its showing 
This page isn't available in Salesforce Lightning Experience or mobile app. error how to resolve it.
public class InvoiceTriggerHelper {
        public static void updateInvoice(List<cma_Invoice__c> lstInvoice){
            System.debug('lstInvoice'+lstInvoice);
            
            Map<Id, List<cma_Invoice__c>> acctIdinvoiceListMap = new Map<Id, List<cma_Invoice__c>>();
            Set<Id> acctIds = new Set<Id>();
            List<cma_Invoice__c> invoiceList = new List<cma_Invoice__c>();
            for(cma_Invoice__c invoice : lstInvoice){
                system.debug('invoice.cma_Account__r.id--->'+invoice.cma_Account__c);
                if(invoice.cma_Account__c != null){
                    acctIds.add(invoice.cma_Account__c);
                }
            }
            system.debug('acctids--->'+acctIds);
            if(acctIds.size() > 0){
        invoiceList = [SELECT sic_Invoice_Amount_EUR_current_year__c, sic_Invoice_Volume_Tons_current_year__c, cma_Account__c FROM cma_Invoice__c WHERE cma_Account__c IN : acctIds];
        
        for(cma_Invoice__c invoice : invoiceList){
            if(!acctIdinvoiceListMap.containsKey(invoice.cma_Account__c)){
                acctIdinvoiceListMap.put(invoice.cma_Account__c, new List<cma_Invoice__c>());
            }
            acctIdinvoiceListMap.get(invoice.cma_Account__c).add(invoice);
        }

        List<Account> acctList = new List<Account>();
        acctList = [SELECT sic_Actuals_YTD_turnover_EUR__c, sic_Actuals_YTD_Volume_Tons__c FROM Account WHERE Id IN: acctIds];
        for(Account acct : acctList){
            List<cma_Invoice__c> tempinvoiceList = new List<cma_Invoice__c>();
            tempinvoiceList = acctIdinvoiceListMap.get(acct.Id);
            Double totalturnover = 0;
            Double totalVolume = 0;
            if(tempinvoiceList!=null && !tempinvoiceList.isEmpty()){
                for(cma_Invoice__c invoice : tempinvoiceList){
                    if(invoice.sic_Invoice_Amount_EUR_current_year__c != null){
                      totalturnover += invoice.sic_Invoice_Amount_EUR_current_year__c;
                    }
                    if(invoice.sic_Invoice_Volume_Tons_current_year__c !=null){
                        totalVolume += invoice.sic_Invoice_Volume_Tons_current_year__c;
                    }
                }
            }
            acct.sic_Actuals_YTD_turnover_EUR__c = totalturnover;
            acct.sic_Actuals_YTD_Volume_Tons__c = totalVolume;
        }
        update acctList;
            }
        }
    
   
    }
Where Account is having lookup relationship so it is already indexed  please let me know how we can over come this error

Thanks: 
Subodh Shukla
 
Hi all,
My reuirement is that i want to Export all my visualForce page data into Excelsheet when i click to Download as Excel Link on the page. it should create a new vf page and show all related data. 
My VF Page is:

<apex:page sidebar="false" controller="RolesAndUsers" >
  <apex:form >
   Roles:&nbsp;&nbsp;&nbsp;&nbsp;<apex:selectList value="{!SelectedRole}" multiselect="false" size="1">
   <apex:actionSupport event="onchange" reRender="User,Subroles"/>
   <apex:selectOptions value="{!RolesName}">
   </apex:selectOptions>
   </apex:selectList><br></br><br></br><br></br>
   Users in Selected Role:&nbsp;&nbsp;&nbsp; 
   <apex:pageBlock id="User">
    <apex:pageblockTable value="{!UserName}" var="Ur"> 
     <apex:column >
      <apex:OutputField value="{!Ur.Name}"/>
      </apex:column>
    </apex:pageblockTable>
   </apex:pageBlock>
       
   <br></br>
   Sub Roles In Hierarchy:
   <apex:pageBlock id="Subroles" >
   <apex:pageBlockTable value="{!subrole}" var="sr">
     <apex:Column >
      <apex:OutputField Value="{!sr.name}"/>
     </apex:Column>
     <apex:repeat value="{!sr.Users}" var="c">
                <apex:facet name="header">Users</apex:facet>
                <apex:column value="{!c.Name}"/>
                 <apex:facet name="header">Users Email</apex:facet>
                <apex:column value="{!c.Email}"/>
            </apex:repeat>
     
   </apex:pageBlockTable>
  </apex:pageblock>
 
my controller is :

public with sharing class RolesAndUsers{

Public List<User>UserList= new List<User>();
Public String SelectedRole {get;set;}
Public List<UserRole>SelectedUserRole= new List<UserRole>();

Public List<SelectOption>Roleoptions= new List<SelectOption>();
///---------------Method to get all Roles-------------------////
Public List<SelectOption>getRolesName(){

   Roleoptions.add(new selectOption('-None-','-None-'));
    for (UserRole ur1 :[select id,Name from UserRole ])
     {
       
       Roleoptions.add(new selectoption(ur1.name,ur1.name));
       
     }
     return Roleoptions;
  }
 
///--------------Method to get all User Under selected Role-------------------/// 

public List<User>getUserName(){
   UserList.clear();    
           
       
      for(User u1:[Select id, name ,UserRole.name From USer Where UserRole.Name=:SelectedRole and UserRole.name!=null])
      {
        UserList.add(u1);
      
      }
      
return UserList;
}
/////--------------Method to get all Sub Roles------------------////
Public List<UserRole>getSubrole(){
//subroles.clear();
List<UserRole>SelectedUserRole = [select id from UserRole Where UserRole.Name=:SelectedRole];
List<UserRole>Subroles=[SELECT id, Name,(Select name,email From USERS) From UserRole WHERE ParentRoleid IN: SelectedUserRole];
Return Subroles;


}


what i want is whenever i select a role all the Subrole and there User Should be Send as excel in new vf page
Here Is my class :
public with Sharing class VisitReportpdf{

Public sic_Visit_Report__c VisitReport{get;set;}
Public VisitReportpdf(apexpages.standardcontroller controller){
VisitReport= [SELECT 
                   id,
                   Name,
                   CreatedBy.name,
                   Our_shares__c,
                   Market_Share__c,
                   Total_demand__c,
                   Visit_title__c,
                   Visit_Date__c,
                   Account__r.name,
                   Competitors__c,
                   Contact__r.name,
                   Internal_Participants__c,
                   Objective__c,
                   Report_details__c                   
               FROM Visit_Report__c 
               where id=:ApexPages.CurrentPage().getparameters().get('id')];
}
}

And this is my Test Class
@isTest(SeeAllData=true)
public Class TestVisitReportpdf{
  public static testmethod void test1(){
   
   Account acc= new Account();
   acc.name ='TestAccount';
   Insert acc;
   
   Contact con = new Contact();
   Con.lastName='Test Contact';
   Con.Accountid=acc.id;
   Insert con;
   
    Visit_Report__c svr = new Visit_Report__c();  
    svr.Account__c=acc.id;
    svr.Competitors__c='test Competitors';
    svr.Contact__c=con.id;
    svr.Visit_Date__c=system.today();
    svr.Internal_Participants__c='Test Participents';
    svr.Our_shares__c=10;
    svr.Market_Share__c=90;
    svr.Total_demand__c=100;
    svr.Objective__c='Commercial';
    svr.Report_details__c='Test Report Details';
    svr.Visit_title__c='Test visit Title';
    Insert svr;  
   

        
    
  ApexPages.Standardcontroller sc = new ApexPages.Standardcontroller(svr);
  VisitReportpdf VRP= new VisitReportpdf(sc);
 
      
 }
}

Hi all,

i want salesforce to take file from my local system and upload in saleforce on daily bases is it possible 
how we can achieve this 

Thanks & Regards 
Hi All,

i am new in apex code i write a trigger and dont have idea about the handler class so i directly write logic in trigger itself. it would be great if anybody let me know how to write handler class and call this trigger code. 
trigger Lookupuserrecord on Account (before insert, before update) {
        
        Set<Id> ParentIds = New Set<Id>();
        For(Account Acc : Trigger.New)
    {
        ParentIds.Add(Acc.Master__c);
    }
       List<Master__c> ParentList = [Select Id,test_user1__c from Master__c where id =: ParentIds];
       
       For(Account CO : Trigger.New)
    {    
        For(Master__c PA : ParentList)
        {
            IF(CO.Master__c == PA.ID)
            {
                IF(PA.test_user1__c != NULL)
                {
                    CO.test_user1__c = PA.test_user1__c ;
                }
            }
        }
    }    
       
        
}

 
Hi all,

i am new here is sfdc i want to know is there any automatic functionality in sf when the owner of account is changed its related contact owner is changed. if yes can we disable it
Hi All,

i am new in apex code i write a trigger and dont have idea about the handler class so i directly write logic in trigger itself. it would be great if anybody let me know how to write handler class and call this trigger code. 
trigger Lookupuserrecord on Account (before insert, before update) {
        
        Set<Id> ParentIds = New Set<Id>();
        For(Account Acc : Trigger.New)
    {
        ParentIds.Add(Acc.Master__c);
    }
       List<Master__c> ParentList = [Select Id,test_user1__c from Master__c where id =: ParentIds];
       
       For(Account CO : Trigger.New)
    {    
        For(Master__c PA : ParentList)
        {
            IF(CO.Master__c == PA.ID)
            {
                IF(PA.test_user1__c != NULL)
                {
                    CO.test_user1__c = PA.test_user1__c ;
                }
            }
        }
    }    
       
        
}

 
Hi all,
My reuirement is that i want to Export all my visualForce page data into Excelsheet when i click to Download as Excel Link on the page. it should create a new vf page and show all related data. 
My VF Page is:

<apex:page sidebar="false" controller="RolesAndUsers" >
  <apex:form >
   Roles:&nbsp;&nbsp;&nbsp;&nbsp;<apex:selectList value="{!SelectedRole}" multiselect="false" size="1">
   <apex:actionSupport event="onchange" reRender="User,Subroles"/>
   <apex:selectOptions value="{!RolesName}">
   </apex:selectOptions>
   </apex:selectList><br></br><br></br><br></br>
   Users in Selected Role:&nbsp;&nbsp;&nbsp; 
   <apex:pageBlock id="User">
    <apex:pageblockTable value="{!UserName}" var="Ur"> 
     <apex:column >
      <apex:OutputField value="{!Ur.Name}"/>
      </apex:column>
    </apex:pageblockTable>
   </apex:pageBlock>
       
   <br></br>
   Sub Roles In Hierarchy:
   <apex:pageBlock id="Subroles" >
   <apex:pageBlockTable value="{!subrole}" var="sr">
     <apex:Column >
      <apex:OutputField Value="{!sr.name}"/>
     </apex:Column>
     <apex:repeat value="{!sr.Users}" var="c">
                <apex:facet name="header">Users</apex:facet>
                <apex:column value="{!c.Name}"/>
                 <apex:facet name="header">Users Email</apex:facet>
                <apex:column value="{!c.Email}"/>
            </apex:repeat>
     
   </apex:pageBlockTable>
  </apex:pageblock>
 
my controller is :

public with sharing class RolesAndUsers{

Public List<User>UserList= new List<User>();
Public String SelectedRole {get;set;}
Public List<UserRole>SelectedUserRole= new List<UserRole>();

Public List<SelectOption>Roleoptions= new List<SelectOption>();
///---------------Method to get all Roles-------------------////
Public List<SelectOption>getRolesName(){

   Roleoptions.add(new selectOption('-None-','-None-'));
    for (UserRole ur1 :[select id,Name from UserRole ])
     {
       
       Roleoptions.add(new selectoption(ur1.name,ur1.name));
       
     }
     return Roleoptions;
  }
 
///--------------Method to get all User Under selected Role-------------------/// 

public List<User>getUserName(){
   UserList.clear();    
           
       
      for(User u1:[Select id, name ,UserRole.name From USer Where UserRole.Name=:SelectedRole and UserRole.name!=null])
      {
        UserList.add(u1);
      
      }
      
return UserList;
}
/////--------------Method to get all Sub Roles------------------////
Public List<UserRole>getSubrole(){
//subroles.clear();
List<UserRole>SelectedUserRole = [select id from UserRole Where UserRole.Name=:SelectedRole];
List<UserRole>Subroles=[SELECT id, Name,(Select name,email From USERS) From UserRole WHERE ParentRoleid IN: SelectedUserRole];
Return Subroles;


}


what i want is whenever i select a role all the Subrole and there User Should be Send as excel in new vf page
Hi all,

i am new here is sfdc i want to know is there any automatic functionality in sf when the owner of account is changed its related contact owner is changed. if yes can we disable it