• Austin Mueller
  • NEWBIE
  • 80 Points
  • Member since 2015


  • Chatter
    Feed
  • 3
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 32
    Replies
Requirement
I have to fetch all the content Notes that are associated to events created after 01-Aug-2016.

Logic path
I have taken the following path to get to content notes
  • fetch events
  • find the Link via ContentDocumentLink object by passing them Event ids fetched in step-1
  • fetch ContentVersion by passing ContentDocumentIds retrieved in step-2
  • check each contentversion record by looking at their fileType to filter out only notes (SNOTE).
Code
Set<id> ev=(new Map<Id, Event>([SELECT id from Event where CreatedDate > 2016-08-01T00:00:00Z])).keySet(); 
Map<id, ContentDocumentLink> cdlMap = new Map<id, ContentDocumentLink>(); 

for(ContentDocumentLink cdl: [SELECT ContentDocumentId, LinkedEntityId FROM ContentDocumentLink WHERE LinkedEntityId IN : ev]) 
{ 
    cdlMap.put(cdl.ContentDocumentId, cdl);         
    contentDocumentIdSet.add(cdl.ContentDocumentId); 
} 
system.debug('cdl keys > ' + contentDocumentIdSet ); 
List<ContentVersion> cvMap = new List<ContentVersion>(
              [SELECT Title, FileType, ContentDocumentId 
               FROM ContentVersion 
               WHERE ContentDocumentId IN:contentDocumentIdSet]); 

system.debug('cdlMap ' + cdlMap.size() + '| cvMap > ' + cvMap.size());

Problem
ContentVersion list (cvMap) is not returning anything.
  • I tried passing cdlMap.keySet() didn't work.
  • I then created a Set<id> and passed the map keyset to it and then supplied it to the SOQL, that didn't work either.
  • and now I tried the above code to created a set in loop and provide it in SOQL. Not working.
If I hardcode ContentDocumentId to SOQL single or multiple, it is working. Any help would be highly appreciated.
So I have tried and tried...everything from the process builder to being on the phone with SF support. Nothing has worked, but yet I need to figure something out.

I want to set up a trigger that does the following:

On an Account, say Company XYZ, we have a field called Type. If we set that to Ex-Customer I would like to have every contact that has portal access under that Account to have their portal access deactivated or in general their SF profile frozen/deactivated. Whatever functionality is easier, it doesnt matter to me. I cannot seem to make this happen! This would help us immensely! 

This is the trigger I have so far...

for(User u : [Select u.Id, u.IsActive, u.IsPortalEnabled from User u where u.ContactId in :cIds]){ if(u.IsActive || u.IsPortalEnabled ){ u.IsActive = false; u.IsPortalEnabled = false; usersToUpdate.add(u); } }

Please let me know what else I need to add in order to make the Ex-Customer connection and the deactivation of the user/profile/portal.

Thank you
Hello Experts,

I need help with this code to show only the words in the parent case description in the child case. At the moment the child case description lists all the keywords.
trigger CheckSecretInfo on Case (after insert, before update) {

	String childCaseSubject = 'Warning: Parent case may contain secret info';

	// Step 1: Create a collection containing each of our secret keywords
	Set<String> secretKeywords = new Set<String>();
	secretKeywords.add('Credit Card');
	secretKeywords.add('Social Security');
	secretKeywords.add('SSN');
	secretKeywords.add('Passport');
	secretKeywords.add('Bodyweight');


List<Case> casesWithSecretInfo = new List<Case>();
Set<String> KeyWords = new Set<String>();
for (Case myCase : Trigger.new){
if(myCase.Subject != childCaseSubject){

// Step 2 Loop through secretkeywords and add all offending words to a Set

for(String KeyWord: secretKeywords){
if(myCase.Description != null && myCase.Description.containsIgnoreCase(KeyWord)){
	secretKeywords.add(KeyWord);
    break;
    system.debug('Keywords are: ' + keyword);
}
}

system.debug('cases to create' + casesWithSecretInfo.size());
	//Loop through secretkeywords and if there is any secret keywords add case to be created

List<Case> casesToCreate = new List<Case>();
for(Case caseWithSecretInfo : casesWithSecretInfo){
    Case childCase = new Case();
    childCase.Subject = 'Warning: Parent case may contain secret info';
    childCase.ParentId = caseWithSecretInfo.Id;
    childCase.IsEscalated = true;
    childCase.Priority = 'High';
    childCase.Description = 'The following secret keywords were found: ' + KeyWords;
    casesToCreate.add(childCase);
}
    insert casesToCreate;
}
}

}
Thanks 
 
