• Jos Vervoorn 2
  • NEWBIE
  • 20 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 12
    Questions
  • 15
    Replies
I'm running a scheduled batch but I like to clean up the rows from previous runs during the day. So from the schedule, I call the batch with the JobId as a string parameter. So far good. But then I need to select all rows not having the jobId__c with the same value (parameter) and it does not work. It affects all rows and not only the ones with the JobId having the same value as the parameter.
I wrote a fairly simple trigger on the ContentVersion object which ultimately would allow tracking opportunities without a signed contract. 

So a document is added or changed and the picklist value 'Signed Contract' is selected. This would flip the 'HasSignedQuote__c' bollean on true on the opportunity. 

However I noticed that the LinkedEntityId from the ContentDocumentLink is not always populated and I can't get my finger behind the root cause.
 
trigger ContentVersion_TRIGGER on ContentVersion (After insert, After update) {

      
    Public static Boolean SignedContract = false;

    System.debug(LoggingLevel.Info,'[ContentVersion_TRIGGER]. - TRIGGER ');
    

        Set<Id> contentDocumentIdSet = new Set<Id>();
        for(ContentVersion cv:trigger.new){

            if(cv.ContentDocumentId != null){
                contentDocumentIdSet.add(cv.ContentDocumentId);
                If(cv.File_Type__c == 'Signed Contract'){ //** Based on Content version picklist ...
                   System.debug(LoggingLevel.Info,'[ContentVersion_TRIGGER]. - Set SignedContract = true');   
                   SignedContract = true;
                }
            }
        }
        System.debug(LoggingLevel.Info,'[ContentVersion_TRIGGER].contentDocumentIdSet'+contentDocumentIdSet);   
        ContentDocumentLink cdl = [SELECT ContentDocumentId, LinkedEntityId FROM ContentDocumentLink WHERE ContentDocumentId IN:contentDocumentIdSet Limit 1];
        System.debug(LoggingLevel.Info,'[ContentVersion_TRIGGER].ContentDocumentLink  :'+cdl.LinkedEntityId);      
        List<Opportunity> OppList = [SELECT Id, HasSignedQuote__c FROM Opportunity where Id =:cdl.LinkedEntityId];  
        System.debug(LoggingLevel.Info,'[ContentVersion_TRIGGER].OppList.size() :'+OppList.size());  
        For (Opportunity Opp:OppList){
            If (SignedContract == true){
                System.debug(LoggingLevel.Info,'[ContentVersion_TRIGGER]. - Flag opportunity HasSignedQuote to true ...');   
                Opp.HasSignedQuote__c = true;
            }
        }
        Update OppList;
   
} //** end of Class

 
I'm using substring to extract valid user timezone picklist values using below code. It does match .. but I get to results.
String text= 'Australian Central Standard Time ((South Australia) Australia/Adelaide)';

String RegEx = '(\\w+[/]\\w+[/]?\\w+)||GMT';
Pattern regexPattern = Pattern.compile(regex);
Matcher mymatcher= regexPattern.matcher(text);
If (myMatcher.find()){
  system.debug(LoggingLevel.Info,'*** Match ' + myMatcher.group());
}
What I expect in the log is Australia/Adelaide. The RegEx seems ok ... https://regexr.com/43hi9
Seeking a way to update case field after milestone processing. We have tried several options like flow with process builder, apex trigger (with/without @Future annotation) but ... whatever we try .... case field is not updated.

To sketch the scenario:
On the case, we would like to have a field to contain the deadline for the active milestone. So when we complete the current milestone ... this custom field get's populated with the deadline.

Now we can do this whenever a field update on the case has been performed ... but it seems that milestone processing takes place after triggers and after process builder. I have seen some samples out there but  ... I'm having a hard time to get this working while it sounds so easy.

 - milestone is completed / case deadline is populated by next milestone

All help & support is much appreciated.
While performing validation on my Apex Trigger & helper class I run into the following error:

Static method cannot be referenced from a non static context: void OpportunityLineItemTriggerHandler.AutoScheduleLineItemsAfterUpdate(List<OpportunityLineItem>, Map<Id,OpportunityLineItem>)

Now in test sandbox ... I did not run into this error .. so I'm not sure why in production it fails ...
Trigger code:
OpportunityLineItemTriggerHandler updater = new OpportunityLineItemTriggerHandler();

