• Chris Secrist
  • NEWBIE
  • 0 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 10
    Replies
Please help, trying to finish a project and the latest request has stalled the project.  Trying to update the approval field in the credit request based on credit lines.  If a credit line has a certain qty or part, then the approval field should update to a check box.  Any support will be great.  New to salesforce and I believe a trigger is needed, any guidance or actual trigger will be wonderful.  A single request can have multiple credit lines.Image showing credit request and credit lines.
All,

Looking for some help.  New to apex and just need some help to finish this code off.  The product is located in a custom settings with qty and multiplier field.  Some fo the multiplier fields have no value.  Currently, have three issues.

1.  If multiplier field = 0, than I want the credit to be created withour credit lines.   Currently this does not happen.
2.  If there are no credit lines, and an update is made it fails because it is attempting to delete lines that do not exist.  Need the delete to optional based on if credit lines exist.

public class AddOrUpdateCreditLineTriggerHandler {
    Map<Id, List<Credit_lines__c>> mapCRToCL = new Map<id, List<credit_lines__c>>();
    map<id, Credit_Request__c> original;
    map<id,Credit_Request__c> modified;
    List<Credit_Lines__c> associatedCreditLines;
    List<Credit_lines__c> toDelete = new List<Credit_Lines__c>();
    List<Credit_lines__c> toInsert = new List<Credit_lines__c>();
   
    public AddOrUpdateCreditLineTriggerHandler(List<Credit_Request__c> original, List<Credit_Request__c> modified){
        if(original != null) {
            this.original = New Map<Id, Credit_Request__C>(original);
        }
        this.modified = New Map<Id, Credit_Request__c>(modified);
        associatedCreditLines =
         [SELECT id, Product__C, Name, credit_request__c
          FROM Credit_Lines__C
          WHERE Credit_request__c in :modified ];
     for(Credit_lines__c cl: associatedCreditLines) {
            if(mapCRToCL.containsKey(cl.credit_request__c)){
                mapCRToCL.get(cl.credit_request__c).add(cl);
            } else {
                mapCRToCL.put(cl.credit_request__c, new List<Credit_Lines__c>{cl});
            }
     }
    }
   
    public void run(){
        if(Trigger.isInsert){
            afterInsert();
        } else if (Trigger.isUpdate){
            afterUpdate();
        }
    }
   
    private void afterInsert(){
        for(Credit_Request__c cr : this.modified.values() ){
            toInsert.addAll(createStandardCreditLines(cr));
        }
        insert toInsert;
    }
    
    private void afterUpdate(){
        for(Credit_Request__c cr : filterQtyChanged(this.modified.values())){
            toDelete.addAll(mapCRToCl.get(cr.id));
            toInsert.addAll(createStandardCreditLines(cr));
        }
       delete toDelete;
       insert toInsert;
    }
   
    private List<Credit_lines__c> createStandardCreditLines(Credit_Request__c cr){
        List<Credit_Lines__c> created = new List<Credit_Lines__c>();
        for(AutomatedCreditLineRecords__c a: creditLines()){
          
            if(a.multiplierField__c != null && cr.get(a.multiplierField__c) == null){
                continue;
            }
            Double multiplier = 1;
            if(a.multiplierField__c != null && cr.get(a.multiplierField__c) != null){
                multiplier = (Double) cr.get(a.multiplierField__c);
            }
            created.add(
             New Credit_lines__c(
                 Credit_Request__c = cr.Id,
                 Quantity__c = (a.Qty__c * multiplier),
              Product__c = a.productId__c
                )
            );
        }
        return created;
    }
   
    private List<AutomatedCreditLineRecords__c> CreditLines(){
        return AutomatedCreditLineRecords__c.getall().values();
    }  
           
