• john harvey 2
  • NEWBIE
  • 10 Points
  • Member since 2016

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

Hi all,

I have written a code to update all the siblings records and parent records of the record getting updated. I want to use MAP in below trigger if it is possible. I want to optimize it using MAP. Can anyone please help me? Thank you so much.

 

trigger Addressflag on Address__c (After update, After Insert) {
    if(Trigger.isUpdate || Trigger.isInsert){
    List<ID> ConIds = new List<ID>();
    Boolean needsUpdate = FALSE; 
    for (Address__c Adds: trigger.new)
    {
    ConIds.add(Adds.contact__c);
    }
    system.debug('parent con ids'+ConIds);
    contact con = [select id, checkbox__c, recordTypeId from contact where Id IN :conIds];
    List<Address__c> otherAlt = new List<Address__c>([select id, contact__c, checkbox__c, contact__r.recordTypeId from Address__c where contact__c in: conIDs]);
        for (Address__c adds: trigger.new)
        {
            for (integer i=0; i < otherAlt.size(); i++)
            {
                if ((otherAlt[i].contact__c==adds.contact__c) && (otherAlt[i].id != adds.id))
                {
                     otherAlt[i].checkbox__c = FALSE;
                     con.checkbox__c=FALSE;
                     needsUpdate = TRUE;
                }
            }
        }

        if(checkrecursive.runOnce())
        {
              if (needsUpdate)
              {
                  update otherAlt;
                  update con;
              }
        }
    }
 }
Contact has master detail relationship with address. What I am trying to do is whenever the checkbox on any of the address is checked I am unchecking the same checkbox from all other siblings and parent record. I am acheving it through above trigger but I am concerned about the time when 1000s f records will get inserted at same time.
What I want is even if an admin deletes the data it stays in salesforce and not visible to any other user. To achieve this I thought of a solution to create a button for delete and that would make a checkbox field true. Based on the value of checkbox field is there anyway I can restrict those record's access to only a group? Can this be achieved by sharing setting? I tried but did not work. Any suggestions please?
Purpose is to pull labeled or particular branch to local directory so by using ant migration tool I can deploy it to other sandbox.
I already have a migration tool set up which is working with 2 different orgs, I want to integrate it with some source control or version control so that it can pull the code from server and deploy it. 
On a Visualforce page, I'd like to run a script that can get the values of fields on another SF console tab.

Something like this method: 
sforce.console.chat.getDetailsByPrimaryTabId(primaryTabId:String, callback:***Function***)

However, the method above only works for retrieving details from a Live Agent chat session tab.
I want to be able to do this for other SF tabs.
 

Hi all,

I have written a code to update all the siblings records and parent records of the record getting updated. I want to use MAP in below trigger if it is possible. I want to optimize it using MAP. Can anyone please help me? Thank you so much.

 

trigger Addressflag on Address__c (After update, After Insert) {
    if(Trigger.isUpdate || Trigger.isInsert){
    List<ID> ConIds = new List<ID>();
    Boolean needsUpdate = FALSE; 
    for (Address__c Adds: trigger.new)
    {
    ConIds.add(Adds.contact__c);
    }
    system.debug('parent con ids'+ConIds);
    contact con = [select id, checkbox__c, recordTypeId from contact where Id IN :conIds];
    List<Address__c> otherAlt = new List<Address__c>([select id, contact__c, checkbox__c, contact__r.recordTypeId from Address__c where contact__c in: conIDs]);
        for (Address__c adds: trigger.new)
        {
            for (integer i=0; i < otherAlt.size(); i++)
            {
                if ((otherAlt[i].contact__c==adds.contact__c) && (otherAlt[i].id != adds.id))
                {
                     otherAlt[i].checkbox__c = FALSE;
                     con.checkbox__c=FALSE;
                     needsUpdate = TRUE;
                }
            }
        }

        if(checkrecursive.runOnce())
        {
              if (needsUpdate)
              {
                  update otherAlt;
                  update con;
              }
        }
    }
 }
Contact has master detail relationship with address. What I am trying to do is whenever the checkbox on any of the address is checked I am unchecking the same checkbox from all other siblings and parent record. I am acheving it through above trigger but I am concerned about the time when 1000s f records will get inserted at same time.
Purpose is to pull labeled or particular branch to local directory so by using ant migration tool I can deploy it to other sandbox.
I just started using the migration tool and got the custom object retrieval working fairly quickly.  The problem is when I go to deploy I get an error on every fields and an All field that is not a field of the object 

Here is the error:
All Component Failures:
1.  objects/My_Object__c.object (My_Object__c.My_Field__c) -- Error: Not in package.xml
2.  objects/My_Object__c.object (My_Object__c.All) -- Error: Not in package.xml


Here is package.xml:
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <types>
        <members>z87__My_Object__c</members>
        <name>CustomObject</name>
    </types>
    <version>36.0</version>
</Package>


 
I am creating a pre-chat page for live agent, I have copied the same code from Pre-Chat Form Code Sample mentioned in live agent developer guide, just replaced the button Ids.
I placed one chat button (ID : 573g00000008Ofd) on a VF page for testing with this pre-chat page. On clicking that, the pre-chat form opens. But when the form is submitted it always redirect to this button's custom chat page, regardless of which button I select from the drop down.

<select name="liveagent.prechat.buttons">
<option value="573g00000008Ofd">Chat Button 1 </option>
<option value="573g00000008OfY">Chat Button 2 </option>
</select>

Please let me know if I am missing something or some other code needs to be incorporated to get redirected to respective custom chat pages of the buttons.
 
Hi, 
I was trying to recover record which are accedently deleted from salesforce instance and I am using the following code:
 
global class BatchClass implements Database.Batchable<sObject>,Schedulable{
	global Database.queryLocator start(Database.BatchableContext bc){
		String query = 'SELECT Id, Name, IsDeleted, ItemName__c FROM Buffer__c WHERE IsDeleted = True ALL ROWS';
		return Database.getQueryLocator(query);
	}
	global void execute(Database.BatchableContext BC, List<Buffer__c> scope){
		List<Buffer__c> bufferList = new List<Buffer__c>();
        for(Buffer__c s:scope){
            s.ItemName__c='Gaurav';
            bufferList.add(s);
        }
        system.debug('Data--->'+bufferList);
        undelete bufferList;
    }
	global void finish(Database.BatchableContext bc){
        AsyncApexJob a = [SELECT Id, Status, NumberOfErrors, JobItemsProcessed, TotalJobItems, CreatedBy.Email FROM AsyncApexJob WHERE Id =:BC.getJobId()];
		Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
        String[] names = new String[]{a.CreatedBy.Email};
        mail.setToAddresses(names);
        mail.setSubject('Mail: Test');
        mail.setPlainTextBody('Hi ,\n\nThe following job is '+a.Status+' and jobId is '+a.Id+'\n\n\n Regards,\n'+a.CreatedBy.Email);
        Messaging.sendEmail(new Messaging.SingleEmailMessage[]{mail});
	}
    global void execute(SchedulableContext s){
		Database.executeBatch(this);        
    }
}

When I am trying to execute my batch class it doesnt undelete records from recycle bin. Can anyone please help me out. Thanks!