• sumitha
  • NEWBIE
  • 75 Points
  • Member since 2017
  • SDFC Consultant

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 18
    Questions
  • 42
    Replies
Hi, 
I am trying to recreate ACCOUNT object page in my custom visual force page.

Now I would like to know how to code for LIST VIEW OPTIONS, so that when ever we change the value the records in the pageblock section changes as selected.

Account Custom VisualForce PageList View Options

Code:
<!--
Author		: Srini
Description	: Create Account Object Duplicate Page
Version		: V1.0
CreatedDate	: 05-15-2019
-->
<apex:page standardController="Account" recordSetVar="accounts" tabStyle="account">
    <apex:form >
    <apex:sectionHeader title="Accounts" subtitle="Home" help="Account Page Help!"/>

<!-- VIEW -->	
<!--    <apex:pageBlock mode="maindetail"> -->
    	&nbsp; <b>View:</b> &nbsp;
        <apex:selectList value="{!filterId}" size="1">
<!-- ACTIONSUPPORT -- When View Option is changed we have to refresh below Page to change those values -->
        	<apex:actionSupport event="onchange" reRender="thechart"/>    
            <apex:selectOptions value="{!listviewoptions}" />
        </apex:selectList> &nbsp;
        <apex:commandButton id="go" value="Go!" title="Go" styleClass="buttonStyle" style="color:green"/> &nbsp;
        <apex:commandLink value="Edit"/> | &nbsp;
        <apex:commandLink value="Create New View"/> <br/> <br/>
<!--    </apex:pageBlock> -->

<!-- RECENT ACCOUNT -->    
    <apex:pageBlock title="Recent Accounts" mode="detail" tabStyle="dashboard">
    	<apex:pageBlockButtons location="top">
        	<apex:commandButton value="New" title="New Account" id="NAB" styleClass="buttonstyle" style="color:darkblue" />
       		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;	
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;	
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;	
            <apex:selectList value="{!filterId}" size="1">
                <apex:actionSupport event="onchange" reRender="thechart"/>
	            <apex:selectOption itemLabel="Recently Created" itemValue="" id="RC">			</apex:selectOption>
                <apex:selectOption itemLabel="Recently Modified" itemValue="" id="RM">			</apex:selectOption>
                <apex:selectOption itemLabel="Recently Viewed" itemValue="" id="RV">			</apex:selectOption>
			</apex:selectList>
        </apex:pageBlockButtons>
        <apex:pageBlockTable value="{!accounts}" var="acc" rows="5">
<!--            <apex:column headerValue="Account Name">
                <apex:outputLink value="{!acc.name}">{!acc.name}</apex:outputLink>
			</apex:column>
-->
            	<apex:column value="{!acc.name}"/>
                <apex:column value="{!acc.Id}"/>      	          	    
    	        <apex:column value="{!acc.Type}"/>
        </apex:pageBlockTable> 
        <apex:inlineEditSupport />
    </apex:pageBlock>

<!-- REPORTS -->       
    <apex:pageBlock mode="maindetail">
        <apex:pageBlockSection columns="2">
            <apex:pageBlock title="Reports" mode="detail" tabStyle="case" helpTitle="Reports Help !" helpUrl="/apex/VFpage_1">
                <apex:pageBlockSection columns="1">
                    <apex:commandLink value="Active Accounts"/>
                    <apex:commandLink value="Accounts with last activity > 30 days"/>
                    <apex:commandLink value="Account Owners"/>
                    <apex:commandLink value="Contact Role Report"/>
                    <apex:commandLink value="Account History Report"/>
                    <apex:commandLink value="Partner Accounts"/>   
                </apex:pageBlockSection> <br/>
                <apex:pageBlock mode="detail" tabStyle="opportunity">
                    <apex:commandLink value="Go to Reports"/>
                </apex:pageBlock>
            </apex:pageBlock>
            
<!-- TOOLS -->        
            <apex:pageBlock title="Tools" mode="detail" tabStyle="order" helpTitle="Tools Help !" helpUrl="/apex/VFpage_2">
            	<apex:pageBlockSection columns="1">
                    <apex:commandLink value="Import Accounts & Contacts"/>
					<apex:commandLink value="Mass Delete Accounts"/>
					<apex:commandLink value="Transfer Accounts"/>
					<apex:commandLink value="Merge Accounts"/>
					<apex:commandLink value="Mass Reassign Account Teams"/>
					<apex:commandLink value="Sales Methodologies"/>                    
                </apex:pageBlockSection>    
            </apex:pageBlock>
        </apex:pageBlockSection>
	</apex:pageBlock>        
 </apex:form>   
</apex:page>

 
Hi All,

How to migrate all of the product images from the documents folder in classic to a library in Files.

Thanks in Advance.
Sumitha P
Hi Guys, 
Need help on creating a post in chatter from workbench or any application like postman tools. 
when we try using workbench it showing as "INVALID SESSION id".

please advice on possible solution. 
Thanks in advance, 
Sumitha P
Hi All,
 
I have created Apex trigger on Email Message Object
Functionality : Updates a Case object status field as "Unread" 
whenever Email Message is inserted or updated with status new. 
 
But,When Email Message with Status "New" under Case Object is created
The Email Message Status changed into Read from New when I just opened the Email Message(without edit).
But the Case Object field remains as "Unread".
 
Expected Result : The Email Message Status changed into Read from New when I just opened the Email Message(without edit), the Case Oject Status field should changed to "Read"
 
Please Suggest a solution.
 
Thanks.
Hi Guys,

What are the possible ways to receive mail from outside salesforce(like gmail/outlook) under Case Email object(EmailMessage)?

Thanks,
Sumitha P
Hi,

