• James Allen 4
  • 5 Points
  • Member since 2014

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
  • 4
I am working on a VisualForce email template with a component and controller.  I have it pulling a list of records from a custom object based on the Id of the related template record. However I need to add another parameter to the where clause based on another value from the record. I think I have it coded correctly but my query is not returning the expected results.

Is there a way to see a debug log of the controller when an email is sent?  

Can you see any reason using the :cohortType variable in my SOQL where clause would not evaluate correctly to the value passed in from the template?

Section from Template
            <b>Study Island PLC Cohort Series Schedule and Registration Links:</b>
            <table border="1" width="600" >
            <tr><th>Cohort Description</th><th>Select Cohort</th></tr>
                    <c:CohortRegisterComponent Cohort_Type="{!RelatedTo.Program__c}" Task_Id="{!RelatedTo.Id}" />

<apex:component controller="CohortRegisterController" access="global">
    <apex:attribute name="Task_Id" type="String" description="Task ID" assignTo="{!taskId}"  />
    <apex:attribute name="Cohort_Type" type="String" description="Cohort Type" assignTo="{!cohortType}"  />
    <apex:outputText value="{!taskId}"></apex:outputText><br/>
    <apex:outputText value="{!cohortType}"></apex:outputText><br/>
    <apex:repeat value="{!ScheduledCohorts}" var="s_cohorts" id="scheduledCohorts">
            <td width="70%">
                <apex:outputText value="{!s_cohorts.Session_Name__c}"></apex:outputText><br/>
            <td align="center" width="30%"><apex:outputLink value="{!s_cohorts.Session_URL__c}&accountId={!TaskAcct}&objectId={!taskId}">Register Here</apex:outputLink> </td>

