• Afrose Ahamed
  • NEWBIE
  • 40 Points
  • Member since 2021

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 13
    Questions
  • 11
    Replies

Hi All,
Greetings of the day! 
We are storing password as a encryptedText in a custom object but still we have got flagged by salesforce security review. To connect external database we need to  store external password in salesforce. By changing visibility to private will solve the issue or shall we explain to security review team about why we are storing will they approve? Please advise.

 

<fields>

        <fullName>Password__c</fullName>

        <deprecated>false</deprecated>

        <externalId>false</externalId>

        <inlineHelpText>What is the password used by this user to connect to the database?</inlineHelpText>

        <label>Password</label>

        <length>30</length>

        <maskChar>asterisk</maskChar>

        <maskType>all</maskType>

        <required>false</required>

        <trackTrending>false</trackTrending>

        <type>EncryptedText</type>

    </fields>

        ...

        <sharingModel>ReadWrite</sharingModel>

    	<visibility>Public</visibility>

	</CustomObject>
Hi All,
​​​​​​In batchapex when multiple user tries to update or insert same record or same user at multiple times tries to insert or update on same record at same time  Im getting the following error delete failed. first exception on row 0 with id xxxxxxxxxx; first error: entity_is_deleted, entity is deleted: []. 

I really appreciate if someone explain. It will be a great help to me to understand better.