Business Requirement:
Once email is received(Email Message of Case),We have to show the unread Email Message in the Enhanced List view of Case.

Need help --> If the user sends the mail via outlook/Gmail,how will those mail will those mail will place under the Respective Email Message in Case Related List.


Thanks in Advance,
Sumitha P
Hi All,

When i try to write Page reference
GenerateDocument - It is Visual force page in CPQ Managed Package.It is called when Generate Document button is clicked in Quote Detail Page.
//Quote.id --> retrieves current CPQ Quote id
PageReference pr = new PageReference('apex/GenerateDocument?id=' + quote.id);
               
        
                 Attachment at     =   new Attachment();
                 Blob b = pr.getContentAsPDF();
                    at.Body        =  b;
                        at.ParentId   =   quo1.Id;
                 at.ContentType = 'pdf';
                 insert at;
Displays Error as :
core.apexpages.exceptions.ApexPagesGenericException: The page can't be loaded because the remote site apex/GenerateDocument isn't listed in your organization's Remote Sites Settings.
But I try to create new Remote Site  --> but it does not works on my end.

Please Advice and suggest.

Thanks,
Sumitha P
 
Hi All,

I have attached the code  where I have passed the variable through contructor in Batch Apex class

I have written Batch apex with constructor and execute and written system.debug for checking.
Where it is not seeing the system.debug statement inside Execute method in debug logs.

I need help on execution method in Batch Apex.I am unaware why the execute method is not working on my side.
Apex class:
Extension_Batch  batch = new Extension_Batch(Newprdt,newRecord);
         Database.executeBatch(batch,200);
Batch Apex class:
global class Extension_Batch implements Database.Batchable<sObject>
{
 global List<B__c> Newprdt123;
 global  A__c newRecord123;   
 global Extension_Batch(List<B__c> Newprdt,A__c newRecord)
{
   //this block is working fine

    system.debug('Newprdt_batch'+Newprdt);
    system.debug('newRecord'+newRecord);
   Newprdt123 = Newprdt;
   newRecord123 = newRecord;
    system.debug('Newprdt123'+Newprdt123);
    system.debug('newRecord123'+newRecord123);
}
// Start Method
    global Database.QueryLocator start(Database.BatchableContext bc) 
    {
        system.debug('instart');
     return Database.getQueryLocator('Select id,OwnerId,IsDeleted,RecordTypeId,CreatedDate,CreatedById,LastModifiedDate, LastModifiedById  from A__c');
    }
   // Execute method
    global void execute(Database.BatchableContext BC,List<B__c> Newprdt123) 
    { 
        
       system.debug(' '+Newprdt123);  
       system.debug('newRecord123'+newRecord123); 
        
     for(B__c prdt :Newprdt123)
       {
         for(PricebookEntry pbe2 :[SELECT Id,Name,isactive,PriceBook2Id,Pricebook2.id,Product2.CurrencyIsoCode,
                                     PriceBook2.Name,PriceBook2.isactive,Product2.Name,Product2.ProductCode,
                                         Product2.family,UnitPrice,Product2.Description,product2.isactive FROM PriceBookentry 
                                         where Product2.ProductCode =:prdt.Name and isactive=true
                                         and Pricebook2.id=:newRecord123.PriceList__c])
           {
            if( prdt.List_Price_Per_Unit__c <> pbe2.UnitPrice & pbe2.Product2.ProductCode == prdt.Name)
               {
                  prdt.List_Price_Per_Unit__c = pbe2.UnitPrice;
               }
             update prdt;  
              
           }
          
                
       List<Pricebookentry> pbe3=[SELECT Id,Name,isactive,PriceBook2Id,Product2.ProductCode,PriceBook2.Name,PriceBook2.isactive,Product2.Name,
                                         Product2.family,Product2.Description,Unitprice,product2.isactive FROM PriceBookentry 
                                         where Product2.ProductCode =:prdt.Name and isactive=false and Pricebook2.id=:newRecord123.PriceList__c];
       
           if(pbe3.size() ==1)
           {
          for(Pricebookentry pbe1:pbe3)
          {
                            
       List<B__c> stpr =[Select id,IsDeleted,Product__r.id,Name,CreatedDate,CreatedById,LastModifiedDate,LastModifiedById,SystemModstamp,LastActivityDate From B__c 
                                   where Number1__c=:newRecord123.id and Name=: pbe1.product2.ProductCode];
              
            
              delete stpr;
         
          }
       }
           
       }
    }       
    // Finish Method
    global void finish(Database.BatchableContext BC) 
    {
       system.debug('Batch apex completed');
    }

}
Thanks in advance.
Sumitha P
 
  • September 24, 2019
  • Like
  • 0
Hi All,

Need Help !

I have to clone custom object which 250+related list record(child record) + some field updation in Related record.

I created a custom button in Custom object detail page which calls the apex class.
(It was working for lesser records in related list record only).
My thought is to write batch apex class
but I need help to write Batch apex class for this kind of Scenario.

Thanks,
Sumitha P

 
  • September 03, 2019
  • Like
  • 0
Hi All,
I Have an Visual force page with some Set of List and String.
I have given those List and string While calling the Batch apex
Extension_Batch  batch = new CloneNSTExtension_Batch(List name,String name);
         batch.executeBatch(batch);
My clarification is how to take the String name inside the excute method in batch apex.Because,those string(which have value from the  normal apex class) I have added as the Condition value in query.

Please advice.

Thanks in advance
Sumitha P
Hi All,

We have two Visual force page and Apex class.
First Visualforce page - Retrirves the table data based on the picklist.
Secoond Visualforce page - Export those Table value with picklist parameters in Excel Sheet.
This Flow is working fine in normal Visual force page preview.