Apex class code (first x lines ......)
Public void AutoScheduleLineItemsAfterInsert(List<OpportunityLineItem> NewOppLineItems)
  {
     System.debug('** * ** #20 AutoScheduleLineItemsAfterInsert');
     //** Get prepped by retrieving the base information needed for generating schedule
     Date currentDate;             
     Decimal NumberOfInstallments; //**Decimal numberPayments;
     Decimal paymentAmount;
     Decimal totalPaid;
     String ItemDescription;
      
     NumberOfInstallments = 1; //** Ensure default value for installments even when no value provided.
          
     //** Generate lists for bulkify on OpportunityItems etc. 
     set<id> oppid = new set<id>();
     List<Id> oppLineIdsList = new List<Id>();
     List<OpportunityLineItemSchedule> newScheduleObjects = new List<OpportunityLineItemSchedule>();
     
     //** Assign (new) added ID values to variables
     for (OpportunityLineItem ol : NewOppLineItems) {
          oppLineIdsList.add(ol.id);
          oppid.add(ol.opportunityid);
     }
     //** Create (parent) opportunity list so we have required into to retrieve account based product (pricebook) values.
     list<opportunity> opplist = [select id, AccountID,CurrencyIsoCode from opportunity where id in : oppid ];
     
    for (opportunity opp: opplist) {
         //** So we have all we need. Account, Opportunity currency and ProductID
         system.debug('** * ** #44 AccountID: '+opp.AccountID);
         system.debug('** * ** #45 Opportunity Currency: '+opp.CurrencyIsoCode);
           
         //** For every OpportunityLineItem record, add its associated pricebook entry
         //** to a set so there are no duplicates.
         Set<Id> pbeIds = new Set<Id>();             //** PriceBookEntryID
         for (OpportunityLineItem oli : NewOppLineItems) 
            //** pbeIds.add(oli.pricebookentryid);
            pbeIds.add(oli.id);
            //** For every OpportunityLineItem record, add its associated oppty
            //** to a set so there are no duplicates.
            Set<Id> opptyIds = new Set<Id>();
            for (OpportunityLineItem oli : NewOppLineItems) 
                 opptyIds.add(oli.OpportunityId);

Thanks in advance.
 
While creating a 'simple' Lightning QuickAction to update case date/time field I get this unexpected token case.
({
   StartTiming: function(component, event, helper) {
        console.log('save:1');
        var action = component.get("c.case");
        action.setParams({"case": case  });
   }
})
Some help to overcome this would be great. Now the controller is not finished but I need to overcome this issue first.

Many thanks on advance.
 
I'm working on a controller to list case related email.I'm struggling to get the SOQL query to limit results based on ParentID = case.id.

Without this everything works just fine.as a 'related' email list on the case page layout. What do I miss of what is wrong ?

The code of the controller:

public class CaseEmailListController {

    public CaseEmailListController(ApexPages.StandardController controller) {

    }

private ApexPages.StandardController stdCtrl {get; set;}
public List<Case> Cases {get; set;}

// Sorting on CreatedDate and ToAddress
private String sortOrder = 'CreatedDate';
public void sortByCreatedDate() {
    this.sortOrder = 'CreatedDate';
}  
public void sortByToAddress() {
    this.sortOrder = 'ToAddress';
}
    
public Case   ourCase {get; set;}
public List<EmailMessage> getCaseEmail() {

  List<EmailMessage> results = Database.query(
      'SELECT CreatedDate, FromAddress,HasAttachment,Id,ParentId,Subject,TextBody,ToAddress ' +
      'FROM EmailMessage ' + 'WHERE ParentID=:' + Case.ID +
      ' ORDER BY ' + sortOrder + ' ASC ' +
      'LIMIT 10'
    );

return results;
}
}
Hi guys, the quote template has lots of limitations when it comes to styling; I would like to do something custom and need a step-by-step guide. Basically, I would like a "create quote" button on quote pagelayout that references my visualforce page and creates the pdf. 

So I think I need to follow the steps below:
1. Create a custom controller class. Can I do this with standard List controller? Basically, I have to query all the quote and quotelineitems
2. Create a new visual force page using controller from step1, add the proper styling and render as pdf.
3. Create the button on quote with a link to visual force page
Any tips and guides are appreciated. 
Thanks.

Did I miss anything? 
 
I am trying to find a way to send emails from Salesforce1 and I think the only way might be to make a VF page of the Send Email page.  I need to be able to use email templates and preview it.