Hi Everyone,

We are integrating Oracle system with Salesforce. We are using a tool called Websphere Cast Iron to achieve the integration.

The tool provides us set of connectors to execute Salesforce Bulk APIs.

Problem:
-----------
Oracle source tables have huge data,we are fetching 10k records from source tables and submitting the batch to Salesforce and querying its status after couple of minutes. When we query for the batch results we are getting a valid response of either record created successfully or failed.

But the problem is the result row doesn't have "ExternalID" field defined in custom object, it has only 18 character "id", success and error elements. if we have "ExternalID" in result row along with"id" it would be easy for us to identify and update corresponding record in source table.

You may have suggestions like go and query salesforce with "id" and get ExternalID to update your source tables data.

However we want to know is there any work around to get "ExternalID" in batch results itself?

Second query is, Can we implement a logic to generate a unique 18 character sequence(Source table Primary key column + some character string) and set it as "id" while submitting the job itself, so when we get the batch result we know which part of the "id" is our primary key and update that record in source table with the "id".

Any suggestions please.

Thanks & Regards,
Srinivas
 
I'm working to solve an issue where my Controller Class sends an email. I set the ReplyTo and I set the SenderDisplayName those are both correct however. The email visually displays another users email that is no longer at the company. I can't understand or trace how this is being set. When I look at the mail details I see that the return path shows the old users email. We are not using Org Wide Defaults. How else could this from email address be set?
How to find out the Names Corresponding to each OwnerID in the SQL server database.

Thanks..
I had tried different triggers on Assets, however, none of them works. Even simple 'before insert' trigger. Then I did a simple workflow, it worked, however, for my requirements, simple workflow does not work. I need to update a value on Account which is parents of Assets, the value need to come from most recent date value from latest created Asset. 
 
I created my triggers under the standard object 'Asset', triggers. The only thing i noticed here is after i created the trigger, the sobject on top of the trigger section from is not 'Assets', which is different than other objects is
Sobject TypeAssets Owned - Epicor
 
Not sure why it is not “Assets”. Do you have any ideas of how to make this trigger work?



Apex Trigger Detail
Sobject Type:  Assets Owned - Epicor
Code below: 
trigger MaintenanceExpiration on Asset (after insert) {

    Set<ID> acctId = new Set<ID>();

    for(Asset ass: Trigger.new) {
        acctId.add(ass.Account.id);
    }
    List<Account> acctList=[SELECT id, Maintenance_Expiration__C from Account where id in :acctId];
    
    for(Asset ass: Trigger.new) {
        for( Account a: acctList){
           if (ass.Account.id==a.Id){
                if (a.Maintenance_Expiration__C==null){
                    Datetime epday = trigger.new[i].Maintenance_Expiry_Date__c;
                    a.Maintenance_Expiration__C= date.newInstance(epday.year(), epday.month(),epday.day());
                }
                else if(a.Maintenance_Expiration__C<trigger.new[i].Maintenance_Expiry_Date__c){
                    Datetime epday = trigger.new[i].Maintenance_Expiry_Date__c;
                    a.Maintenance_Expiration__C= date.newInstance(epday.year(), epday.month(),epday.day());

                }
                
          }
        }
    }
     if(acctList!=null && acctList.size()>0){
           //update account list;
           update acctList;
       }
    
}


 
Requirement
I have to fetch all the content Notes that are associated to events created after 01-Aug-2016.