In community Builder :
But,it is showing error in Community Builder.

We have added two visual force page in communities.

First Visualforce page - Retrirves the table data based on the picklist.
Secoond Visualforce page - Export those Table value with picklist parameters in Excel Sheet without data.

 Reason : Picklist value is not passed to second VFP(Export Functionality)

Need Help : How to pass the picklist parameter from First Visual force page to another VFP.

Thanks in Advance
Hi ,

Need help on geeting the data from public website.Please suggest ways/flow how to do this requirement

My Understanding:
1) Get the data from public website using webscraping tool(output will be an API).which can used into Apex class(but how to automate the Process I didnt have idea about it)

Please suggest or advice how to get the data every month from a public website and store into Salesforce.

Thanks in advance.

Regards,
Sumitha P
Hi All,

Reference: https://codepen.io/rogie/pen/GIfqc

This Code is working perfectly in Google Chrome but it is not working in Firefox.
<apex:page standardcontroller="Account" sidebar="false" action="{!showRate}" showheader="false" docType="html-5.0" lightningStylesheets="true">
 <apex:form >
<apex:slds />
  <style>
.star-rating fieldset {
  font-size:0;
  white-space:nowrap; 
  display:inline-block;
  width:250px;
  height:50px;
  overflow:hidden;
  position:relative;
  background:
      url('data:image/svg+xml;utf-8,<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="20px" height="20px" viewBox="0 0 20 20" enable-background="new 0 0 20 20" xml:space="preserve"><polygon fill="#DDDDDD" points="10,0 13.09,6.583 20,7.639 15,12.764 16.18,20 10,16.583 3.82,20 5,12.764 0,7.639 6.91,6.583 "/></svg>');
  background-size: contain;
}

.star-rating input { 
   opacity: 0;
   display:inline-block;
   width: 100%;
   height: 100%; 
   margin:0;
   padding:0;
   z-index: 2;
   position: relative;
}

.star-rating input:hover + label,
.star-rating input:checked + label {
     opacity:1;    
   }

.star-rating label {
   opacity: 0;
   position: absolute;
   left: 0;
   top: 0;
   height: 100%;
   width: 20%;
   z-index: 4;
   background: 
      url('data:image/svg+xml;utf-8,<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="20px" height="20px" viewBox="0 0 20 20" enable-background="new 0 0 20 20" xml:space="preserve"><polygon fill="#FFDF88" points="10,0 13.09,6.583 20,7.639 15,12.764 16.18,20 10,16.583 3.82,20 5,12.764 0,7.639 6.91,6.583 "/></svg>');
   background-size: contain;
 }

.star-rating td ~ td label 
               {
  width: 20%;
  z-index: 8;  
}
.star-rating td ~ td ~ td label 
               {
  width: 30%;
  z-index: 7;  
}
.star-rating td ~ td ~ td ~ td label 
               {
  width: 40%;
  z-index: 6;  
}
 .star-rating td ~ td ~ td ~ td ~ td label
               {
                width: 50%;
         z-index: 5; 
               }
.star-rating td ~ td ~ td ~ td ~ td ~ td label {
  width: 60%;
  z-index: 4;
}
.star-rating td ~ td ~ td ~ td ~ td ~ td ~ td label {
  z-index: 3;
  width: 70%;
}
.star-rating td ~ td ~ td ~ td ~ td ~ td ~ td ~ td label {
  z-index: 2;
  width: 80%;
}
 .star-rating td ~ td ~ td ~ td ~ td ~ td ~ td ~ td ~ td label {
  z-index: 1;
  width: 90%;
} 
.star-rating td ~ td ~ td ~ td ~ td ~ td ~ td ~ td ~ td ~ td label {
  z-index: 0;
  width: 100%;
} 
               
.font
{
 font-size: 19px;
}
</style>
 <apex:selectRadio value="{!fr.RatingScore__c}" layout="lineDirection">
   <apex:actionSupport event="onclick" reRender="form"/>
                       <apex:selectOption itemValue="0.5"></apex:selectOption>
                        <apex:selectOption itemValue="1"></apex:selectOption>
                       <apex:selectOption itemValue="1.5"></apex:selectOption>
                        <apex:selectOption itemValue="2"></apex:selectOption>
                       <apex:selectOption itemValue="2.5"></apex:selectOption>
                        <apex:selectOption itemValue="3"></apex:selectOption>
                       <apex:selectOption itemValue="3.5"></apex:selectOption>
                        <apex:selectOption itemValue="4"></apex:selectOption>
                       <apex:selectOption itemValue="4.5"></apex:selectOption>
                        <apex:selectOption itemValue="5"></apex:selectOption>
  </apex:selectRadio>
</apex:form>
</apex:page>
Please Advice,

Thanks & Regards,
Sumitha P
 
Hi All, 

Need help on displaying the Nearby contacts within the radius(10km) around our current location  in Google Maps without using the Map component in the visual force page.

Please advice.

Thanks,
Sumitha P
Hi All,
      Here is my apex trigger,