    private List<Credit_Request__c> filterQtyChanged(List<Credit_Request__c> possible){
        List<Credit_request__c> toUpdate = new List<Credit_Request__c>();
        for(Credit_Request__c cr : this.modified.values()){
            if(QuantityChanged(this.original.get(cr.id), cr)){
                toUpdate.add(cr);
            }
        }
        return toUpdate;
    }
   

3.
All,

I have the following credit object and a credit line lookup.  In the credit line, I have a quantity field.  I would like for that field to be show in the credit object.  I tried a formulat but it did not show a value.  Any solution or how to would be beneficial.

 
I have an email template for case notifications.  When the case is updated with a comment or email, we are notified via email of the update.  This works, except if the new email on the case is part of a reply.  Such that there are multiple To and From subject lines.  When this occurs the email notification contains the info below.  Is there a way to prevent this from showing up.  I am looking at the email template and do not see what the root cause is.


/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Candara;
panose-1:2 14 5 2 3 3 3 2 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman";}



 
I am attempting to use the dhtmlx gantt chart in salesforce.  Currently I am trying to display all cases from all accounts that meet certain critieria.  Then I would like to use those cases and associated dates in a field to populate Gantt chart.  Looking for any assistance possible.  I cannot get a visualforce page to show any case information when I use a basic controller.

<apex:page standardController="Case" >
    <apex:form >
        <apex:pageBlock >  
            <apex:pageMessages />
            <apex:pageBlockButtons> 
                <apex:commandButton value="Save" action="{!save}"/>
            </apex:pageBlockButtons>
              <apex:PageBlockTable value="{!Case}" var="c">
                <apex:column value="{!c.Account}"/>
                  <apex:column value="{!c.Number}"/>
                <apex:column value="{!c.Owner}"/>
                <apex:column headerValue="Install Date">
                    <apex:inputField value="{!a.Planned_Install_Date__c}"/>
                </apex:column>
            </apex:PageBlockTable>
        </apex:pageBlock>
    </apex:form>
</apex:page>
Please help, trying to finish a project and the latest request has stalled the project.  Trying to update the approval field in the credit request based on credit lines.  If a credit line has a certain qty or part, then the approval field should update to a check box.  Any support will be great.  New to salesforce and I believe a trigger is needed, any guidance or actual trigger will be wonderful.  A single request can have multiple credit lines.Image showing credit request and credit lines.
I am attempting to use the dhtmlx gantt chart in salesforce.  Currently I am trying to display all cases from all accounts that meet certain critieria.  Then I would like to use those cases and associated dates in a field to populate Gantt chart.  Looking for any assistance possible.  I cannot get a visualforce page to show any case information when I use a basic controller.

<apex:page standardController="Case" >
    <apex:form >
        <apex:pageBlock >  
            <apex:pageMessages />
            <apex:pageBlockButtons> 
                <apex:commandButton value="Save" action="{!save}"/>
            </apex:pageBlockButtons>
              <apex:PageBlockTable value="{!Case}" var="c">
                <apex:column value="{!c.Account}"/>
                  <apex:column value="{!c.Number}"/>
                <apex:column value="{!c.Owner}"/>
                <apex:column headerValue="Install Date">
                    <apex:inputField value="{!a.Planned_Install_Date__c}"/>
                </apex:column>
            </apex:PageBlockTable>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Hi - 

 

I found this really cool gantt chart, but for some reason I'm having problem embedding it into my Visual Force page. The link of the gantt chart is the following:

 

http://dhtmlx.com/docs/products/dhtmlxGantt/index.shtml

 

I was wondering if anyone can help me figure out what's wrong with the below code? I'm not really getting any error message but the inspect element has "Uncaught TypeError: Cannot call method 'addEventListener' of null". 

 

 

<apex:page >

    <apex:stylesheet value="{!URLFOR($Resource.Timeline, 'codebase/dhtmlxgantt.css')}"/>
    <script type="text/javascript" language="JavaScript" src="{!URLFOR($Resource.Timeline, 'codebase/dhtmlxcommon.js')}"></script>
    <script type="text/javascript" language="JavaScript" src="{!URLFOR($Resource.Timeline, 'codebase/dhtmlxgantt.js')}"></script>


    <head>


