I would like to hire a Programmer

Cerrado Publicado hace 6 años Pagado a la entrega
Cerrado Pagado a la entrega

Updating related records via an apex batch:

Here is my code; I need all of the EFE and IL numbers to display in their respected lists.

global class BatchUpdateEFEandIL5 implements

[url removed, login to view]<sObject>, [url removed, login to view]{

private static Id oevsRecTypeId;

private static Id tvsRecTypeId;

// Prepare collections

// create a list that is empty but new, so not null.

global static List <Account> SubAcct = new List <Account>();

// global static String EFEList = '' ;

// global static String ILList = '' ;

private List<String> EFEList = new List<String>();

private List<String> ILList = new List<String>();

//private String queryString;

private integer Summary = 0;

public [url removed, login to view] start([url removed, login to view] BC){

// only use accounts that are of OEVS and TVS record type.

oevsRecTypeId = [url removed, login to view]().get('OEVSCompany').getRecordTypeId();

tvsRecTypeId = [url removed, login to view]().get('TVS Company').getRecordTypeId();

// query string will get us all the info we need for the child accts

String queryString = 'select ID, Company_infolease__c, company_ecredit__c ' +

'from Account ' +

'where (recordtypeid = :oevsRecTypeId or recordtypeid = :tvsRecTypeId) ' +

'and parentId = null';

return [url removed, login to view](queryString);

}

// excute gets called once per iteration, and iteration is a signle object, '<sObject>'.

public void execute([url removed, login to view] BC, List<sObject> scope) {

// variable for rollups

//(sObject s : scope) {

//if [url removed, login to view] == 'condition'

//do some logic

// else

// do some logic

// update scope

//}

// create a parent id list

List<Account> ParentIds = (List<Account>) scope;

// create dictionary of type acccount keyed by Id, will automatically insert all Ids associated w/ Accounts.

Map<id, Account> parentMap = new Map<Id, Account>(parentIds);

// create a list and set it to a query for the Children account

List<Account> Children = [

SELECT Id, Name, ParentID, ECredit__C, ECR_CUST_NUM__C

FROM Account

WHERE parentId in :ParentIds

];

// create an empty map where key is accountId and value is the list of Accounts. Then iterate through

// through the Account list

Map<Id, List<Account>> ParentIdToChildAccounts = new Map<Id, List<Account>>();

for(Account a : children){

// for each account 1st chk to see if there's already an entry in the ParentIdToChildAccounts map for the

// accounts parent Id (containgssKey method chks to see if that key already in map).

if([url removed, login to view]([url removed, login to view])){

// use get method to retrieve the list for the current parent Ids account and add that account

// to the list.

[url removed, login to view]([url removed, login to view]).add(a);

} else {

// if this is the first parentId for an acct u need to create an iniatilize the list of accounts accts

// for that account and insert that into the map

[url removed, login to view]([url removed, login to view], new List<Account>{a});

}

}

// given a parent account's id, we can grab a list of all child accounts from that map.

// create list of accts to update

List<Account> toBeUpdated = new List<Account>();

// go over all parent Id in child map

for(Id parentId : [url removed, login to view]()){

String EFEtoAppend = '';

String ILtoAppend = '';

for(Account childAccount: [url removed, login to view](parentId)){

// verify that and update is actually needed, if it hasen't insert child.

if(childAccount.eCredit__c != null){

EFEtoAppend += ', ' + childAccount.eCredit__c;

}

// grandchild

if(childAccount.ECR_CUST_NUM__c != null){

ILtoAppend += ', ' + childAccount.ECR_CUST_NUM__c;

// if(childAccount.childAccount.ECR_CUST_NUM__c != null)

// ILtoAppend += ', ' + childAccount.childAccount.ECR_CUST_NUM__c;

}

}

// now we have a parent account, with a string of concattenated EFE and IL list entries

// so lets update the parent

Account updated = [url removed, login to view](parentId);

updated.Company_infolease__c = ILtoAppend + ' ,';

updated.company_ecredit__c = ', ' + EFEtoAppend;

[url removed, login to view](updated);

}

[url removed, login to view][] srList = [url removed, login to view](toBeUpdated, false);

// loop through sr list

for ([url removed, login to view] sr : srList) {

if ([url removed, login to view]()) {

// Operation was successful, so get the ID of the record that was processed

[url removed, login to view]('Successfully inserted account. Account ID: ' + [url removed, login to view]());

}

else {

// Operation failed cause cause there are no records to update. Exit the code & return error msg.

for([url removed, login to view] err : [url removed, login to view]()) {

[url removed, login to view]('The following error has occurred.');

[url removed, login to view]([url removed, login to view]() + ': ' + [url removed, login to view]());

[url removed, login to view]('Account fields that affected this error: ' + [url removed, login to view]());

}

}

}

}

// Finish the method by refrencing the sObject

public void finish([url removed, login to view] BC){

// schedulable methods

//public void execute(schedulableContex context) {

// BatchUpdateEFEandIL5 batchJob = new BatchUpdateEFEandIL5();

// [url removed, login to view](batchJob);

//}

}

}

Programación Salesforce.com Desarrollo de software

Nº del proyecto: #14646080

Sobre el proyecto

10 propuestas Proyecto remoto Activo hace 6 años

10 freelancers están ofertando un promedio de $136 por este trabajo

TalentTouch

I am the best choice for you to write code. Strong performer , working in MNC 5 company . strong in apex class, trigger , batch class, Lightning etc. Relevant Skills and Experience Apex class , Visualforce Page , visu Más

$133 USD en 1 día
(0 comentarios)
0.0
karamchandani

We are a team of experienced and certified developers who will render services to you. Relevant Skills and Experience We provide work on salesforce platform which includes - APEX,VF,Device-Responsive ,salesforce gener Más

$100 USD en 7 días
(0 comentarios)
0.0
manishyadav867

I have worked on lot of batch classes . I have done a project in data migration from Territory Management to enterprise territory management.

$110 USD en 2 días
(0 comentarios)
0.0
sukhpartap556

It will finished in guaranteed two days Relevant Skills and Experience Salesforce Apex, Salesforce Integration, Proposed Milestones $155 USD - Everything

$155 USD en 2 días
(0 comentarios)
0.0