trigger LeadConversionTrigger on Lead (after update) {
    /*
     * Create maps of Ids to store the records
     * associated with the converted leads
     */
    Map<Id,Id> convertedOpportunityIds = new Map<Id,Id>();
    
    /*
     * Loop through the leads submitted through this
     * trigger.  Populate the appropriate maps of Ids
     * for each lead with populated values.
     */
    for (Lead l : Trigger.New) {
        
        // Get a reference to the old values associated
        // with this lead.
        Lead oldLead = trigger.OldMap.get(l.Id);
        
        // Determine if the lead was converted or not.
        // If the previous status was not converted and
        // the current status is converted, then this
        // trigger executed because of a conversion.
        if (!oldLead.IsConverted && l.isConverted) {
        
            // if lead was converted and converted opp id got populated
            if (l.convertedOpportunityId != null && oldLead.convertedOpportunityId == null ) {
                convertedOpportunityIds.put(l.Id, l.convertedOpportunityId);
            }
        }
    }
    
    List<Dealer_Registration_Product__c> dealerProducts = [SELECT Id, Name, Lead__c, Opportunity_Name__c FROM Dealer_Registration_Product__c 
                                                                WHERE Lead__c IN: convertedOpportunityIds.keySet() ];
    if ( dealerProducts != null && !dealerProducts.isEmpty() ) {
        for ( Dealer_Registration_Product__c product: dealerProducts ) {
            product.Opportunity_Name__c = convertedOpportunityIds.get( product.Lead__c);
        }
        update dealerProducts;
    }                                                        
}
and i have written the tes class as,
 
@IsTest
public class testLeadTriggers {
    public static testmethod void testContactIdAndConversion() 
    {
        Account acc = new Account( Name = ' name');
        insert acc;
        Contact cont = new Contact( FirstName = 'tt', LastName = 'Contact', AccountId = acc.Id);
        insert cont;
        Lead lead = new Lead( LastName = 'Lead', Company = ' company', Status = 'New', Contact_Id__c = cont.Id );
        insert lead;
        Lead testLead = [SELECT Id, Referred_By__c, Referred_End_User_Account__c FROM Lead WHERE Id =: lead.Id];
        System.AssertEquals( cont.Id, testLead.Referred_By__c );
        System.AssertEquals( acc.Id, testLead.Referred_End_User_Account__c );
        Opportunity opptyLine = new Opportunity (
            Name = 'discount 2',
            AccountID = acc.ID ,
            LeadSource= 'Inbound Call',
            Type ='Quota',
            CloseDate=Date.today(),
            StageName='5.Decision',
           Reseller__c = acc.ID,
            Distributor_Discount_Product_Temp__c=49.5,
            Distributor_Discount_Service_Temp__c=25,
                AIMS_Partner__c='Cerner'
             );
            insert opptyLine;
        
        Dealer_Registration_Product__c dealer = new Dealer_Registration_Product__c( Lead__c = lead.Id );
        insert dealer;
        
        Database.LeadConvert lc = new database.LeadConvert();
        lc.setLeadId(testLead.id);
        //lc.setDoNotCreateOpportunity(true);
        //lc.setOwnerId(testUser1.id);
        lc.setConvertedStatus('Converted');
        
       Database.LeadConvertResult lcr = Database.convertLead(lc);
      System.assert(lcr.isSuccess());
      opportunity opp = [select id from opportunity where AccountID=: acc.id];
        
        
        Dealer_Registration_Product__c testDealer = [SELECT Id, Opportunity_Name__c FROM Dealer_Registration_Product__c  WHERE Id =: dealer.Id ];
      //  System.Assert( testDealer.Opportunity_Name__c != null );
   
    }
}
But I am getting error as,

System.DmlException: ConvertLead failed. First exception on row 0; first error: UNKNOWN_EXCEPTION, There was an error converting the lead. Please try again. If the problem persists, please contact your administrator.: []

Please advice to write the testclass.


Thanks and regards,
Sumitha.P


 
Hi All,
         
       I have a custom object with the field(Start_Date__c).In my visualforce page I have given
              Date:  <apex:input type="date"  id="dts" value="{!sd}" />
       1) How to pass the the id in javascript for date and retrieve the records(data with Start_Date__c  which has greater than the specfied date).
       2) This operation should perform dynamically without any button clicking.
       3)  I have struck how to gt the elementid using javascript for date field.

Thanks and Regards,
Sumitha P            

       

 
Hi everyone,
I have create a apex class,used  for updating the discount fields from account into Opportunity/QuoteLineItem fields.
 
public class DistributorDiscountChangeTriggerClass
{
     
