• SFDC ROCK
  • NEWBIE
  • 20 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 29
    Questions
  • 5
    Replies
Hi All,
I have a field ABC on lead .After creating lead if ABC has changed within 2 two days then fine otherwise send notification mail to lead owner that please take action.
How to achieve that ?

Thanks
How to find a__c ,b__c and c__c table from object  S and object P
if we do not have any direct relationship between both but Object O is having relationship with S and P.

SQOL Query ?
 
Hi All,
Getting below error when inserting 100 records
System.LimitException: Apex CPU time limit exceeded

String ob= Schema.getGlobalDescribe().get('Opportunity').getDescribe().getRecordTypeInfosById().get(opp.RecordTypeId).getName();
if(ob=='oops'){
//updating one field
}

Any alternate way to get recordtype name ? or other way to write above code ?
 
how can I move below process builder on trigger code.

object : abc

Condition :    abc.pstatus  equal   picklist   preveiw
                     abc.rstatus  equal   picklist   sreveiw
                      abc.initail  equal   picklist   sales
                      abc.initail   equal    picklist calli
                      abc.type equal   picklist   rtype
                      abc.dtype equal   picklist   aac
            
            custom logic 
            
            (1 AND 4)or (2 AND 3) AND 5 AND 6
            

Action : insert and update on acb object

         record:   abc
         
        field:          status equal done        

         inseet and update on different object def
         
         record:   abc.def
          
        field:            status equal done      

Thanks,   
I have one trigger where I am inserting/updating one field called Amount (Currecny (16,2)) from opportunitylineitem to object A (which is related object on opportunity).

suppose:

opportunitylineitem  amount :2 EUR

getting result 
object A      amount :2 USD

expected 

object A      amount :2 EUR