Here is my code:(sometimes happened too many dml rows error in batchapex reducing the batch size to 50 it's fixed)
 
Trigger Updaterec on courses__c (After Insert, After update) {
List<string>studentids =new List<string>();
For(courses__c  course:trigger.new){
Studentids.add(course.students__c);
}
<students__c> students = [select I'd,schools__c from students__c where id IN:studentids];
List<string> schoolids =new list<string>();
For(students__c sc:students){
schoolids.add(sc.school__c);
}
Mycontroller.updateschool(schoolids);
}

Apex class
Public with sharing class Mycontroller{
Public static void updateschool(list<string>schoolids){
Integer Counts = [select count(Id)number from schools__c where id IN:schoolids].get('number');
If(Counts<4000){
List<schools__c> oldschoollist =[select Id, name from schools__c where id IN:schoolids];
Dmlhandler.delete(oldschoollist);
//Again querying the same school and its related record inserting as new records with user newly added records
/*Logic goes here
*
*
*
*/
Dmlhandler.Insert(newschoollist);
}else{
batchlogic batch = new batchlogic(schoolids);
batch.schoolids=schoolids;
Database.Executebatch(batch);
}
}
}

Batch apex
Public with sharing class Mycontroller{
Public static void updateschool(list<string>schoolids){
Integer Counts = [select count(Id)number from schools__c where id IN:schoolids].get('number');
If(Counts<4000){
List<schools__c> oldschoollist =[select Id, name from schools__c where id IN:schoolids];
Dmlhandler.delete(oldschoollist);
//Again querying the same school and its related record inserting as new records with user newly added records
/*Logic goes here
*
*
*
*/
Dmlhandler.Insert(newschoollist);
}else{
batchlogic batch = new batchlogic(schoolids);
batch.schoolids=schoolids;
Database.Executebatch(batch);
}
}
}

Regards,
Afrose​​​​​​​
Hi All,
When I change vf version from 18.0 to 56.0 I'm getting the following error The processing instruction target matching "[xX][mM][lL]" is not allowed. There is no space in xml. And i pasted the code on top of the page before apex:page but still the same problem I'm getting. Is there any release update on contentType or xml to change. Can someone please advise how to fix this error.
 
<apex:page controller="myController" contentType=application/octet-stream#{test.name}><?xml version="1.0" encoding="UTF-8"?>

Regards,
Afrose​​​​​​​
Hi All,
Greetings of the day! 
Below mentioned two lines are exceeding governor limits. I want to change this below mentioned  line with condition based. If query rows is below 50000 and DML rows below 10000 then its should be in sync process if above it should be in async process. which is best batch apex or scheduled apex and how i can change the code and how can i wrote batch apex or scheduled apex. Please some one help me on this.
//some times this query exceeding more than 50000 rows and giving an error
        List<Obj2__c> obj2new = [SELECT id,name,(SELECT name FROM objs1__r) FROM Obj2__c WHERE id in : paramids];


//some times this line exceeding 10000 dml rows and giving an error
        RecordsManager.InsertAsSystem( paramnewlist );
 
trigger ParamsUpdate on Obj1__c (after insert, after update ) {
    
    if(trigger.IsAfter && (trigger.IsInsert || trigger.IsUpdate))    
    {
    List<String> obj2Ids = new List<String>();
	
    for( Obj1__c objs: Trigger.New){
        obj2Ids.add ( objs.Obj2__c);
    }
        
    
    List<Obj3__c> obj3ids = [SELECT id, Obj4__c FROM Obj3__c WHERE obj2__c IN : obj2Ids];
    
    List<String> obj4idlst= new List<String>();
    
    for( Obj3__c obj3 : obj3ids){
        obj4idlst.add( obj3.Obj4__c);
    }
    
        
        MyLogics.updateParams ( obj4idlst ); 
        }
        
}
 
public with sharing class MyLogics{
   
    public static void updateParams( List<String> obj4idlst ){
          
        Map<String,List<String>> paramsMap = new Map<String,List<String>>();
        
        List<Obj3__c> oldparams = [SELECT id FROM Obj3__c WHERE Obj4__c IN : obj4idlst ];  
        
        RecordsManager.DeleteAsSystem( oldparams );
         // Delete oldparams;  
 
        
        List<Obj4__c> Objs4 = [SELECT id,name,(SELECT id,name,Obj2__c FROM Objs3__r) FROM Obj4__c WHERE id IN : obj4idlst];
        List<String> paramids = new List<String>();
        
       
        
        for( Obj4__c obj4: Objs4){ 
            for( Obj3__c lst : obj4.Objs3__r){
                paramids.add ( lst.Obj2__c );
            } 
            	
        }
        
        //this query exceeding morethan 50000 rows
        List<Obj2__c> obj2new = [SELECT id,name,(SELECT name FROM objs1__r) FROM Obj2__c WHERE id in : paramids];
        
        
        List<String> tempParam = new List<String>();
        for( Obj2__c func: obj2new){
           
            for( Obj1__c Param : func.objs1__r ){
                tempParam.add ( Param.Name );
            }      
            paramsMap.put ( func.Id, tempparam);
        }
        
        
        
        List<Obj3__c> paramnewlist = new List<Obj3__c>();
        for( Obj4__c lsts: Objs4){ 
            for( Obj3__c FTS : lsts.objs3__r ){
                if( paramsMap.get ( FTS.Obj2__c) != null){
                    for( String parameterName : paramsMap.get ( FTS.Obj2__c )){
                        paramnewlist.add( new Obj3__c( name=parameterName, Obj4__c=lsts.Id));
                    }
                }    
            } 
        }
       //this line exceeding 10000 dml rows   
        RecordsManager.InsertAsSystem( paramnewlist );
          
    }  
}

Regards,
Afrose Ahamed M.G.
Hi All,
When i update record only after update firing as expected. But i insert record both after insert and after update firing. Im not sure its due to recursion. But in my org there is no work flow update rule in this object. So im not sure its recursion issue or not. But i tried to add boolean static variable but still the same execution is happening. Please someone help on this to understand better.
trigger ParamsUpdate on Obj1__c (after insert, after update ) {
    
    if(trigger.IsAfter && (trigger.IsInsert || trigger.IsUpdate))    
    {
    List<String> obj2Ids = new List<String>();
	
    for( Obj1__c objs: Trigger.New){
        obj2Ids.add ( objs.Obj2__c);
    }
        
    
    List<Obj3__c> obj3ids = [SELECT id, Obj4__c FROM Obj3__c WHERE obj2__c IN : obj2Ids];
    
    List<String> obj4idlst= new List<String>();
    
    for( Obj3__c obj3 : obj3ids){
        obj4idlst.add( obj3.Obj4__c);
    }
    
        
        MyLogics.updateParams ( obj4idlst ); 
        }
        
}
 
trigger ParamsUpdate on Obj1__c (after insert, after update ) {
    
    if(trigger.IsAfter && (trigger.IsInsert || trigger.IsUpdate))    
    {
    List<String> obj2Ids = new List<String>();
	
    for( Obj1__c objs: Trigger.New){
        obj2Ids.add ( objs.Obj2__c);
    }
        
    
    List<Obj3__c> obj3ids = [SELECT id, Obj4__c FROM Obj3__c WHERE obj2__c IN : obj2Ids];
    
    List<String> obj4idlst= new List<String>();
    
    for( Obj3__c obj3 : obj3ids){
        obj4idlst.add( obj3.Obj4__c);
    }
    
        
        MyLogics.updateParams ( obj4idlst ); 
        }
        
}

Regards,
Afrose Ahamed M.G.
 
Hi All,

How to avoid too many SOQL error. In following code im getting too many SOQL error. Please someone advise. 
public pageReference saveObjs(){
DML.InsertOp(obj);
try{

      Object_A__c obj =[select name, id,(Select name, Object_C__c,Status__c From 
     Objects_B__corder by Status__c ) from Object_A__c  where 
     id=:string.ValueOf(Obj.get('ObjA__c'))];
     list<Object_B__c > collection =obj.Objects_B__corder;
     Object_D__c newobjs = new Object_D__c();
for(Object_B__c B:collection){
   newobjs.Object_C__c=B.Object_C__c;
   newobjs.Object_O__c=obj.id;
   newobjs.Status__c =B.Status__c;
   DML.InsertOp(newobjs);
   List<Object_D__c>objd=[select          Object_E__c,Status__c, from Object_D__c where Object_C__c=:B.Object_C__c];
for(Object_D__c d:objd){
   Object_F__c newF=new Object_F__c();
   newF.Object_E__c=d.Object_E__c;
   newF.Object_D__c=newobjs.id;
   newF.Status__c=d.Status__c;
  Object_E__c EE=[select Order__c From Object_E__c where id=:d.Object_E__c];
  newF.Order__c=EE.Order__c;
  DML.InsertOp(newF);
}Object_D__c newobjs = new Object_D__c();
}
}catch(Exception e){
System.debug(e);
}
}



Regards,
Afrose Ahamed 
 

Hi All,

This is just snippet of code that i want to acheive. My apologise if its not understandable im a beginner. I want show a prompt in that  i want show number of records counts from apex class before deleting action happened.Somehow  prompt is showing but Deleting records count is not showing. Please refer the below code and advise how can i acheive this. it will be a great help..

<apex:page sidebar="false" showHeader="false" controller="OldDataController" standardstylesheets="false">
 <script>
    function changeComplete(){
    	alert('{!numberOfRecDeleted}');    
    }
	</script>

 <apex:commandLink oncomplete="changeComplete();" onclick="if(!confirm('Do you want to proceed? {!numberOfRecDeleted}')) return false;"  action="{!DeloldRecords}" status="loadingStatus"  style="margin-left:4px;"><span class="glyphicon glyphicon-file"></span> Delete Records</apex:commandLink>
                          
</apex:page>
public with sharing class OldDataController {

public static Integer numberOfRecDeleted {get;set;}

public static void delController(List<Records__c> DelRecs){
list<String> DelRecsNames = new List<String>();
for(Records__c DelRec : DelRecs)
{
DelRecsNames.add(DelRec.name);
}
numberOfRecDeleted = DelRecsNames.size();
DMLManager.deleteAsuser([Select id from Records__c where id:DelRecsNames]);
System.debug('Number of Records Deleted'+numberOfRecDeleted);
}


User-added image

Regards,

Afrose Ahamed M.G

Hi All,
I have created Parent component in that when Account search its needs to display contacts. its successfully displayed. i Want to display contacts on child component. So i created on child component and passed values. But its nothing showin. Please help thanks in advance.
 

Parent Component
<template>
    <lightning-card title="How to display the Contacts based on Account Name in LWC" custom-icon="custom:icon13">
     
        <div class="slds slds-p-horizontal--medium">
         <div class="slds-grid slds-wrap">
            <div class="slds-col slds-size_4-of-12 slds-m-bottom--medium">
                <lightning-Input type="search" placeholder="Search..." value={accountName} name="accountName" class="accountName" onchange={handleChangeAccName}></lightning-input>                 
             </div>
             <div class="slds-col slds-size_6-of-12 slds-m-top--medium" style="margin-top: 19px; margin-left: 10px;">                 
                    <lightning-button label="Search Account Name" size="small" variant="brand" onclick={handleAccountSearch} icon-name="utility:search" icon-position="right"></lightning-button>
             </div>
         </div>
          
         <h2>Account Name :- <span><strong>{currentAccountName}</strong></span></h2>
 
         <h3><strong><span style="color:brown;">{dataNotFound}</span></strong></h3>

         <template if:true={flagIndicatingDataHasBeenLoadedInVariables}>
           <c-child-comp records-value={records}></c-child-Comp>
           </template>
</div>
    </lightning-card>
</template>
*****************************************
import { LightningElement, track, wire } from 'lwc';
import retrieveContactData from '@salesforce/apex/lwcAppExampleApex.retrieveContactData';

export default class DisplayContactsOnAccountName extends LightningElement {

   @track currentAccountName;
   @track searchAccountName;
    handleChangeAccName(event){
      this.currentAccountName = event.target.value;      
    }

    handleAccountSearch(){
       this.searchAccountName = this.currentAccountName;
    }
   
    @track records;
    @track dataNotFound;
    @track flagIndicatingDataHasBeenLoadedInVariables = false;
    @wire (retrieveContactData,{keySearch:'$searchAccountName'})
    wireRecord({data,error}){
        if(data){           
            this.records = data;
            this.error = undefined;
            this.dataNotFound = '';
            this.flagIndicatingDataHasBeenLoadedInVariables = true;
            if(this.records == ''){
                this.dataNotFound = 'There is no Contact found related to Account name';
            }

           }else{
               this.error = error;
               this.data=undefined;
           }
    }
}
Child Component

<template>
    <h2 class="slds-m-bottom--x-small" style="color:darkslateblue; font-weight:bold;">Displaying Contacts Records based on Account Name</h2>
           <table class="slds-table slds-table_cell-buffer slds-table_bordered" border="1" cellspacing="0" cellpadding="0" bordercolor="#ccc" style="border-collapse:collapse;">
               <thead>
                   <tr>
                       <th>First Name</th>
                       <th>Last Name</th>
                       <th>Email</th>
                       <th>Phone</th>
                       <th>Description</th>
                   </tr>
               </thead>
               <tbody>
                   <template for:each={records} for:item="conItem">
                       <tr key={conItem.Id}>
                           <td>{conItem.FirstName}</td>
                           <td>{conItem.LastName}</td>
                           <td>{conItem.Email}</td>
                           <td>{conItem.Phone}</td>
                           <td>{conItem.Account.Name}</td>
                       </tr>
                   </template>
               </tbody>
           </table>
        

<br/><br/>
   
</template>
****************************************************
import { LightningElement,api } from 'lwc';

export default class ChildComp extends LightningElement {

    @api recordsValue;
    

}

 



Regards,

Afrose Ahamed M.G.

Hello All,
When a lead is converted, is it possible to find out, in an Apex trigger, whether the ConvertedAccountId is referecing to an existing Account or an Account created as a result of the conversion? Or in another word, can I find out whether a user selected an existing account or created a new account as part of the lead conversion process?

Thanks,

Afrose Ahamed 

Hello All,
 When Lead convert if users choose Create New' then validation rule on lead needs to run if they choose 'Choose Existing' validation rule don't need to run. So i created check box on lead with unchecked.
Validation rule: AND(AfroseDev__By_Pass_Validation_Rule__c = True &&
ISBLANK(Email))


After that i created trigger to bypass validation rule. But its running on both 'Create New' and 'Choose Existing' please refer the below code. Please help how can i acheive this.
trigger LeadCurrencyTrigger on Lead ( Before Insert, Before Update, after insert,After Update) {
   list<id>OldAlloppid = new list<id>();//hold all opportunities ids in the list
    list<id>Convertedid = new list<id>();//hold currentConverted Opportunity Id in the list
    for(Opportunity op:[select id from Opportunity]){
        OldAlloppid.add(op.id);
        
    }
    
    for(lead l:trigger.new){
        Convertedid.add(l.convertedOpportunityId);
        
 // this condition will check the if current convertedoppid not in the existing opportunity records.
        if(OldAlloppid!=Convertedid)
        {
           
            System.debug('Convertedid'+Convertedid + 'oldMap'+OldAlloppid);
        if(l.IsConverted && trigger.isBefore){
			
            System.debug('im inside');
            l.AfroseDev__By_Pass_Validation_Rule__c = true;
        }
    }    
	
}  
}



Regards,
Afrose Ahamed M.G

Hi All, 
When lead conversion if i choose existing opportunity its showing me this error (There was an error converting the lead. Please try again. If the problem persists, please contact your administrator.)  I know why this error causing due to if lead currency and opportunity currency are not same then this error will show. But this is very difficult to understand for users.  So i wrote a trigger to show custom error. When i try with other fields its showing the error what i need to show. But if try to show for currency field its showing system error not my custom error. How can i override system error. 
//just for testing to check trigger LeadCurrencyTrigger on Lead (Before insert,Before Update) {
 list<lead> ls=new list<lead>([SELECT LastName, Email, CurrencyIsoCode,AfroseDev__CurrencyISO__c, IsConverted, ConvertedAccountId, ConvertedContactId, ConvertedOpportunityId FROM Lead]);
        for(Lead ls:trigger.new){
            String acid = ls.ConvertedOpportunityId;
            for(Lead op:trigger.new){
                if(op.IsConverted){
                for(Opportunity Ac: [select id,Name,CurrencyIsoCode, AfroseDev__CurrencyISO__c from Opportunity where id=:acid] ){
                if(ls.CurrencyIsoCode!=Ac.CurrencyIsoCode){
                    system.debug('ls.LastName'+ls.LastName);
                    system.debug('Ac.Name'+Ac.Name);
                 trigger.new[0].adderror('Please select different location');
            }
                }
                }
            }


Also i tried i created one formula field on lead and one formula field on opportunity to store currencyISO value and i tried calling to show my custom error but still im getting system error. How can i acheive this please help. 
Thanks,
Afrose Ahamed M.G.
 

Hi All,

At line 13 im getting error System.NullPointerException: Argument cannot be null. Please help me guys how can i sort out this issue
Error Line Highlighted in Bold
 

public with sharing class checkRec{
    public List<sObject> soblist {get;set;}
    public String oblabel { get;set;}
    public String Obtype {get;set;} //Object API Name
    public List<Schema.FieldSetMember> fls {get;set;} //The fields from the fieldset
    public String obql {get;set;}
    public Search__c Search {get;set;}
    public String spquery { get;set; }
    public String spqueryid { get;set; }
    
    public checkRec(){
        //set Object Type and Fields(Error Line)
        evt= String.escapeSingleQuotes(ApexPages.currentPage().getParameters().get('Obtype '));
        if(Obtype == getNamePrefix.getNamePrefix()+'Check__c')
            Obtype = getNamePrefix.getNamePrefix()+'Note__c';
        if(Obtype == getNamePrefix.getNamePrefix()+'Source__c')
            Obtype = getNamePrefix.getNamePrefix()+'Data_Source__c';    
        if(Obtype == getNamePrefix.getNamePrefix()+'User_Details__C')
            Obtype = 'User';    
            
        Map<String , Schema.SObjectType> globalDescription = Schema.getGlobalDescribe();             
        oblabel= globalDescription.get(Obtype ).getDescribe().getLabel();
        Schema.SObjectType SObjectTypeObj = globalDescription.get(Obtype);
        Schema.DescribeSObjectResult DescribeSObjectResultObj = SObjectTypeObj.getDescribe();
        try{
            Schema.FieldSet fieldSetObj = DescribeSObjectResultObj.FieldSets.getMap().get(getNamePrefix.getNamePrefix()+'LookUp');  
            fields = fieldSetObj.getFields();

        } catch(exception e){
             System.debug('Add Loos Field Set to this object');
             ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Error,'This Object does not have a \'checkRec\' Field Set'));
        }        
        Search__c = new Search__c();
   
        runlooks();
              
    }
 

   Thanks,
Afrose Ahamed M.G.


Please anyone explain what is my mistakes here.
I Want to set output values from apex action.
public class flowinputs{
            @invocableVariable public String oppId;
           }
User-added image
As per above mentioned im getting oppId as input values from apex class.
But Store Output Values not showing  from my apex results  class oppsdetails, oppsdetail.
 
public class results{
            @invocableVariable public Decimal oppsdetails;
        public results(Decimal objname){this.oppsdetails=objname;}
          @invocableVariable public string oppsdetail;
        public results(string objnam){this.oppsdetail=objnam;}
        
    }

See below image output values not showing from apex class result oppdetails,oppdetail. In ouput i can't able to declare new resources also.
User-added image
Please refer the below my full apex code.
 
public class checksum {
    public class flowinputs{
            @invocableVariable public String oppId;
           
    }
    public class results{
            @invocableVariable public Decimal oppsdetails;
        public results(Decimal objname){this.oppsdetails=objname;}
          @invocableVariable public string oppsdetail;
        public results(string objnam){this.oppsdetail=objnam;}
        
    }
@invocableMethod
    public static list<list<results>> countSum(list<flowinputs> requests){
        list<list<results>> Wrapperclass=new list<list<results>>();
        list<results> Resultrecords=new list<results>();
        usd.add(Resultrecords);
        List<id> oppids = new list<Id>();       
        for(flowinputs request:requests)
        {
            oppids.add(request.oppId);
            
        }
        for(AggregateResult Qsum: [select Quote__r.id quoteid,Product__r.id prid,sum(Quantity__c) qunty from QuoteLine__c where Quote__r.id=: oppids group by Product__r.id,Quote__r.id]){
           String accid =(String)Qsum.get('quoteid');
            String acid =(String)Qsum.get('prid');
            Decimal quotesums=(Decimal)Qsum.get('qunty');
           // System.debug('accid' +accid);
            System.debug('sum'+quotesums);
            Resultrecords.add(new results(quotesums));
              Resultrecords.add(new results(acid));
            Resultrecords.add(new results(accid));
        }
            
return Wrapperclass;
    }
    
}
Getting outputs but unable to store set output values from apex class to  flow.
User-added image
I passed below like this also:
apex code:
public class checksum {
    public class flowinputs{
            @invocableVariable public String oppId;
           
    }
    public class results{
            @invocableVariable public Decimal oppsdetails;
        public results(Decimal objname){this.oppsdetails=objname;}
          @invocableVariable public string oppsdetail;
        public results(string objnam){this.oppsdetail=objnam;}
        
    }
@invocableMethod
    public static list<results> countSum(list<flowinputs> requests){
       
        list<results> RecordsResults=new list<results>();
      
        List<id> oppids = new list<Id>();       
        for(flowinputs request:requests)
        {
            oppids.add(request.oppId);
            
        }
        for(AggregateResult Qsum: [select Quote__r.id quoteid,Product__r.id prid,sum(Quantity__c) qunty from QuoteLine__c where Quote__r.id=: oppids group by Product__r.id,Quote__r.id]){
           String accid =(String)Qsum.get('quoteid');
            String acid =(String)Qsum.get('prid');
            Decimal quotesums=(Decimal)Qsum.get('qunty');
           // System.debug('accid' +accid);
            System.debug('sum'+quotesums);
            RecordsResults.add(new results(quotesums));
              RecordsResults.add(new results(acid));
            RecordsResults.add(new results(accid));
        }
            
return RecordsResults;
    }
    
}

for above mentioned apex code im getting Setoutput values as Oppdetails, oppdetail from apex class.
User-added image

When declaring variable to set this. Im getting error like this
User-added image

My Requirement is:
Invokable Contains an Input variable with for “input variable” to be passed from flow to the apex class Query all QuoteLine__c records that have the field Quote__c populated with the input variable record ID Group all returned records by the field Product__c, SUM all values in Quantity__c Return a collection variable containing the following values to be passed back to flow for further utilization. Quote ID Quote Line ID Product ID Quantity
 
Please anyone explain how can i acheive this.

Regards,
Afrose
Hi All,
​​​​​​In batchapex when multiple user tries to update or insert same record or same user at multiple times tries to insert or update on same record at same time  Im getting the following error delete failed. first exception on row 0 with id xxxxxxxxxx; first error: entity_is_deleted, entity is deleted: []. 

I really appreciate if someone explain. It will be a great help to me to understand better.

Here is my code:(sometimes happened too many dml rows error in batchapex reducing the batch size to 50 it's fixed)
 
Trigger Updaterec on courses__c (After Insert, After update) {
List<string>studentids =new List<string>();
For(courses__c  course:trigger.new){
Studentids.add(course.students__c);
}
<students__c> students = [select I'd,schools__c from students__c where id IN:studentids];
List<string> schoolids =new list<string>();
For(students__c sc:students){
schoolids.add(sc.school__c);
}
Mycontroller.updateschool(schoolids);
}

Apex class
Public with sharing class Mycontroller{
Public static void updateschool(list<string>schoolids){
Integer Counts = [select count(Id)number from schools__c where id IN:schoolids].get('number');
If(Counts<4000){
List<schools__c> oldschoollist =[select Id, name from schools__c where id IN:schoolids];
Dmlhandler.delete(oldschoollist);
//Again querying the same school and its related record inserting as new records with user newly added records
/*Logic goes here
*
*
*
*/
Dmlhandler.Insert(newschoollist);
}else{
batchlogic batch = new batchlogic(schoolids);
batch.schoolids=schoolids;
Database.Executebatch(batch);
}
}
}

Batch apex
Public with sharing class Mycontroller{
Public static void updateschool(list<string>schoolids){
Integer Counts = [select count(Id)number from schools__c where id IN:schoolids].get('number');
If(Counts<4000){
List<schools__c> oldschoollist =[select Id, name from schools__c where id IN:schoolids];
Dmlhandler.delete(oldschoollist);
//Again querying the same school and its related record inserting as new records with user newly added records
/*Logic goes here
*
*
*
*/
Dmlhandler.Insert(newschoollist);
}else{
batchlogic batch = new batchlogic(schoolids);
batch.schoolids=schoolids;
Database.Executebatch(batch);
}
}
}

Regards,
Afrose​​​​​​​
Hi All,
When I change vf version from 18.0 to 56.0 I'm getting the following error The processing instruction target matching "[xX][mM][lL]" is not allowed. There is no space in xml. And i pasted the code on top of the page before apex:page but still the same problem I'm getting. Is there any release update on contentType or xml to change. Can someone please advise how to fix this error.
 
<apex:page controller="myController" contentType=application/octet-stream#{test.name}><?xml version="1.0" encoding="UTF-8"?>

Regards,
Afrose​​​​​​​
Hi All,
Greetings of the day! 
Below mentioned two lines are exceeding governor limits. I want to change this below mentioned  line with condition based. If query rows is below 50000 and DML rows below 10000 then its should be in sync process if above it should be in async process. which is best batch apex or scheduled apex and how i can change the code and how can i wrote batch apex or scheduled apex. Please some one help me on this.
//some times this query exceeding more than 50000 rows and giving an error
        List<Obj2__c> obj2new = [SELECT id,name,(SELECT name FROM objs1__r) FROM Obj2__c WHERE id in : paramids];


//some times this line exceeding 10000 dml rows and giving an error
        RecordsManager.InsertAsSystem( paramnewlist );
 
trigger ParamsUpdate on Obj1__c (after insert, after update ) {
    
    if(trigger.IsAfter && (trigger.IsInsert || trigger.IsUpdate))    
    {
    List<String> obj2Ids = new List<String>();
	
    for( Obj1__c objs: Trigger.New){
        obj2Ids.add ( objs.Obj2__c);
    }
        
    
    List<Obj3__c> obj3ids = [SELECT id, Obj4__c FROM Obj3__c WHERE obj2__c IN : obj2Ids];
    
    List<String> obj4idlst= new List<String>();
    
    for( Obj3__c obj3 : obj3ids){
        obj4idlst.add( obj3.Obj4__c);
    }
    
        
        MyLogics.updateParams ( obj4idlst ); 
        }
        
}
 
public with sharing class MyLogics{
   
    public static void updateParams( List<String> obj4idlst ){
          
        Map<String,List<String>> paramsMap = new Map<String,List<String>>();
        
        List<Obj3__c> oldparams = [SELECT id FROM Obj3__c WHERE Obj4__c IN : obj4idlst ];  
        
        RecordsManager.DeleteAsSystem( oldparams );
         // Delete oldparams;  
 
        
        List<Obj4__c> Objs4 = [SELECT id,name,(SELECT id,name,Obj2__c FROM Objs3__r) FROM Obj4__c WHERE id IN : obj4idlst];
        List<String> paramids = new List<String>();
        
       
        
        for( Obj4__c obj4: Objs4){ 
            for( Obj3__c lst : obj4.Objs3__r){
                paramids.add ( lst.Obj2__c );
            } 
            	
        }
        
        //this query exceeding morethan 50000 rows
        List<Obj2__c> obj2new = [SELECT id,name,(SELECT name FROM objs1__r) FROM Obj2__c WHERE id in : paramids];
        
        
        List<String> tempParam = new List<String>();
        for( Obj2__c func: obj2new){
           
            for( Obj1__c Param : func.objs1__r ){
                tempParam.add ( Param.Name );
            }      
            paramsMap.put ( func.Id, tempparam);
        }
        
        
        
        List<Obj3__c> paramnewlist = new List<Obj3__c>();
        for( Obj4__c lsts: Objs4){ 
            for( Obj3__c FTS : lsts.objs3__r ){
                if( paramsMap.get ( FTS.Obj2__c) != null){
                    for( String parameterName : paramsMap.get ( FTS.Obj2__c )){
                        paramnewlist.add( new Obj3__c( name=parameterName, Obj4__c=lsts.Id));
                    }
                }    
            } 
        }
       //this line exceeding 10000 dml rows   
        RecordsManager.InsertAsSystem( paramnewlist );
          
    }  
}

Regards,
Afrose Ahamed M.G.
Hi All,
When i update record only after update firing as expected. But i insert record both after insert and after update firing. Im not sure its due to recursion. But in my org there is no work flow update rule in this object. So im not sure its recursion issue or not. But i tried to add boolean static variable but still the same execution is happening. Please someone help on this to understand better.
trigger ParamsUpdate on Obj1__c (after insert, after update ) {
    
    if(trigger.IsAfter && (trigger.IsInsert || trigger.IsUpdate))    
    {
    List<String> obj2Ids = new List<String>();
	
    for( Obj1__c objs: Trigger.New){
        obj2Ids.add ( objs.Obj2__c);
    }
        
    
    List<Obj3__c> obj3ids = [SELECT id, Obj4__c FROM Obj3__c WHERE obj2__c IN : obj2Ids];
    
    List<String> obj4idlst= new List<String>();
    
    for( Obj3__c obj3 : obj3ids){
        obj4idlst.add( obj3.Obj4__c);
    }
    
        
        MyLogics.updateParams ( obj4idlst ); 
        }
        
}
 
trigger ParamsUpdate on Obj1__c (after insert, after update ) {
    
    if(trigger.IsAfter && (trigger.IsInsert || trigger.IsUpdate))    
    {
    List<String> obj2Ids = new List<String>();
	
    for( Obj1__c objs: Trigger.New){
        obj2Ids.add ( objs.Obj2__c);
    }
        
    
    List<Obj3__c> obj3ids = [SELECT id, Obj4__c FROM Obj3__c WHERE obj2__c IN : obj2Ids];
    
    List<String> obj4idlst= new List<String>();
    
    for( Obj3__c obj3 : obj3ids){
        obj4idlst.add( obj3.Obj4__c);
    }
    
        
        MyLogics.updateParams ( obj4idlst ); 
        }
        
}

Regards,
Afrose Ahamed M.G.
 

Hello All,
When a lead is converted, is it possible to find out, in an Apex trigger, whether the ConvertedAccountId is referecing to an existing Account or an Account created as a result of the conversion? Or in another word, can I find out whether a user selected an existing account or created a new account as part of the lead conversion process?

Thanks,

Afrose Ahamed 

Hello All,
 When Lead convert if users choose Create New' then validation rule on lead needs to run if they choose 'Choose Existing' validation rule don't need to run. So i created check box on lead with unchecked.
Validation rule: AND(AfroseDev__By_Pass_Validation_Rule__c = True &&
ISBLANK(Email))


After that i created trigger to bypass validation rule. But its running on both 'Create New' and 'Choose Existing' please refer the below code. Please help how can i acheive this.
trigger LeadCurrencyTrigger on Lead ( Before Insert, Before Update, after insert,After Update) {
   list<id>OldAlloppid = new list<id>();//hold all opportunities ids in the list
    list<id>Convertedid = new list<id>();//hold currentConverted Opportunity Id in the list
    for(Opportunity op:[select id from Opportunity]){
        OldAlloppid.add(op.id);
        
    }
    
    for(lead l:trigger.new){
        Convertedid.add(l.convertedOpportunityId);
        
 // this condition will check the if current convertedoppid not in the existing opportunity records.
        if(OldAlloppid!=Convertedid)
        {
           
            System.debug('Convertedid'+Convertedid + 'oldMap'+OldAlloppid);
        if(l.IsConverted && trigger.isBefore){
			
            System.debug('im inside');
            l.AfroseDev__By_Pass_Validation_Rule__c = true;
        }
    }    
	
}  
}



Regards,
Afrose Ahamed M.G

Hi All,

At line 13 im getting error System.NullPointerException: Argument cannot be null. Please help me guys how can i sort out this issue
Error Line Highlighted in Bold
 

public with sharing class checkRec{
    public List<sObject> soblist {get;set;}
    public String oblabel { get;set;}
    public String Obtype {get;set;} //Object API Name
    public List<Schema.FieldSetMember> fls {get;set;} //The fields from the fieldset
    public String obql {get;set;}
    public Search__c Search {get;set;}
    public String spquery { get;set; }
    public String spqueryid { get;set; }
    
    public checkRec(){
        //set Object Type and Fields(Error Line)
        evt= String.escapeSingleQuotes(ApexPages.currentPage().getParameters().get('Obtype '));
        if(Obtype == getNamePrefix.getNamePrefix()+'Check__c')
            Obtype = getNamePrefix.getNamePrefix()+'Note__c';
        if(Obtype == getNamePrefix.getNamePrefix()+'Source__c')
            Obtype = getNamePrefix.getNamePrefix()+'Data_Source__c';    
        if(Obtype == getNamePrefix.getNamePrefix()+'User_Details__C')
            Obtype = 'User';    
            
        Map<String , Schema.SObjectType> globalDescription = Schema.getGlobalDescribe();             
        oblabel= globalDescription.get(Obtype ).getDescribe().getLabel();
        Schema.SObjectType SObjectTypeObj = globalDescription.get(Obtype);
        Schema.DescribeSObjectResult DescribeSObjectResultObj = SObjectTypeObj.getDescribe();
        try{
            Schema.FieldSet fieldSetObj = DescribeSObjectResultObj.FieldSets.getMap().get(getNamePrefix.getNamePrefix()+'LookUp');  
            fields = fieldSetObj.getFields();

        } catch(exception e){
             System.debug('Add Loos Field Set to this object');
             ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Error,'This Object does not have a \'checkRec\' Field Set'));
        }        
        Search__c = new Search__c();
   
        runlooks();
              
    }
 

   Thanks,
Afrose Ahamed M.G.