   @future /* Due to Apex CPU Time Limit issue we used @future annotation */
     public static void DisupdService(set<Id> accByIds) /* Get the value from Apex */
    {
       if(checkrecursive.runonce()) 
           /*checkRecursive Class - used for run the trigger one time */
    
{
    try // Try -block
  {
       // Get the Open Opportunity Id, Distributor (Account ID) of the particular account. //
         Map<Id, Opportunity> oppByIds = new Map<Id,Opportunity>([SELECT Id,Distributor__c FROM Opportunity WHERE Distributor__c IN:accByIds AND IsClosed = FALSE]);        
         System.debug('Opportunity ID' +oppByIds.size());
      
        // Get the Quotelineitem details by using filtered Open Opportunity(oppByids) //
         List<QuoteLineItem> qlitmp= new List<QuoteLineItem>([select id,quote.opportunity.Distributor__c,Disti_Service_Product_Temp_Hidden__c,quote.opportunity.Override_Renewal_Discount__c,quote.opportunity.RecordType.name,Distributor_Discount_1__c,quote.opportunity.Distributor__r.Distributor_Discount_Renewal__c,product2.family,quote.opportunity.Distributor__r.Distributor_Discount_Service__c ,quote.opportunity.Distributor__r.Distributor_Discount_Product__c from quotelineitem where quote.opportunityID IN: oppByIds.keyset() and product2.family='Service']); 
     System.debug('qlitmp -list'+qlitmp.size());  
      
        //Get the details of Open opportunity for Record Type
       List<Opportunity> oppqt= new List<Opportunity>([ SELECT Id,RecordType.name ,Override_Renewal_Discount__c,Distributor__r.Distributor_Discount_Renewal__c,Distributor__r.Distributor_Discount_Product__c,Distributor__r.Distributor_Discount_Service__c,Distributor_Discount_Product_Temp__c,Distributor_Discount_Service_Temp__c,Distributor__c FROM Opportunity WHERE Id IN: oppByIds.keySet() /*FOR UPDATE*/]);
      System.debug('Opportunity -list'+oppqt.size());   
   if ( !accByIds.isEmpty() )  // If account(accbyIds) Id is not null , the process enter into the IF loop
    {
     
        System.debug('Inside if Loop');
       
       
         for ( Opportunity qt: oppqt ) 
         {
        // NST's Record Type == Service Renewal //   
         if(qt.RecordType.name=='Service Renewal' && qt.Override_Renewal_Discount__c==false)
        { 
            System.debug('inside if SR false');
            qt.Distributor_Discount_Service_Temp__c=  qt.Distributor__r.Distributor_Discount_Renewal__c;
             qt.Distributor_Discount_Product_Temp__c= qt.Distributor__r.Distributor_Discount_Product__c;
             System.debug('Distributor_Discount_Renewal__c '+  qt.Distributor_Discount_Service_Temp__c); 
          
        }
      else  if(qt.RecordType.name=='Service Renewal' && qt.Override_Renewal_Discount__c==true)
        { 
            System.debug('inside if SR true');
            qt.Distributor_Discount_Service_Temp__c=  qt.Distributor__r.Distributor_Discount_Service__c;
            qt.Distributor_Discount_Product_Temp__c=qt.Distributor__r.Distributor_Discount_Product__c;
             System.debug('Distributor_Discount_Service__c '+  qt.Distributor_Discount_Service_Temp__c); 
          
        }
             
              //EOF NST's Record Type == Service Renewal //

    else if ( qt.Distributor__c != null) 
    {
                System.debug('Distributor__c!= null');
               qt.Distributor_Discount_Service_Temp__c= qt.Distributor__r.Distributor_Discount_Service__c;
                qt.Distributor_Discount_Product_Temp__c=qt.Distributor__r.Distributor_Discount_Product__c;
             System.debug('opportunity.Distributor_Discount_Service_Temp__c '+  qt.Distributor_Discount_Service_Temp__c); 

           }   
               
         }
         update oppqt;//opp
         }
      for(opportunity optyid : oppqt)
      {
          system.debug('optyid'+optyid.Distributor_Discount_Service_Temp__c);
          system.debug('optyid'+optyid.id);
      }
  /*
 for(quotelineitem qlitemp: qlitmp)
 {
   if(qlitemp.quote.opportunity.RecordType.name=='Service Renewal' && qlitemp.quote.opportunity.Override_Renewal_Discount__c==false && qlitemp.product2.family=='Service')
        { 
            system.debug('1-false');
           
           qlitemp.Disti_Service_Product_Temp_Hidden__c=qlitemp.quote.opportunity.Distributor__r.Distributor_Discount_Renewal__c;
         }
     else if(qlitemp.quote.opportunity.RecordType.name=='Service Renewal' && qlitemp.quote.opportunity.Override_Renewal_Discount__c==true && qlitemp.product2.family=='Service')
        { 
            system.debug('1-false');
           
           qlitemp.Disti_Service_Product_Temp_Hidden__c=qlitemp.quote.opportunity.Distributor__r.Distributor_Discount_Service__c;
         }
  else if(qlitemp.product2.family=='Service' && qlitemp.quote.opportunity.Distributor__c != null)
        {
            system.debug('12');
                 qlitemp.Disti_Service_Product_Temp_Hidden__c=qlitemp.quote.opportunity.Distributor__r.Distributor_Discount_Service__c ; 
        }
        
             }
        update qlitmp;  
  */
        Map<Id, NST__c> nstdisByIds = new Map<Id,NST__c>( [ SELECT Id, Distributor_Account__c FROM NST__c WHERE  Distributor_Account__c IN: accByIds AND NST_Status__c = 'Draft']);                
       System.debug('nstdisByIds ID' +nstdisByIds.size());

     List<NST__c> nstdis = [ SELECT Id,recordtype.id,recordtype.name,Distributor_Account__r.Distributor_Discount_Renewal__c,Distributor_Account__r.Distributor_Discount_Product__c,Distributor_Account__r.Distributor_Discount_Service__c, Product_Contractual_Discount_Temp__c,Service_Contractual_Discount_Temp__c,Distributor_Account__c FROM NST__c WHERE Id IN: nstdisByIds.keySet()];
    System.debug('nstdis -list'+nstdis.size());   
           for ( NST__c qt: nstdis ) 
         {
            System.debug('Inside FOr');
             // NST's Record Type == Service Renewal //
        if(qt.RecordType.name=='Service Renewal')
        { 
            System.debug('inside if');
            qt.Service_Contractual_Discount_Temp__c=  qt.Distributor_Account__r.Distributor_Discount_Renewal__c;
             System.debug('Distributor_Discount_Renewal__c '+  qt.Service_Contractual_Discount_Temp__c); 
        }
        
         // End of NST's Record Type == Service Renewal //
    else if ( qt.Distributor_Account__c != null) 
    {

               qt.Service_Contractual_Discount_Temp__c= qt.Distributor_Account__r.Distributor_Discount_Service__c;
             System.debug('opportunity.Service_Contractual_Discount_Temp__c '+  qt.Service_Contractual_Discount_Temp__c);  
           }       
         }

      update nstdis;  
        system.debug('Updated'+nstdis.size());
           system.debug('Updated'+nstdis);
        
    }

    catch(Exception e)
    {
       system.debug('e'+e);
       

    }
    }
}
}

Please advice.
Thanks in advance.

Regards
Sumitha P
Hi Everyone,