what could be the issue ?
 if(!TypeAmountMap.containsKey(Shot.type__c)){
                   
                    TypeAmountMap.put(Shot.type__c,Shot.Amount__c);
                    system.debug('TypeAmountMap1'+TypeAmountMap);   // every time I am getting records here
                }else{
                    TypeAmountMap.put(Shot.type__c, TypeAmountMap.get(Shot.type__c)+Shot.Amount__c);
                    system.debug('TypeAmountMap2'+TypeAmountMap);     // records are not getting created any time ....if i am inserting multiple records also. what can be the reason ? why not coming here
                                                                         
                   note: type__c : formula fiel
 TypeAmountMap this map is having value type__c and amount__c which every time getting populated.
 Method Snipet :
 
 Map<String,Decimal> typeAmonutMap= new Map<String,Decimal>();
                  for(items__c Item:LineItem){
                      if(typeAmonutMap.containsKey(Item.Type__c)){  
                           } 
                           
            typeAmonutMap.put(Item.Type__c,Item.Amount__c);
        system.debug('typeAmonutMap====' +typeAmonutMap);
==>  // getting  type=A     Amount=3
                         type=A      amount=4
                         type=B      Amount= 6                                                                            type=B       Amount=9
                         type=B      amount=3
                         type=C     amount=99
                                                                                           

I need to insert above record to the related object like below:

Record1 

type=A amount=7 (3+4)

Record2

Type=B  Amount=18 (6+9+3)        

Record3

Type=C amount=99

and so on.    

Please help me to complete the method.
Problem statement:

from Items object (related object on oppty) copy type__c values and Amount__c values and create (only insert) records on object item_product__c (related object on oppty)after calulating amount__c and type__c.

type__c  value from Items object
A
B
C
D

if records is getting created on items object 

type__c=A   Amount__c=5
type__c=A   Amount__c=6
type__c=C   Amount__c=10
type__c=c   Amount__c=6
type__c=B   Amount__c=8
.....

records should be created on item_product__c like below

type__c=A   Amount__c=11   //(5+6)
type__c=B   Amount__c=8
type__c=C   Amount__c=16

total 3 records should get created.

Note : amount is formula field on item but same amount is currecy field on item_product__c


Createrecord(itemIdFrompreviousmethodIds); // taking id from previous method
}
 public static void Createrecord(Set<Id> itemIdFrompreviousmethodIds){
        Set<String> Types = new Set<String>();
        for(Type__mdt TypeCM : [Select type__c from Type__mdt]){ //>>>>>>>>>>> metadata where store all type__c values.
            Types.add(TypeCM.type__c);                // adding all type__c values and keeping it into set
        }
        
        
 Map<Id,List<items__c>> opptyitemList = new Map<Id,List<items__c>>();
        
         for(items__c item : [select Id,type__c,Amount__c,Opportunity__c from items__c where Id IN : itemIdFrompreviousmethodIds and product_type__c IN :Types]){    
                                  // getting all records from item which is related object of oppty 
            
            
            //mapping for item with opptyId.
             if(opptyitemList.containsKey(item.id)){
             
                  list<items__c> LineItemLst=opptyitemList.get(item.id);
                   LineItemLst.add(item);
                    opptyitemList.put(item.Opportunity__c,LineItemLst); // not getting any values.
                     
             } else { 
                 opptyitemList.put(item.Opportunity__c, new List<items__c>());  
                  opptyitemList.get(item.Opportunity__c).add(item);   // creating records and getting mapped value.
                  
                  //how should I write code so that I can create records on item_product__c 
                
                         
                     }
                     
                 }
          
             } 
             
   Any modification or any other suggestions will be appreciated.
How to write a trigger code with handler class to copy few field value from one object (A)to another object (B) ?


Condition :1
Object A

picklist Field : Subodh            Salary =5000
picklist Field : Subodh             Salary =7000

Object B 
picklist Field : Subodh       Total Salary :12000

Condition : 2

Object : A

picklist Field : Subodh             Salary =7000
picklist Field : Rahul                Salary =7000
picklist Field : Amit                  Salary =5000
picklist Field : Rahul                Salary =7000
picklist Field : Amit                   Salary =5000


Object : B

picklist Field : Subodh            Total Salary =7000
picklist Field : Rahul               Total Salary =14000
picklist Field : Amit                  Total Salary =10000


Thanks
Subodh
Hi All,
when ever we are selecting any record from list view and changing the lead status.
suppose lead status value:Open - Not Contacted 
and dependent value : A,B
User-added image

and after changing lead status value:Working - Contacted​​​​​​​ 
we are not chaning the depend field so the value is still same A ,B
which is not correct because for Working - Contacted we have dependent value :C and D
User-added image

how can we change dependent value also or restrict  wrong value ?

as we can see the extra picklist value is coming as below : A is not correct value for Working - Contacted​​​​​​​ .
User-added image
 
Hi All,

Suppose we have record type1 : values :a,b,c,d,e,f,g,h,i
                              record type2 : values:a,b,c,d,e,Z

from backend we are able to update Z value in record type1.

How can we stop that.
Can we use valdaition rule?
Thanks,
Hi All,

I want to restrict change status picklist value for every diffeent record type
User-added image

Suppose record type1 : a,b,c (picklist values)
        record type2 :a,b,c,d

for when I select  record type1 in the record the change status tab should have value a,b,c only.
User-added image

in above screenshot i dont want negotiation piclist value.

How can we achieve this funtionality.

Thanks
Hi All,

I have two fields 
1.abc (Date)
2.def (picklist) (2020,2021,2022,2023,2024......2050).
I want to create 3rd field (FORMULA FILED) where I want to update def based on abc whenever I choose any date from abc field the year should get coppied to the field def.

example :
abc : 1/2/2020
def : 2020

I have same logic on process builder which I want to deactivate and
write formula field.

Thanks,
Subodh

 
Hi All,

Whenever we are giving input to comment field ,it is overflowing the value as below screenshot.
User-added image
below is lightning code used for this.Can someone suggest me what is causing this issue ?

<div class="slds-section slds-is-open">           
               <div class="slds-grid slds-wrap slds-grid--pull-padded">                                                               
                              <div class="slds-p-horizontal--small slds-size--1-of-2">
                                             <div class="slds-form-element slds-hint-parent slds-has-divider--bottom slds-p-around--x-small hasDiv">
                                                            <label class="slds-form-element__label">comment</label>
                                                            <div class="slds-form-element__control" style="min-height: 18px;">
                                                                           <aura:if isTrue="{!v.isEditPage}">
                                                                                          <ui:inputText class="slds-output" value="{!v.Oppty.Comment__c}" maxlength="100"/>
                                                                                          <aura:set attribute="else">
                                                                                                         <ui:outputText class="slds-output" value="{!v.Oppty.Comment__c}" />
                                                                                                         <span class="slds-float--right litIcon editIcon" onclick="{!c.changeEditLayout}">
                                                                                                                        <lightning:icon iconName="utility:edit" size="xx-small" alternativeText="Indicates approval"/>
                                                                                                         </span>
                                                                                          </aura:set>
                                                                           </aura:if>
                                                            </div>
                                             </div>
                              </div>                  
               </div>
</div>

Thanks,
Subodh
 
I am writing Batch Apex Query String where the soql limit I want to avoid.How can we avoid the limit in below batch code ?

     DateTime currentTime = System.now();
      DateTime ddd = currentTime.addHours(-2);
      list<Total__c> campaignInfluenceList = new List<Total__c>();
      campaignInfluenceList = [select Id,CampaignId__c,OpportunityId__c,CampaignId__r.unique__c from Total__c where lastmodifieddate>=:ddd];
            Set<Id> oppIds = new Set<Id>();
//how to avoid soql limit in below for loop.
            for(Total__c d:campaignInfluenceList){
                oppIds.add(d.OpportunityId__c);
             }
             
                  String str = 'opportunityCreatedFromLead';
     string query='Select Id,Name,unique__c,Type,Lead_ID__c,createdby.profile.Name,(select Id,CampaignId__c,OpportunityId__c,CampaignId__r.Source__c from Total__r ) from Opportunity where id=: oppIds ';
     
     return Database.getQueryLocator(query); 

Thanks,
How to write test class for below class

 global void execute(Database.BatchableContext bc, List<opportunity> scope){
 List<opportunity>  ls=new list<opportunity>();
  Map<Id,opportunity> update = new Map<Id,opportunity>();
  for(opportunity oppty:scope){
 if(oppty.abc=='P' && oppty.abc!='M' 
                           && oppty.createdby.profile.Name=='Custom: TCT'){
                            oppty.abc='M';
                             //Updated below opptyListUpdate List to update Map as to avoid duplicate values
                             update.put(oppty.Id,oppty);
                             ls.add(oppty);
                             break;
Hi All,
How to find opportunity id for last 2 or 3 hours in soql ?
I want to use this in batch apex as query string in where clause.

Currently I am using below code for retriving id for one day with help of custom setting:
=============================
from Opportunity where\t'; query += 'createddate = '+day; //custom setting

Thanks,
Subodh
It is shwing error "suken--crmdev1.cs97.my.salesforce.com refused to connect."

can we do any changes in code ?
<apex:page>
  
  <script type="text/javascript">
  var one = true;
  var window;
  
window.onload = function() {

if(one == true) {
 var Id= "{!$CurrentPage.Parameters.Id}";                    

var newwindow = window.open('/apex/managed_package_visualforce_page1?Id='+Id,target="_self");
  newwindow.focus(); 
  
if(newwindow != '' && newwindow != null){
var newwindow1 = window.open('/apex/managed_package_visualforce_page1?Id='+Id, '_self');
newwindow1.focus(); 
}
one = false;
}  
};
</script>  
</apex:page>
After deploy in QA the code coverage is showing 0% in QA but in dev its 100% 
After running test class in qa its showing below error

Internal Salesforce Error: 992167576-63130 (-2133302522) (-2133302522)
I have a trigger with below logic with that logic I want to create batch apex  and schedule it daily.
Can we do it with below logic or need to write complete different code ?


public class handlerclass{
public static void methodname(List<sbject> newlist,Map<Id,sobject> oldmaplist){

    set<Id> oppIds = new  set<Id>();
    Map<Id,osbject1> oppupdate = new Map<Id,osbject1 >();
    for(sobject__c so: newlist){
        
        if(so.sobject1Id__c!=null)
           oppIds.add(so.sobect1Id__c);

    }

        if(!oppIds.isEmpty()){
            for(sobeject1 oppty : [Select name,id,address__c from osbject1 where uid='frame']){
                    
                    if(condition){
                        
                        for(loop){
                            if(condition){
                                
                                if(condition);
                                   //assigment logic';
                                   
                                    //update logic
                                    break;
                                }
                                if(condition){
                                    //assigment logic';
                                   
                                    //update logic;
                                    break;
                                }
                                if(condition){
                                    //assigment logic';
                                   
                                    //update logic;
                                   
                               }
                            }
                        }
                    }
 Method Snipet :
 
 Map<String,Decimal> typeAmonutMap= new Map<String,Decimal>();
                  for(items__c Item:LineItem){
                      if(typeAmonutMap.containsKey(Item.Type__c)){  
                           } 
                           
            typeAmonutMap.put(Item.Type__c,Item.Amount__c);
        system.debug('typeAmonutMap====' +typeAmonutMap);
==>  // getting  type=A     Amount=3
                         type=A      amount=4
                         type=B      Amount= 6                                                                            type=B       Amount=9
                         type=B      amount=3
                         type=C     amount=99
                                                                                           

I need to insert above record to the related object like below:

Record1 

type=A amount=7 (3+4)

Record2

Type=B  Amount=18 (6+9+3)        

Record3

Type=C amount=99

and so on.    

Please help me to complete the method.
How to write a trigger code with handler class to copy few field value from one object (A)to another object (B) ?


Condition :1
Object A

picklist Field : Subodh            Salary =5000
picklist Field : Subodh             Salary =7000

Object B 
picklist Field : Subodh       Total Salary :12000

Condition : 2

Object : A

picklist Field : Subodh             Salary =7000
picklist Field : Rahul                Salary =7000
picklist Field : Amit                  Salary =5000
picklist Field : Rahul                Salary =7000
picklist Field : Amit                   Salary =5000


Object : B

picklist Field : Subodh            Total Salary =7000
picklist Field : Rahul               Total Salary =14000
picklist Field : Amit                  Total Salary =10000


Thanks
Subodh
What will be execution
priority of below in salesforce :

1.after update workflow  
2.procees builder  
3.aproval procees
4.workflow
we can not call one asynchronous process to another asynchronous process but how can we call from one batch to another batch since batch is also asynchronous process?