public class CohortRegisterController {
    private List<Cohort__c> cohortsList;
    private List<TASKRAY__Project_Task__c> taskList;
    public TASKRAY__Project_Task__c taskObj {get; set;}
    public String taskId {get; set;}
    public String cohortType {get; set;}
    private Boolean showLines {get; set;}
    public CohortRegisterController() {
        System.debug('cohortType ' + cohortType);
        cohortsList = ([SELECT Id, Name, Display_Name__c, Session_Name__c, Start_Date__c, End_Date__c, Type__c, Status__c, Session_URL__c
                        FROM Cohort__c
                        WHERE Status__c in ('New', 'Scheduled') and Type__c = :cohortType 
                        ORDER BY Start_Date__c]);
    public String getTaskAcct(){
        System.debug('taskId ' + taskId);
        taskList = [Select Id, Name, Contact__c, TASKRAY__trAccount__c from TASKRAY__Project_Task__c Where Id = :taskId];
        System.debug('taskList ' + taskList);
        taskObj = taskList[0];
        String taskAcct = taskObj.TASKRAY__trAccount__c;
         System.debug('taskObj ' + taskObj);
        return taskAcct;
    public String getdotw(DateTime dateTimeVar){
        DateTime dt = DateTime.newInstance(dateTimeVar.date(), dateTimeVar.time());
        String dayOfTheWeek = dt.format('EEEE');
        return dayOfTheWeek;
    public Boolean getshowLines() {
        if(!cohortsList.isEmpty()) showLines = true;
        return showLines;
    public List<Cohort__c> getScheduledCohorts() {
        //List<Cohort__c> cohortsList;
        System.debug('cohortsList ' + cohortsList);
        return cohortsList;
I have implemented the multiselect JQuery tool on a visualforce page to select users from a list.  I am now expanding the functionality to include more users using the OptGroup feature and I would like to pre-select user belonging to the default group.

However when building the standard <select multiple="multiple" > list I can't find a way to only select certain <option>.  It appears that the Jquery conversion to the checkbox UI only looks for selected.  So no matter if you add selected="true" or selected="false" it still checks all the check boxes.

I am trying to find a way to either manipulate the <select> or use Jquery/javascript to update the control to pre-select certain options.

Here is my VF code.  I can include the Multiselect script as well if that helps.  

                   <select id="selectCoaches" style="display:none" multiple="multiple" >  
                      <apex:repeat value="{!GroupNames}" var="group">  
                            <optgroup label="{!group[0]}">
                             <option value="{!group[1]}" selected="{!group[2]}">{!group[1]} </option>  

If I set selected="" it does not check the box but I can't conditionaly set it to a blank value. 

I have read posts about using .val() to set it via JQuery but my javascript skills are still developing and I am not sure where or how I would set it based on values coming from the controller. 

Thanks for any help!
I have been working on a use case to create a "queue assign" button that will assign the oldest order to the user pressing the button.  I have the basic flow working but I have been working on using a VF page to call the flow and redirect the user to the order that was assigned.

Using some great examples like http://techman97.wordpress.com/2013/10/18/flow-and-finishlocation/#comment-512 and others I have tried to create a custom controller to return the selected id and set the finish location to that order.

I finaly realized that this does work if I set a final screen to my flow.  But I get a Invalid Page Redirection error if I try to run as a trigger ready (headless) flow.  I do not need a screen in this case and would like to just push the button and redirect to the assigned order.

Anyone working on the trigger flow pilot come accross this problem and find a solution?

The ID does get returned to the page if I just display it on the screen but I guess without a flow screen the Id is not available when finishlocation is set.
I am having this error:
FATAL_ERROR System.LimitException: SBQQ:Too many queueable jobs added to the queue: 2
when I deploy the automation of the Renewal process (I have tried  with batch size = 1,batch size = 50 and batch size = 200 nothing works ) in production (works in Sandbox), even though I have followed this article and almost have copied the batch apex class that appears in this Knowledge article: https://help.salesforce.com/articleView?id=000267468&language=en_US&type=1 .

Below is my batch apex class.The main difference to the one in the Knowledge article mentioned before is the Query at the 'start()' method, see below:
///***Batch Apex Class***

global class Renewal implements Database.Batchable<SObject>, Database.Stateful {
	global Integer recordsProcessed = 0;

	global Database.QueryLocator start(Database.BatchableContext bc){
		return Database.getQueryLocator(
			//This is where you input the conditions for the records which you wish to set renewal for 
			'SELECT SBQQ__RenewalForecast__c, Id FROM Contract WHERE SBQQ__RenewalForecast__c = false AND EndDate=NEXT_N_QUARTERS:2');
	global void execute(Database.BatchableContext bc, List<Contract> scope){
		for(Contract contract: scope){    
            System.debug('<DEBUG> Update Renewal Forecast and Quoted for Contract: '+ contract.Id);
			contract.SBQQ__RenewalForecast__c = true;
			recordsProcessed = recordsProcessed + 1;

        update scope;
	global void finish(Database.BatchableContext bc){
       // Get the ID of the AsyncApexJob representing this batch job
       // from Database.BatchableContext.
       // Query the AsyncApexJob object to retrieve the current job's information.
       AsyncApexJob a = [SELECT Id, Status, NumberOfErrors, JobItemsProcessed,TotalJobItems, CreatedBy.Email FROM AsyncApexJob WHERE Id =:BC.getJobId()];

       // OPTIONAL: Send an email to the Apex job's submitter notifying of job completion.
       Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
       String[] toAddresses = new String[] {a.CreatedBy.Email};
       mail.setSubject('Contract Renewal Batch ' + a.Status);
       ('The batch Apex job processed ' + a.TotalJobItems +
       ' batches with '+ a.NumberOfErrors + ' failures.');
       Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
This is the test class for this batch apex class, although I don't think it has any relation to the problem:
public class RenewalTest {
    public static testMethod void testRenewal() {
        // Create an Account
        Account ac = new Account();
        ac.Name = 'Jamones Corporation Number';
        ac.Type = 'Manufacturer';
        ac.Industry = 'Food';
        ac.Tiering__c = 'Tier-1';
        ac.Language__c = 'Spanish';
        insert ac;
        // Create an Opportunity
        Opportunity op = new Opportunity();
        op.Name= 'OriginalOpNumber';
        op.AccountId = ac.Id;
        op.Type = 'New business';
        op.StageName = 'A - Interest';
        op.CloseDate = Date.today();
        insert op;
        // Create the Contract
        Contract c = new Contract();
        c.StartDate = Date.today().addMonths(-8);
        c.ContractTerm = 12;
        //c.EndDate = c.StartDate.addMonths(c.ContractTerm);
        c.Status = 'draft';
        c.AccountId = ac.Id;        
        c.SBQQ__Opportunity__c = op.Id;
        c.SBQQ__RenewalForecast__c = false;
        //c.SBQQ__RenewalQuoted__c = false;
        insert c;
       	System.debug('<DEBUG> Contract Id:'+ String.valueOf(c.Id));
        System.debug('<DEBUG> Date of today:'+ String.valueOf(Date.today()));
        System.debug('<DEBUG> Contract Start Date:'+ String.valueOf(c.StartDate));
        System.debug('<DEBUG> Contract End Date:'+ String.valueOf(c.EndDate));
        System.debug('<DEBUG> Contract Renewal Forecast:'+ String.valueOf(c.SBQQ__RenewalForecast__c));
        //System.debug('<DEBUG> Contract Renewal Quoted:'+ String.valueOf(c.SBQQ__RenewalQuoted__c));

        Renewal obj = new Renewal();
        Contract contract = [SELECT SBQQ__RenewalForecast__c FROM Contract WHERE Id= :c.Id];
        System.assertEquals(true, contract.SBQQ__RenewalForecast__c );
        //System.assertEquals(true, contract.SBQQ__RenewalQuoted__c ); 
    	System.debug('<DEBUG> Contract Renewal Forcast:'+ contract.SBQQ__RenewalForecast__c);
        //System.debug('<DEBUG> Contract Renewal Forcast:'+ contract.SBQQ__RenewalQuoted__c );

I am pretty new to salesforce but after analizing the logs the only thing that is bothering me is that there are some triggers in the Opportunity that seem to be called very frequently, and I have a suspicion they might me not 'bulkified'? However the trigger i am talking about is part of the Salesforce package 'Declarative Rollup Summary' and therefore I cannot see this part of code, so I have no idea how the triggers of this package work. See screenshots below:
User-added image
User-added image

Can anyone tell me if the fact that these triggers are called constantly is normal or not? And more importnaly, does anyone have any idea of what could be happening?

I can post more information if neeeded. 
Thanks in advance!!
I have a collection in a visualworkflow that is failing on the first decision element within the flow. I'm getting the following error:

FLOW_ELEMENT_ERROR|The flow failed to access the value for Item.Product_Family_Getter__c because it hasn't been set or assigned.

However, I am definitely setting the field and can see that the flow has it at an earlier point in the debug log:

Building the collection of Opportunity Line Items:
17:27:27.411 (411151510)|FLOW_VALUE_ASSIGNMENT|9831cff0c4b4f94bdd20336c790e146f2a7e2ab-19d3|getDealItems|true
17:27:27.411 (411228209)|FLOW_VALUE_ASSIGNMENT|9831cff0c4b4f94bdd20336c790e146f2a7e2ab-19d3|OpportunityLineItems|[{Name=Crest-ONE Comm- White Teeth ONE Connect, CurrencyIsoCode=USD, Id=00kg0000004G4MeAAK, License__c=Subscription, Product_Family_Getter__c=ONE Connect}]
17:27:27.411 (411251830)|FLOW_BULK_ELEMENT_DETAIL|FlowRecordLookup|getDealItems|1
Iterating through the collection
It can be seen that the Item definitely has the field "Product_Family_Getter__c" assigned
17:27:27.411 (411944263)|FLOW_ELEMENT_BEGIN|9831cff0c4b4f94bdd20336c790e146f2a7e2ab-19d3|FlowLoop|Loop_through_Line_Items
17:27:27.412 (412846666)|FLOW_VALUE_ASSIGNMENT|9831cff0c4b4f94bdd20336c790e146f2a7e2ab-19d3|Item|{Name=Crest-ONE Comm- White Teeth ONE Connect, CurrencyIsoCode=USD, Id=00kg0000004G4MeAAK, License__c=Subscription, Product_Family_Getter__c=ONE Connect}
17:27:27.412 (412858987)|FLOW_VALUE_ASSIGNMENT|9831cff0c4b4f94bdd20336c790e146f2a7e2ab-19d3|Loop_through_Line_Items.currentIteration|0

However, I still get this error:
17:27:27.413 (413041600)|FLOW_ELEMENT_BEGIN|9831cff0c4b4f94bdd20336c790e146f2a7e2ab-19d3|FlowDecision|Is_this_a_NOW_Item
17:27:27.414 (414510540)|FLOW_ELEMENT_END|9831cff0c4b4f94bdd20336c790e146f2a7e2ab-19d3|FlowDecision|Is_this_a_NOW_Item
17:27:27.421 (421733197)|FLOW_ELEMENT_ERROR|The flow failed to access the value for Item.Product_Family_Getter__c because it hasn't been set or assigned.||

What else should I be doing? I attach a quick picture of the section of the flow that's failing:
User-added image

I am part of the flow trigger pilot.

I have a custom object that tracks parts on a bill of materials (product parts). I have another object that tracks a simple production forecast for the products (MRP Forecast) - I have built a flow trigger that evaluates the MRP forecast and creates individual requirements records on a 3rd custom object that is Master Detail to the forecast object for each product on the bill of materials for the product specified in the forecast. (Bills of Material can be anywhere from 1 to 200 part numbers)

It works perfectly if I add or edit a forecast in the native salesforce interface - but we have hundreds of products, and each product needs a separate forecast for each month - so I need to be able to upload my forecast records en mass.

I tried an upload of 30 forecast records and it failed on the record insert: "common.exception.ApiException: record limit reached. cannot submit more than 200 records into this call".

Is there anyway I can "bulkify" the flow so that it collects multiple requests and handles them more elegantly?