The Following error occurs in Apex trigger.

      Error: Apex trigger DistributorDiscountChangeTrigger caused an unexpected exception, contact your administrator: DistributorDiscountChangeTrigger: execution of AfterUpdate caused by: System.DmlException: Update failed. First exception on row 0 with id 0QLL00000001CRNOA2; first error: INVALID_CROSS_REFERENCE_KEY, invalid cross reference id: []: ()
 QuoteLineItem ID: 0QLL00000001CRNOA2 

DistributorDiscountChangeTrigger :(used to update the discount ,which enter in account and should updte the value in related QuoteLineItem)
trigger DistributorDiscountChangeTrigger on Account (after update) 
{
    if(checkRecursive.runOnce())
{
    Map<Id, Account> accByIds = new Map<Id, Account>();
       for ( Account acc: Trigger.NEW) 
    {
        System.debug('Inside FOR Loop');
        if ( acc.Distributor_Discount_Service__c != Trigger.oldMap.get(acc.Id).Distributor_Discount_Service__c || acc.Distributor_Discount_Product__c != Trigger.oldMap.get(acc.Id).Distributor_Discount_Product__c || acc.Distributor_Discount_Renewal__c != Trigger.oldMap.get(acc.Id).Distributor_Discount_Renewal__c) {
            accByIds.put( acc.Id, acc);
          System.debug('Account ID' +accByIds);    
        System.debug('Account ID' +accByIds.size());    
        }
    }
    
    Map<Id, Opportunity> oppByIds = new Map<Id,Opportunity>( [ SELECT Id,Distributor__c FROM Opportunity WHERE Distributor__c IN: accByIds.keySet() AND IsClosed = FALSE]);        
       System.debug('Opportunity ID' +oppByIds.size());
 List<QuoteLineItem> qlitmp = [select id,quote.opportunity.Distributor__c,quote.opportunity.Override_Renewal_Discount__c,quote.opportunity.RecordType.name,Distributor_Discount_1__c,quote.opportunity.Distributor__r.Distributor_Discount_Renewal__c,product2.family,quote.opportunity.Distributor__r.Distributor_Discount_Service__c ,quote.opportunity.Distributor__r.Distributor_Discount_Product__c from quotelineitem where quote.opportunity.ID IN: oppByIds.keySet()]; 
     List<Opportunity> oppqt = [ SELECT Id,RecordType.name ,Override_Renewal_Discount__c,Distributor__r.Distributor_Discount_Renewal__c,Distributor__r.Distributor_Discount_Service__c,Distributor_Discount_Product_Temp__c,Distributor_Discount_Service_Temp__c,Distributor__c FROM Opportunity WHERE Id IN: oppByIds.keySet()];
      System.debug('Opportunity -list'+oppqt.size());   
     
    
    if ( !accByIds.isEmpty() ) 
    {
        System.debug('Inside if Loop');
        
       
         for ( Opportunity qt: oppqt ) 
         {
        /******* NST's Record Type == Service Renewal ***************/   //opp
               
                  if(qt.RecordType.name=='Service Renewal' && qt.Override_Renewal_Discount__c==false)
        { 
            System.debug('inside if');
            qt.Distributor_Discount_Service_Temp__c=  qt.Distributor__r.Distributor_Discount_Renewal__c;
        
             System.debug('Distributor_Discount_Renewal__c '+  qt.Distributor_Discount_Service_Temp__c); 
          
        }
      else  if(qt.RecordType.name=='Service Renewal' && qt.Override_Renewal_Discount__c==true)
        { 
            System.debug('inside if');
            qt.Distributor_Discount_Service_Temp__c=  qt.Distributor__r.Distributor_Discount_Service__c;
        
             System.debug('Distributor_Discount_Service__c '+  qt.Distributor_Discount_Service_Temp__c); 
          
        }
             
              /*******EOF NST's Record Type == Service Renewal ***************/
//
    else if ( qt.Distributor__c != null) 
    {
                qt.Distributor_Discount_Product_Temp__c = accByIds.get( qt.Distributor__c ).Distributor_Discount_Product__c;
               System.debug('opportunity.Distributor_Discount_Product_Temp__c '+  qt.Distributor_Discount_Product_Temp__c); 
               qt.Distributor_Discount_Service_Temp__c= accByIds.get( qt.Distributor__c ).Distributor_Discount_Service__c;
             System.debug('opportunity.Distributor_Discount_Service_Temp__c '+  qt.Distributor_Discount_Service_Temp__c); 

           }   
               
         }
         update oppqt;//opp
        
        
    }    
          for(quotelineitem qlitemp: qlitmp)
             {
                 system.debug('1');
                 if(qlitemp.quote.opportunity.RecordType.name=='Service Renewal' && qlitemp.quote.opportunity.Override_Renewal_Discount__c==false)
        { 
            system.debug('1-false');
           
           qlitemp.Distributor_Discount_1__c=qlitemp.quote.opportunity.Distributor__r.Distributor_Discount_Renewal__c;
         }
              else if(qlitemp.product2.family=='Service' && qlitemp.quote.opportunity.Distributor__c != null)
        {
            system.debug('12');
                 qlitemp.Distributor_Discount_1__c=qlitemp.quote.opportunity.Distributor__r.Distributor_Discount_Service__c ; 
        }
                 else if(qlitemp.product2.family=='product' && qlitemp.quote.opportunity.Distributor__c != null)
                 {
                     system.debug('13');
                     qlitemp.Distributor_Discount_1__c=qlitemp.quote.opportunity.Distributor__r.Distributor_Discount_Product__c ; 
                 }
                
         }  
        system.debug('qlitmp'+qlitmp);
        update qlitmp; //qli 
             
 
     
        
        /************************** NST Product Service Update to TEMP ***********************/
        Map<Id, NST__c> nstdisByIds = new Map<Id,NST__c>( [ SELECT Id, Distributor_Account__c FROM NST__c WHERE  Distributor_Account__c IN: accByIds.keySet() AND NST_Status__c = 'Draft']);        
       System.debug('nstdisByIds ID' +nstdisByIds.size());

     List<NST__c> nstdis = [ SELECT Id,recordtype.id,recordtype.name,Distributor_Account__r.Distributor_Discount_Renewal__c,Distributor_Account__r.Distributor_Discount_Product__c,Distributor_Account__r.Distributor_Discount_Service__c, Product_Contractual_Discount_Temp__c,Service_Contractual_Discount_Temp__c,Distributor_Account__c FROM NST__c WHERE Id IN: nstdisByIds.keySet()];
    System.debug('nstdis -list'+nstdis.size());   
           for ( NST__c qt: nstdis ) 
         {
            System.debug('Inside FOr');
             /******* NST's Record Type == Service Renewal ***************/
        if(qt.RecordType.name=='Service Renewal')
        { 
            System.debug('inside if');
            qt.Service_Contractual_Discount_Temp__c=  qt.Distributor_Account__r.Distributor_Discount_Renewal__c;
             System.debug('Distributor_Discount_Renewal__c '+  qt.Service_Contractual_Discount_Temp__c); 
        }
        
         /******* End of NST's Record Type == Service Renewal ***************/
    else if ( qt.Distributor_Account__c != null) 
    {
                qt.Product_Contractual_Discount_Temp__c = accByIds.get( qt.Distributor_Account__c ).Distributor_Discount_Product__c;
               System.debug('opportunity.Product_Contractual_Discount_Temp__c '+  qt.Product_Contractual_Discount_Temp__c); 
               qt.Service_Contractual_Discount_Temp__c=  accByIds.get( qt.Distributor_Account__c ).Distributor_Discount_Service__c;
             System.debug('opportunity.Service_Contractual_Discount_Temp__c '+  qt.Service_Contractual_Discount_Temp__c);  
           }       
         }

      update nstdis;  
        system.debug('Updated'+nstdis.size());
           system.debug('Updated'+nstdis);
        /*************************************************************************************/
        
        
    }
}

