• Sarah
  • NEWBIE
  • 10 Points
  • Member since 2022

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 5
    Replies
I have the below code and there is a SOQL query inside for loop. I have been instructed to avoid SOQL in the loop as these are invoked for every iteration of the loop. Since i am a beginner in Salesforce i don't know how to implement that. Here's my code where i have advised to use Soql query and condition checking before for loop using a map.

 
if ((isTrgBefore && (isInsert||isUpdate ))){
   for( Item eachitem :newItemList ){
     if(eachItem.WhoId!=Null){
        Schema.SObjectType sobjectType =         eachItem.WhoId.getSObjectType();
        String sobjectName = sobjectType.getDescribe().getName();
        if(sobjectName.equals(UTIL_Constants.SubString)){ 
                    List<Strategy> stg=[select Type from Strategy where Id=:eachItem.WhoId];
                        for(Strategy s:stg){
                            if(s.Type=='Market Strategy' || s.Type=='Market Potency'){
                            eachItem.Strategy__c = eachItem.WhoId; 
                            }
                        }
         }
     }
     setWhatIds.add(eachItem.WhatId);
  }
}

 
  • May 23, 2022
  • Like
  • 0
An error is getting when users attempt to switch view via dropdown only on mobile devices. It is working fine in desktop. How to fix this issue? 

Thanks in advance. 
  • May 17, 2022
  • Like
  • 0
there is a button named "new item".on clicking the button (to create a new item) we have to fill certain fields. My requirement is " Account" field should be populated automatically based on the value from " Related " Field.
The data type of Account and Related fields are look up.
How can be update the field automatically based on the value entered in other field?
Some one please help me out
Thankyou in advance
  • May 13, 2022
  • Like
  • 0
Here is the Scenario there is a button named "new item".on clicking the button (to create a new item) we have to fill certain fields. My requirement is " Account" field should be populated automatically based on the value from " Related " Field.
How can be update the field automatically based on the value entered in other field?
Some one please help me out Thankyou in advance
  • May 13, 2022
  • Like
  • 0
I have the below code and there is a SOQL query inside for loop. I have been instructed to avoid SOQL in the loop as these are invoked for every iteration of the loop. Since i am a beginner in Salesforce i don't know how to implement that. Here's my code where i have advised to use Soql query and condition checking before for loop using a map.

 
if ((isTrgBefore && (isInsert||isUpdate ))){
   for( Item eachitem :newItemList ){
     if(eachItem.WhoId!=Null){
        Schema.SObjectType sobjectType =         eachItem.WhoId.getSObjectType();
        String sobjectName = sobjectType.getDescribe().getName();
        if(sobjectName.equals(UTIL_Constants.SubString)){ 
                    List<Strategy> stg=[select Type from Strategy where Id=:eachItem.WhoId];
                        for(Strategy s:stg){
                            if(s.Type=='Market Strategy' || s.Type=='Market Potency'){
                            eachItem.Strategy__c = eachItem.WhoId; 
                            }
                        }
         }
     }
     setWhatIds.add(eachItem.WhatId);
  }
}

 
  • May 23, 2022
  • Like
  • 0
An error is getting when users attempt to switch view via dropdown only on mobile devices. It is working fine in desktop. How to fix this issue? 

Thanks in advance. 
  • May 17, 2022
  • Like
  • 0
there is a button named "new item".on clicking the button (to create a new item) we have to fill certain fields. My requirement is " Account" field should be populated automatically based on the value from " Related " Field.
The data type of Account and Related fields are look up.
How can be update the field automatically based on the value entered in other field?
Some one please help me out
Thankyou in advance
  • May 13, 2022
  • Like
  • 0
Here is the Scenario there is a button named "new item".on clicking the button (to create a new item) we have to fill certain fields. My requirement is " Account" field should be populated automatically based on the value from " Related " Field.
How can be update the field automatically based on the value entered in other field?
Some one please help me out Thankyou in advance
  • May 13, 2022
  • Like
  • 0