Logic path
I have taken the following path to get to content notes
  • fetch events
  • find the Link via ContentDocumentLink object by passing them Event ids fetched in step-1
  • fetch ContentVersion by passing ContentDocumentIds retrieved in step-2
  • check each contentversion record by looking at their fileType to filter out only notes (SNOTE).
Code
Set<id> ev=(new Map<Id, Event>([SELECT id from Event where CreatedDate > 2016-08-01T00:00:00Z])).keySet(); 
Map<id, ContentDocumentLink> cdlMap = new Map<id, ContentDocumentLink>(); 

for(ContentDocumentLink cdl: [SELECT ContentDocumentId, LinkedEntityId FROM ContentDocumentLink WHERE LinkedEntityId IN : ev]) 
{ 
    cdlMap.put(cdl.ContentDocumentId, cdl);         
    contentDocumentIdSet.add(cdl.ContentDocumentId); 
} 
system.debug('cdl keys > ' + contentDocumentIdSet ); 
List<ContentVersion> cvMap = new List<ContentVersion>(
              [SELECT Title, FileType, ContentDocumentId 
               FROM ContentVersion 
               WHERE ContentDocumentId IN:contentDocumentIdSet]); 

system.debug('cdlMap ' + cdlMap.size() + '| cvMap > ' + cvMap.size());

Problem
ContentVersion list (cvMap) is not returning anything.
  • I tried passing cdlMap.keySet() didn't work.
  • I then created a Set<id> and passed the map keyset to it and then supplied it to the SOQL, that didn't work either.
  • and now I tried the above code to created a set in loop and provide it in SOQL. Not working.
If I hardcode ContentDocumentId to SOQL single or multiple, it is working. Any help would be highly appreciated.
HI,

Here am gone through a lot of research but some how am not getting a solution how to start, experts please help me out.

My requirement is:—

 I wanted to stream live data to Warehouse system from salesforce,if new records is inserted or udpated on standard objects like Account,contact,Opportunity,Lead etc..
I wanted to inform Warehouse system about new insertions and updations from salesforce,so here how can i start writing my programme.And totally i need 20-25 SObjects data to be informed at a time , as newbie it looks quite hard to start writing a code for it.

Any Help Greatly Appreciated!

Thanks in Advance!
Hi All,

Below are my requirements: 
I have  a VF page with a standard controller for custom object to create new record. This page is controlled by another VF page which checks on Profile. if the profile is "XXX" it will redirect to this VF page else standard page will open.