Please advice,

Thanks
Sumitha P

 
Hi All,

How to migrate all of the product images from the documents folder in classic to a library in Files.

Thanks in Advance.
Sumitha P
Hi Guys, 
Need help on creating a post in chatter from workbench or any application like postman tools. 
when we try using workbench it showing as "INVALID SESSION id".

please advice on possible solution. 
Thanks in advance, 
Sumitha P
Hi Guys,

What are the possible ways to receive mail from outside salesforce(like gmail/outlook) under Case Email object(EmailMessage)?

Thanks,
Sumitha P
Hi,

Business Requirement:
Once email is received(Email Message of Case),We have to show the unread Email Message in the Enhanced List view of Case.

Need help --> If the user sends the mail via outlook/Gmail,how will those mail will those mail will place under the Respective Email Message in Case Related List.


Thanks in Advance,
Sumitha P
Hi All,

When i try to write Page reference
GenerateDocument - It is Visual force page in CPQ Managed Package.It is called when Generate Document button is clicked in Quote Detail Page.
//Quote.id --> retrieves current CPQ Quote id
PageReference pr = new PageReference('apex/GenerateDocument?id=' + quote.id);
               
        
                 Attachment at     =   new Attachment();
                 Blob b = pr.getContentAsPDF();
                    at.Body        =  b;
                        at.ParentId   =   quo1.Id;
                 at.ContentType = 'pdf';
                 insert at;
Displays Error as :
core.apexpages.exceptions.ApexPagesGenericException: The page can't be loaded because the remote site apex/GenerateDocument isn't listed in your organization's Remote Sites Settings.
But I try to create new Remote Site  --> but it does not works on my end.

Please Advice and suggest.

Thanks,
Sumitha P
 
Hi All,

I have attached the code  where I have passed the variable through contructor in Batch Apex class

I have written Batch apex with constructor and execute and written system.debug for checking.
Where it is not seeing the system.debug statement inside Execute method in debug logs.

I need help on execution method in Batch Apex.I am unaware why the execute method is not working on my side.
Apex class:
Extension_Batch  batch = new Extension_Batch(Newprdt,newRecord);
         Database.executeBatch(batch,200);