    <script language="JavaScript" type="text/javascript">
        function createChartControl(htmlDiv1)
        {
            //project 1
            var project1 = new GanttProjectInfo(1, "Applet 11redesign", new Date(2010, 5, 11));
    
            var parentTask1 = new GanttTaskInfo(1, "Old code review", new Date(2010, 5, 11), 208, 50, "");
            parentTask1.addChildTask(new GanttTaskInfo(2, "Convert to J#", new Date(2010, 5, 11), 100, 40, ""));
            parentTask1.addChildTask(new GanttTaskInfo(13, "Add new functions", new Date(2010, 5, 12), 80, 90, ""));
    
            var parentTask2 = new GanttTaskInfo(3, "Hosted Control", new Date(2010, 6, 7), 190, 80, "1");
            var parentTask5 = new GanttTaskInfo(5, "J# interfaces", new Date(2010, 6, 14), 60, 70, "6");
            var parentTask123 = new GanttTaskInfo(123, "use GUIDs", new Date(2010, 6, 14), 60, 70, "");
            parentTask5.addChildTask(parentTask123);
            parentTask2.addChildTask(parentTask5);
            parentTask2.addChildTask(new GanttTaskInfo(6, "Task D", new Date(2010, 6, 10), 30, 80, "14"));
    
            var parentTask4 = new GanttTaskInfo(7, "Unit testing", new Date(2010, 6, 15), 118, 80, "6");
            var parentTask8 = new GanttTaskInfo(8, "core (com)", new Date(2010, 6, 15), 100, 10, "");
            parentTask8.addChildTask(new GanttTaskInfo(55555, "validate uids", new Date(2010, 6, 20), 60, 10, ""));
            parentTask4.addChildTask(parentTask8);
            parentTask4.addChildTask(new GanttTaskInfo(9, "Stress test", new Date(2010, 6, 15), 80, 50, ""));
            parentTask4.addChildTask(new GanttTaskInfo(10, "User interfaces", new Date(2010, 6, 16), 80, 10, ""));
            parentTask2.addChildTask(parentTask4);
    
            parentTask2.addChildTask(new GanttTaskInfo(11, "Testing, QA", new Date(2010, 6, 21), 60, 100, "6"));
            parentTask2.addChildTask(new GanttTaskInfo(12, "Task B (Jim)", new Date(2010, 6, 8), 110, 1, "14"));
            parentTask2.addChildTask(new GanttTaskInfo(14, "Task A", new Date(2010, 6, 7), 8, 10, ""));
            parentTask2.addChildTask(new GanttTaskInfo(15, "Task C", new Date(2010, 6, 9), 110, 90, "14"));
    
            project1.addTask(parentTask1);
            project1.addTask(parentTask2);
    
            //project 2
            var project2 = new GanttProjectInfo(2, "Web Design", new Date(2010, 5, 17));
    
            var parentTask22 = new GanttTaskInfo(62, "Fill HTML pages", new Date(2010, 5, 17), 157, 50, "");
            parentTask22.addChildTask(new GanttTaskInfo(63, "Cut images", new Date(2010, 5, 22), 78, 40, ""));
            parentTask22.addChildTask(new GanttTaskInfo(64, "Manage CSS", null, 90, 90, ""));
            project2.addTask(parentTask22);
    
            var parentTask70 = new GanttTaskInfo(70, "PHP coding", new Date(2010, 5, 18), 120, 10, "");
            parentTask70.addChildTask(new GanttTaskInfo(71, "Purchase D control", new Date(2010, 5, 18), 50, 0, ""));
            project2.addTask(parentTask70);
    
            var ganttChartControl = new GanttChart();
            ganttChartControl.setImagePath("{!URLFOR($Resource.Timeline, 'codebase/imgs/')}");
            
            ganttChartControl.setEditable(true);
            
            ganttChartControl.addProject(project1);
            
            ganttChartControl.create(htmlDiv1);
        }
    </script>
    
    <style>
        body {font-size:12px}
        .{font-family:arial;font-size:12px}
        h1 {cursor:hand;font-size:16px;margin-left:10px;line-height:10px}
        xmp {color:green;font-size:12px;margin:0px;font-family:courier;background-color:#e6e6fa;padding:2px}
        .hdr{
            background-color:lightgrey;
            margin-bottom:10px;
            padding-left:10px;
        }
    </style>

    </head>

    <body onload="createChartControl('GanttDiv');">
        <div style="width:950px;height:620px;position:absolute;" id="GanttDiv"></div>
    </body>



</apex:page>