Now, i have over ridden New and Edit button with redirecting VF page.
The functionality is working fine for New..!!
But i am not getting any pre populated field value in case of Edit.:(

on click of edit am getting all the value's in my instance of a object in getter setter through """.getRecord();""
but i dont understand why they are not appearing on the UI....:(


below is the piece of code:

    $(document).ready(function(){
        var user = "{!$Profile.Name}";
        var prost = "{!pros.ID}";
        alert('Prospect----->ID'+prost);  
        if(user == 'Agent'/*|| ){
           console.log(' Agent profile');
           if (sforce.console.isInConsole()) {
               sforce.console.getEnclosingPrimaryTabId(closeSubtab);
              // alert(sforce.console.getEnclosingPrimaryTabId());
               sforce.console.openPrimaryTab(null, 'apex/ProspPage', true, 'Prosp VF Page');
                                                   
           }

i have tried passing the ID in the URL of openPrimaryTab but its still not working..:(

Please Help...!!!!!
 
cpu limit exceeded
I have master record and n number of child record  and have a the field active checkbox  in master record  and its refer in child record using  formula field .  when i change  the active to inactive in master record i got below error and i have given below the code too. i am not getting this error whennumber of child is less . any suggestion pls. The child target has 2000+ records only

User-added image

trigger 
trigger CyclePlanProcess on Cycle_Plan__c (after delete, after insert, after undelete,
after update, before delete, before insert, before update) {


  CyclePlanProcessHandler handler = new ReckittCyclePlanProcessHandler();
  handler.initialize(trigger.old, trigger.new, trigger.oldMap, trigger.newMap);

  if(Trigger.isInsert && Trigger.isBefore){
    handler.onBeforeInsert();

  } else if(Trigger.isInsert && Trigger.isAfter){
    handler.onAfterInsert();

  } else if(Trigger.isUpdate && Trigger.isBefore){
    handler.onBeforeUpdate();

  } else if(Trigger.isUpdate && Trigger.isAfter){
    handler.onAfterUpdate();

  } else if(Trigger.isDelete && Trigger.isBefore){
    handler.onBeforeDelete();

  } else if(Trigger.isDelete && Trigger.isAfter){
    handler.onAfterDelete();

  }
}


apex code
public with sharing virtual class CyclePlanProcessHandler {

    protected Cycle_Plan__c[] newPlans;
    protected Cycle_Plan__c[] oldPlans;
    protected Map<ID, Cycle_Plan__c> newMap;
    protected Map<ID, Cycle_Plan__c> oldMap;

    protected Set<String> recordTypeNames;

    private static RecordType[] rtList;
    protected Map<Id, RecordType> rtMap;
    

    public CyclePlanProcessHandler(){

    }

    public void initialize(Cycle_Plan__c[] oldPlans, Cycle_Plan__c[] newPlans, Map<ID, Cycle_Plan__c> oldMap, Map<ID, Cycle_Plan__c> newMap) {
        this.newPlans = newPlans;
        this.oldPlans = oldPlans;
        this.newMap = newMap;
        this.oldMap = oldMap;

    }

    public virtual void onBeforeInsert(){

    }

    public virtual void onAfterInsert(){
    
    }

    public virtual void onBeforeUpdate(){

    }

    public virtual void onAfterUpdate(){
    
    }


    public virtual void onBeforeDelete(){

    }

    public virtual void onAfterDelete(){

    }

    public RecordType[] getRtList() {
      if (rtList == null) {
        rtList = [select id, Name, DeveloperName from RecordType where SObjectType = 'Cycle_Plan__c'];
      }

      return rtList;
    }     
  

    public Map<Id, RecordType> getRtMap() {
      if (rtMap == null) {
        rtMap = new Map<Id, RecordType>();
        for (RecordType item : getRtList()) {
          if (getRecordTypeNames().contains(item.DeveloperName)) {
            rtMap.put(item.id, item);
          }
        }
      }

      return rtMap;
    }

    protected virtual Set<String> getRecordTypeNames() {  
        return new Set<String>();
    }
}



-ReckittCyclePlanProcessHandler 


public with sharing class ReckittCyclePlanProcessHandler extends CyclePlanProcessHandler{
  
  public ReckittCyclePlanProcessHandler() {
    
  }

  public override void onAfterInsert() {
    checkDouplicateActiveCycle();
  }

  public override void onAfterUpdate() {
    checkDouplicateActiveCycle();

    validateChildTargets();
  }

  private void validateChildTargets() {
    Set<Id> cycleIds = new Set<Id>();
    for (Cycle_Plan__c item : newPlans) {
      if (!getRtMap().containsKey(item.RecordTypeId)) continue;      
      if (oldMap != null && oldMap.get(item.Id).Active__c == item.Active__c) continue;

      cycleIds.add(item.Id);
    }

    Cycle_Plan_Target__c[] targets = [select id from Cycle_Plan_Target__c where Cycle_Plan__c in :cycleIds];

    if (!targets.isEmpty()) {
      update targets;
    }

  }

  public void checkDouplicateActiveCycle() {
      Map<Id,Id> ownerMap = new Map<Id,Id>();
      for (Cycle_Plan__c item : newPlans) {
        if (!getRtMap().containsKey(item.RecordTypeId)) continue;
          if (!item.Active__c) continue;

          if (oldMap != null 
              && item.Active__c == oldMap.get(item.Id).Active__c
              && item.OwnerId == oldMap.get(item.Id).OwnerId) continue;

          if (!ownerMap.containsKey(item.OwnerId)) {
             ownerMap.put(item.OwnerId, item.Id);
          } else {
             item.addError('Found duplicate active cycle for some users.');
          }
    
      }

      Cycle_Plan__c[] existPlans = [select id, OwnerId from Cycle_Plan__c where OwnerId in :ownerMap.keyset() and Active__c = true];
      for (Cycle_Plan__c item : existPlans) {
          if (ownerMap.get(item.OwnerId) != item.Id) {
             if (newMap.containsKey(ownerMap.get(item.OwnerId))) {
                newMap.get(ownerMap.get(item.OwnerId)).addError('Found duplicate active cycle for some users.');
             }
          }
      }
    }


    public override Set<String> getRecordTypeNames() {
        /*
            Get the list of target Record Types for Reckitt
        */
        if (recordTypeNames == null) {
          recordTypeNames = new Set<String>();
          
          IME_Custom_Settings__c settings = IME_Custom_Settings__c.getInstance('IME');
          if (settings != null && String.isNotEmpty(settings.ReckittCyclePlanProcessHandler_RT__c)) { 
              recordTypeNames.addAll(settings.ReckittCyclePlanProcessHandler_RT__c.split('\\s*;\\s*'));
          }

          system.debug(recordTypeNames);          
        }


        return recordTypeNames;
    }     
}
SOQL does not support the UNION operator. I have two custom objects that I need to query and UNION the results.
Has anyone encountered the same issue? If so, what was the workaround?

Thanks
Neema
 
So I have tried and tried...everything from the process builder to being on the phone with SF support. Nothing has worked, but yet I need to figure something out.

I want to set up a trigger that does the following:

On an Account, say Company XYZ, we have a field called Type. If we set that to Ex-Customer I would like to have every contact that has portal access under that Account to have their portal access deactivated or in general their SF profile frozen/deactivated. Whatever functionality is easier, it doesnt matter to me. I cannot seem to make this happen! This would help us immensely! 

This is the trigger I have so far...

for(User u : [Select u.Id, u.IsActive, u.IsPortalEnabled from User u where u.ContactId in :cIds]){ if(u.IsActive || u.IsPortalEnabled ){ u.IsActive = false; u.IsPortalEnabled = false; usersToUpdate.add(u); } }

Please let me know what else I need to add in order to make the Ex-Customer connection and the deactivation of the user/profile/portal.

Thank you
Hello Experts,

I need help with this code to show only the words in the parent case description in the child case. At the moment the child case description lists all the keywords.
trigger CheckSecretInfo on Case (after insert, before update) {

	String childCaseSubject = 'Warning: Parent case may contain secret info';

	// Step 1: Create a collection containing each of our secret keywords
	Set<String> secretKeywords = new Set<String>();
	secretKeywords.add('Credit Card');
	secretKeywords.add('Social Security');
	secretKeywords.add('SSN');
	secretKeywords.add('Passport');
	secretKeywords.add('Bodyweight');


List<Case> casesWithSecretInfo = new List<Case>();
Set<String> KeyWords = new Set<String>();
for (Case myCase : Trigger.new){
if(myCase.Subject != childCaseSubject){

// Step 2 Loop through secretkeywords and add all offending words to a Set

for(String KeyWord: secretKeywords){
if(myCase.Description != null && myCase.Description.containsIgnoreCase(KeyWord)){
	secretKeywords.add(KeyWord);
    break;
    system.debug('Keywords are: ' + keyword);
}
}

system.debug('cases to create' + casesWithSecretInfo.size());
	//Loop through secretkeywords and if there is any secret keywords add case to be created

List<Case> casesToCreate = new List<Case>();
for(Case caseWithSecretInfo : casesWithSecretInfo){
    Case childCase = new Case();
    childCase.Subject = 'Warning: Parent case may contain secret info';
    childCase.ParentId = caseWithSecretInfo.Id;
    childCase.IsEscalated = true;
    childCase.Priority = 'High';
    childCase.Description = 'The following secret keywords were found: ' + KeyWords;
    casesToCreate.add(childCase);
}
    insert casesToCreate;
}
}

}
Thanks