Batch Apex class:
global class Extension_Batch implements Database.Batchable<sObject>
{
 global List<B__c> Newprdt123;
 global  A__c newRecord123;   
 global Extension_Batch(List<B__c> Newprdt,A__c newRecord)
{
   //this block is working fine

    system.debug('Newprdt_batch'+Newprdt);
    system.debug('newRecord'+newRecord);
   Newprdt123 = Newprdt;
   newRecord123 = newRecord;
    system.debug('Newprdt123'+Newprdt123);
    system.debug('newRecord123'+newRecord123);
}
// Start Method
    global Database.QueryLocator start(Database.BatchableContext bc) 
    {
        system.debug('instart');
     return Database.getQueryLocator('Select id,OwnerId,IsDeleted,RecordTypeId,CreatedDate,CreatedById,LastModifiedDate, LastModifiedById  from A__c');
    }
   // Execute method
    global void execute(Database.BatchableContext BC,List<B__c> Newprdt123) 
    { 
        
       system.debug(' '+Newprdt123);  
       system.debug('newRecord123'+newRecord123); 
        
     for(B__c prdt :Newprdt123)
       {
         for(PricebookEntry pbe2 :[SELECT Id,Name,isactive,PriceBook2Id,Pricebook2.id,Product2.CurrencyIsoCode,
                                     PriceBook2.Name,PriceBook2.isactive,Product2.Name,Product2.ProductCode,
                                         Product2.family,UnitPrice,Product2.Description,product2.isactive FROM PriceBookentry 
                                         where Product2.ProductCode =:prdt.Name and isactive=true
                                         and Pricebook2.id=:newRecord123.PriceList__c])
           {
            if( prdt.List_Price_Per_Unit__c <> pbe2.UnitPrice & pbe2.Product2.ProductCode == prdt.Name)
               {
                  prdt.List_Price_Per_Unit__c = pbe2.UnitPrice;
               }
             update prdt;  
              
           }
          
                
       List<Pricebookentry> pbe3=[SELECT Id,Name,isactive,PriceBook2Id,Product2.ProductCode,PriceBook2.Name,PriceBook2.isactive,Product2.Name,
                                         Product2.family,Product2.Description,Unitprice,product2.isactive FROM PriceBookentry 
                                         where Product2.ProductCode =:prdt.Name and isactive=false and Pricebook2.id=:newRecord123.PriceList__c];
       
           if(pbe3.size() ==1)
           {
          for(Pricebookentry pbe1:pbe3)
          {
                            
       List<B__c> stpr =[Select id,IsDeleted,Product__r.id,Name,CreatedDate,CreatedById,LastModifiedDate,LastModifiedById,SystemModstamp,LastActivityDate From B__c 
                                   where Number1__c=:newRecord123.id and Name=: pbe1.product2.ProductCode];
              
            
              delete stpr;
         
          }
       }
           
       }
    }       
    // Finish Method
    global void finish(Database.BatchableContext BC) 
    {
       system.debug('Batch apex completed');
    }

}
Thanks in advance.
Sumitha P
 
  • September 24, 2019
  • Like
  • 0
Hi All,
I Have an Visual force page with some Set of List and String.
I have given those List and string While calling the Batch apex
Extension_Batch  batch = new CloneNSTExtension_Batch(List name,String name);
         batch.executeBatch(batch);
My clarification is how to take the String name inside the excute method in batch apex.Because,those string(which have value from the  normal apex class) I have added as the Condition value in query.

Please advice.

Thanks in advance
Sumitha P
trigger saleInsertedTrigger on i360__Sale__c (after update) {
     for (i360__Sale__c S: Trigger.new) {
     
     if(s.EE_Service_Level__c = 'full' || s.EE_Service_Level__c = 'Audit Only'){
     
     }
    JCFS.API.createJiraIssue('Project ID', 'Issue Type ID');
}
Hi I need your help here.

We need to have schedule.Start_Date__c disabled when schedule.Products_Offer__c == 'Product B'.

Also, I would like to know if it is possible that it will be disabled as soon as I select the Picklist Product B.
 
<apex:actionRegion>
<div class="slds-truncate" title="">
	<apex:inputField style="width:90px;" value="{!schedule.Start_Date__c}" rendered="{!schedule.Products_Offer__c != 'Willow Rail Platform'}">
		<apex:actionSupport event="onchange" rerender="tableId" status="status"/>
	</apex:inputField>
	<apex:outputField style="width:90px;" value="{!schedule.Start_Date__c}" rendered="{!schedule.Products_Offer__c == 'Willow Rail Platform'}">
		<apex:actionSupport event="onchange" rerender="tableId" status="status"/>
	</apex:outputField>
</div>
</apex:actionRegion>
Any kind of help is much appreciated!
 
how to access a field present in custom object from opportunity line product?
I have a custom Object USB,there is a field called USBNumber .
I want to access USBNumber field in Opportunity Product?
Hi All, 

Need help on displaying the Nearby contacts within the radius(10km) around our current location  in Google Maps without using the Map component in the visual force page.

Please advice.

Thanks,
Sumitha P
trigger CreationOfContact on Account (after insert,after Update) {
Map<Id,Decimal> mp=new Map<Id,Decimal>();
list<Contact> lst=new List<Contact>();
  for(Account a:Trigger.New)
  { 
   mp.put(a.id,a.Number_Of_Contacts__c);
  }
   if(Trigger.isInsert && Trigger.isAfter)
   {
    if(mp.size()>0 && mp!=null)
    {
     for(Id a:mp.keyset())
     {
      for(Integer i=1;i<=mp.get(a);i++)
      {
        Contact c=new Contact();
        c.lastname='Test'+i;
        c.accountid=a;
        lst.add(c);
      }
     }
    }
   }
   insert lst;
   if(Trigger.isUpdate && Trigger.isAfter)
   {
    
   for(Account a:Trigger.new)
   {
    Decimal a1=trigger.oldmap.get(a.id).Number_Of_Contacts__c;
    Decimal a2=trigger.newMap.get(a.id).Number_Of_Contacts__c;
    Decimal a3=0;
    if(a2>a1)
    {
      a3=a2-a1;
      for(Integer i=1;i<=a3;i++)
      {
        Contact c=new Contact();
        c.lastname='Update' +i;
        c.AccountId=a.id;
        lst.add(c);
      }
     }    
    }
      insert lst;
   }
   
}


In this trigger i have created a custom field called no.of.contacts on account object, i've the following scenario:
1. When a new account is created and the that field is populated with (say 2) it should create 2 new contacts.

2. When i edit the that field ( say to 5 now before it was 2 ) so the difference of both is now 3, so it should 3 more contacts.

3. when i edit that field to (say to 4 now earlier the new updated value is 5) so the difference is 1 here , therefore 1contact should be deleted.


So, the code i've written works well upto 2nd scenario, the only problem i;m facing now is at 3rd scenario.

Could someone help me out?