• abhinav gangrade
  • NEWBIE
  • 5 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 1
    Replies
Account and Review have look-up relationship. Please suggest solution to my situation. This works when every account have only or none review record. When account have more than one review then this will fail, How to merge two or more review records into one review record and update it to assign it to account as below.

Suppose one account have three review record, then these fields Subject__c, X20_Group__c, Current_Provider__c, DRAD__c, PVR__c, Service_Contract_Participation__c need to be union into one record and do similar operation as below.

//Account list to update
list<Account> accountListToUpdate = new list<Account>();

//Get the review records and put it in accountListToUpdate
for(Review__c reviewForVar : [select id , Account_Name__c , Subject__c, X20_Group__c, Current_Provider__c, DRAD__c, PVR__c, Service_Contract_Participation__c from Review__c where Account_Name__c!= null]){
    
    //Ensure the subject field is not empty
    if(reviewForVar.Subject__c != null && reviewForVar.Subject__c != ''){
               Account tempAcc = new Account();
                tempAcc.id = reviewForVar.Account_Name__c;
                tempAcc.Subject__c = reviewForVar.Subject__c;
tempAcc.X20Group__c = reviewForVar.X20_Group__c;
        tempAcc.Current_Provider__c = reviewForVar.Current_Provider__c;
        tempAcc.DRAD__c = reviewForVar.DRAD__c;
        tempAcc.PVR__c = reviewForVar.PVR__c;
tempAcc.Service_Contract_Participation__c = reviewForVar.Service_Contract_Participation__c;
                accountListToUpdate.add(tempAcc);
    }
}

//Update the list
update accountListToUpdate;
How to filter in SOQL on count criteria ?This Query give me info more than one review related list record on acocunt
SELECT Account_Name__c, count(id) FROM Review__c GROUP BY Account_Name__c HAVING Count(Account_Name__c) > 1

My question is how to ensure that duplicates are not part of below FOR query, please provide code or syntax to me.

for(Private_Account_Information__c reviewForVar : [select id , Account_Name__c , Subject__c, X20_Group__c, Current_Provider__c, DRAD__c, PVR__c, Service_Contract_Participation__c from Review__c where Account_Name__c!= null])
Hi, Account and 'Private_Account_Information have look-up relationship. I want to copy PrivateAccount Information notes to Account notes. PrivateAccount Information have account_name field on it.

List<Notes_List> Noteslist  = new List<Notes_List>();
List<Note> memberList = new List<Note>([SELECT Body,CreatedById,CreatedDate,Id,IsDeleted,IsPrivate,LastModifiedById,LastModifiedDate,OwnerId,ParentId,SystemModstamp,Title FROM Note where parent.type='Private_Account_Information__c']); // getting all the notes
    for(Note source : memberList )
    {
  Note destination = new Note();
        destination.body = source.body;
        destination.ParentId ='001V000000HaOui'; // How to assign private account information.Account name here ??
  destination.IsDeleted = source.IsDeleted;
        destination.Title = source.title;
  destination.IsPrivate = source.IsPrivate;
  destination.OwnerId = source.OwnerId;
  Noteslist.add(destination);
  }
    }
     insert Noteslist; // inserting new notes
I have account_share object and would like to delete or truncate records from it, pls suggest how to do it.
I am working on writing apex sharing anonymous code,
for(Account abc: [select Owner, CreatedBy, LastModifiedBy from account where CALENDAR_YEAR(createddate) = 2014]

How to assign UserOrGroupId with Owner, CreatedBy, LastModifiedBy for one account record. Pls suggest.
Hi,
I have similar endpoint in my wsdl apex generated code, I want to generic it among all environment, pls suggest. Any pseodo code is nice to have.

public String endpoint_x = 'http://YourServer/YourService';

Thanks,
Abhi