• Arshadulla.Shariff
  • NEWBIE
  • 185 Points
  • Member since 2016
  • Developer
  • IBM

  • Chatter
    Feed
  • 6
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 41
    Replies
HI,
I'm trying to use the following code to add and delete records from a mileage report object.  Everything is working great, except if the user hits the add row button ("add expense") and then changes his mind and hits "delete" button, the row won't delete until user puts values in the required field of the row he's trying to delete.  Is there a way to simply cancel adding the row?  I'm just getting started with VF/Apex and trying to make the code work.  Any help is appreciated.  
<apex:page standardController="Expense_Report__c" extensions="addMileageExpense" sidebar="false">
 <table>
    <colgroup>
            <col span="2" /><col />
  	</colgroup>
  <tr>
    <td><h2>
        Expense Report Name:</h2></td>
      <td> <apex:outputField value="{! Expense_Report__c.Name__c }"/></td>  
  </tr>
  <tr></tr>
  <tr>
      <td><h2>
          
          Start Date:</h2> </td>
      <td><apex:outputField value="{! Expense_Report__c.Start_Date__c}"/></td>
  </tr>

    <br/>
    <br/>
            <td><h2>
          Expense Report:</h2> </td>
      
     <td><apex:outputField value="{!Expense_Report__c.id}"/>	</td>
</table>
        <br/>
    <br/>
    <apex:form >

 		<apex:pageBlock title="Mileage Report" id="er">
 		
            <apex:pageMessages />
 		<apex:variable var="rowNumber" value="{!0}"/>
               <apex:pageblockSection columns="1" id ="mytable">
                   <apex:actionSupport event="onchange" reRender="mytable"/>   
 				<apex:pageBlockTable title="Mileage Expenses" var="me" value="{!expenseList}"> 

 					<apex:column headerValue="Entry" style="width:20px; text-align:center;" headerClass="centertext">
 						<apex:outputText value="{0}" style="text-align:center;"> 
 							<apex:param value="{!rowNumber+1}" /> 
 						</apex:outputText>
					</apex:column> 
 					
                    <apex:column headerValue="Date of trip" >
                       <apex:inputField value="{!me.Date__c}"  required="true"/>
 					</apex:column>
                    
                    <apex:column headerValue="Purpose and Description" >
                       <apex:inputField value="{!me.Name}" id="name" required="true"/>
 					</apex:column> 
 


                    <apex:column headerValue="{! Expense_Report__c.Program_1_Number__c}" 
                                 style="width:50px" footerValue="{! Expense_Report__c.Program_1_Number__c}" 
                                 rendered = "{! If(Expense_Report__c.Program_1_Number__c== null ,false,true) }">
                        <apex:inputField value="{!me.Prgm_1_Miles__c}" style="width:50px" ></apex:inputField>
                     </apex:column>
                        
                        <apex:column headerValue="{! Expense_Report__c.Program_2_Number__c}" 
                                     style="width:50px" footerValue="{! Expense_Report__c.Program_2_Number__c}" 
                                     rendered = "{! If(Expense_Report__c.Program_2_Number__c== null ,false,true) }">
                            <apex:inputField value="{!me.Prgm_2_Miles__c}"  style="width:50px"  ></apex:inputField>
 					    </apex:column> 
                            
                      <apex:column headerValue="{! Expense_Report__c.Program_3_Number__c}" 
                                   style="width:50px" footerValue="{! Expense_Report__c.Program_3_Number__c}" 
                                   rendered = "{! If(Expense_Report__c.Program_3_Number__c== null ,false,true)}">
                          <apex:inputField value="{!me.Prgm_3_Miles__c}"  style="width:50px"  ></apex:inputField>
 					</apex:column> 
                          
                        <apex:column headerValue="{! Expense_Report__c.Program_4_Number__c}" 
                                     style="width:50px" footerValue="{! Expense_Report__c.Program_4_Number__c}" 
                                     rendered = "{! If(Expense_Report__c.Program_4_Number__c== null ,false,true) }">
                            <apex:inputField value="{!me.Prgm_4_Miles__c}"  style="width:50px"  ></apex:inputField>
 					</apex:column> 
                            
                            <apex:column headerValue="{! Expense_Report__c.Program_5_Number__c}" 
                                         style="width:50px" footerValue="{! Expense_Report__c.Program_5_Number__c}" 
                                         rendered = "{! If(Expense_Report__c.Program_5_Number__c== null ,false,true) }">
                                <apex:inputField value="{!me.Prgm_5_Miles__c}"  style="width:50px"  ></apex:inputField>
 					</apex:column> 
                        
                      <apex:column headerValue="{! Expense_Report__c.Program_6_Number__c}" 
                                   footerValue="{! Expense_Report__c.Program_6_Number__c}" style="width:50px" 
                                   rendered = "{! If(Expense_Report__c.Program_6_Number__c== null ,false,true) }">
                          <apex:inputField value="{!me.Prgm_6_Miles__c}"  style="width:50px"  ></apex:inputField>
 					</apex:column> 
                
                    <apex:column headerValue="Total Miles" footerValue= "Total Miles" style="width:50px">
                        <apex:inputField value="{!me.Total_Miles__c}"  style="width:50px"  ></apex:inputField>
 					</apex:column> 
                          
                             
                    <apex:column headerValue="Action" >
                         <apex:commandButton value="Delete" action="{!deleteRow}" reRender="er">
 						<apex:param name="rowIndex" value="{!rowNumber}"/>
                      </apex:commandButton>
                         <apex:variable var="rowNumber" value="{!rowNumber+1}"/>
                        </apex:column> 

                 </apex:pageBlockTable>
                                    
               <apex:commandButton action="{!addRow}" value="Add Expense" reRender="er"/>
 	           </apex:pageblockSection>
                              
 			<apex:pageBlockButtons >
 		                <apex:commandButton value="Save" action="{!ave}" />
 		         <apex:commandButton value="Cancel" action="{!cancel}"/>
 			</apex:pageBlockButtons>
 		</apex:pageBlock>

       
 		
 	</apex:form> 
 </apex:page>

And here's the controller: 
 
public class addMileageExpense {
public Expense_Report__c reports;
 public Mileage_expense__c del;
 public List<Mileage_expense__c> addexpenseList {get;set;}
 public List<Mileage_expense__c> delexpenseList {get;set;}
 public List<Mileage_expense__c> expenseList {get;set;}
 public Integer totalCount {get;set;}
 public Integer rowIndex {get;set;}
 public List<Mileage_expense__c> delexpense {get; set;} 
 public addMileageExpense(ApexPages.StandardController controller) {
 
 reports = (Expense_Report__c)controller.getRecord();
 expenseList = [Select id, Name, Expense_Report__c, Miles__c, Total_Miles__c,   
                Date__c, Prgm_1_Miles__c, Prgm_2_Miles__c, Prgm_3_Miles__c, Prgm_4_Miles__c, 
                Prgm_5_Miles__c, Prgm_6_Miles__c from Mileage_expense__c where Expense_Report__c =: reports.ID];
 totalCount = expenseList.size();
 
 delexpenseList = new List<Mileage_expense__c>();
 delexpense = new List<Mileage_expense__c>();
 }
 
 public void addRow(){
 addexpenseList = new List<Mileage_expense__c>();
 expenseList.add(new Mileage_expense__c(Expense_Report__c = reports.Id));
 }
 
 public PageReference ave(){
 
 upsert expenseList;
 delete delexpenseList;
 return (new ApexPages.StandardController(reports)).view();
 } 
 
 public void deleteRow(){
 
 rowIndex = Integer.valueOf(ApexPages.currentPage().getParameters().get('rowIndex'));
 System.debug('row to be deleted ' + rowIndex );
 System.debug('row to be deleted '+ expenseList[rowIndex]);

     del = expenseList.remove(rowIndex);
 
         delexpenseList.add(del);
     
 }
 }


 
Hello,

I have written a test class for a fucntion.
I  wrote some debug logs in the function.

The debug logs are getting executed but the code coverage is non.

The logic between debug logs should have been executed as the system.debug got executed..
i wonded how to resolve this issue..
 
  • February 03, 2017
  • Like
  • 0
I have two custom fields on the Opportunity object, a text field and a lookup field.  The text field gets populated from an outside source and I want to populate the contents of text field  and have it display in the lookup field.

I need help to create a simple trigger for this on the Opportunity object.

**Opportunity object**
text field - Discount_Code__c 
lookup field - Discount_code_LU__c 

Basic logic would be "Discount_Code_LU__c = Discount_Code__c"

Hi 

I'm trying to set up a button on the opportunity page which opens a new case but preselects a particular record type for cases  ('UK Sales Engagement'). 

I have this but it's not working, any ideas where I'm going wrong ? 

/500/e?retURL=%2F500%2Fo 

&cas4_lkid={!Account.Id} 
&cas4={!Account.Name} 
&00Nw0000008rJRa_lkid={!Account.Id} 
&00Nw0000008rJRa={!Account.Messina_Short_Name__c} 
&CF00Nw0000008rJRp_lkid={!Opportunity.Id} 
&CF00Nw0000008rJRp={!Opportunity.Name} 
&00Nw0000008rJRB_lkid={!Opportunity.Id} 
&00Nw0000008rJRB={!Opportunity.ARV_Churn__c} 
&00Nw0000008rJRk_lkid={!Opportunity.Id} 
&00Nw0000008rJRk={!Opportunity.TCVP_New_del__c} 
&00Nw0000008rJS4_lkid={!Opportunity.Id} 
&00Nw0000008rJS4={!Opportunity.UK_TCVP_re_contract__c} 
&{!Case.RecordType}='UK Sales Engagement' 
&retURL=/{!Opportunity.Id} 
&saveURL=/{!Opportunity.Id}



Thanks very much 

Sarah 

I get the following error: accounthierarchy  unexpected token: ')'    my code looks like:
List<SObject> results = [SELECT ID FROM Account];
  Set<Id> resultIds = (new Map<Id, SObject>(results)).keySet();  
  Map<Set<Id>,results>  getquick = getHierarchies.getAccountHierarchiesQuick(Set<Id>result);
The class tha i am calling is named:  getHierarchies and looks like:
public static Map<Id,HierarchyNode> getAccountHierarchiesQuick(Set<Id> top_acct_ids) {
    Map<Id,HierarchyNode> nodes = new Map<Id,HierarchyNode>();
    Set<Id> parent_acc_ids = top_acct_ids;
Wat am i doing wrong?
 
I am creating a Page to add multiple contacts to an Account. The Page is Called by a Button Click on Account Detail Page.'
For now, Contacts are getting Created however, they are not getting Associated to Account.

VISUALFORCE PAGE ---------

<apex:page name="Create Multiple Contacts" controller="AddMultipleContacts" showHeader="true" sidebar="true">        
    <apex:form >    
    <apex:pageBlock title="Add Contacts">
        <apex:variable var="rowNum" value="{!0}"/>
        <apex:pageBlockTable value="{!ContactList}" var="con">
            <apex:facet name="footer">               
                <apex:commandButton value="Add" style="float: right;" action="{!insertRow}" />                    
             </apex:facet>
            <apex:column headerValue="First Name">
                <apex:inputField value="{!con.FirstName}"/>
            </apex:column>
            
            <apex:column headerValue="Last Name">
                <apex:inputField value="{!con.LastName}"/>
            </apex:column>
            <apex:column headerValue="Phone">
                <apex:inputField value="{!con.Phone}"/>
            </apex:column>
            <apex:column headerValue="Email">
                <apex:inputField value="{!con.Email}"/>                
            </apex:column>
            
             <apex:column headerValue="Action" >
                    <apex:commandLink style="font-size:12px; font-weight:bold; text-align:center;color:Black;" value="Delete" action="{!delRow}">
                    <apex:param value="{!rowNum}" name="index" />
                    </apex:commandLink> 
                    <apex:variable var="rowNum" value="{!rowNum+1}"/>
             </apex:column> 
         </apex:pageBlockTable>
            <apex:commandButton value="Cancel" onclick="window.history.previous()"/>
            
            <apex:pageBlockButtons location="bottom" >
                <apex:commandButton value="Save Contacts" action="{!insertContacts}"/>           
            </apex:pageBlockButtons>
    </apex:pageBlock>
    </apex:form>        
</apex:page>

CONTROLLER ---------

public class AddMultipleContacts {
    Id AcctID;
    public List<Contact> ContactList {get;set;}
    public Integer rowNum{get;set;}
    
    public AddMultipleContacts(){
        AcctID = ApexPages.currentPage().getParameters().get('AcctID');
        ContactList = new List<Contact>();  
        ContactList.add(new contact());        
    }        
    public void insertContacts(){
        insert ContactList;
    }                    
    public void insertRow(){
        ContactList.add(new contact()); 
    }    
    public void delRow(){
        rowNum = Integer.valueOf(apexpages.currentpage().getparameters().get('index'));
        ContactList.remove(rowNum);   
    }        
}

Hi ,
After spring 19 to test sandbox we are experincing the following issue in digital signature component.
Only for ipad and tablets device 

Uncaught TypeError: Reflect.defineProperty called on non-object
/*Component*/

<aura:component  implements="force:appHostable">
    
    <aura:handler name="render" value="{!this}" action="{!c.Init}"/>

    <div style="text-align: center;">
        <canvas aura:id="can" style="border:2px solid #ddd;background: transparent;"></canvas>
    </div>
    <div style="text-align: center;margin: 7px;">
        <button class="slds-button slds-button_brand" onclick="{!c.erase}">Clear</button>
        <button class="slds-button slds-button_brand" onclick="{!c.save}">Save</button>
    </div>
</aura:component>
/*Controller*/
({
    Init : function(component, event, helper) {
        helper.doInit(component, event, helper);
    },
    erase:function(component, event, helper){
        helper.eraseHelper(component, event, helper);
    },
    save:function(component, event, helper){
        helper.saveHelper(component, event, helper);
    },
})
/*helper*/
({
    doInit : function(component, event, helper) {
            var canvas, ctx, flag = false,
            prevX = 0,
            currX = 0,
            prevY = 0,
            currY = 0,
            dot_flag = false;
       
        var x = "black",
            y = 2,
            w,h;
        canvas=component.find('can').getElement();
        var ratio = Math.max(window.devicePixelRatio || 1, 1);
        w = canvas.width*ratio;
        h = canvas.height*ratio;
        ctx = canvas.getContext("2d");
        console.log('ctx:='+ctx);
       
        canvas.addEventListener("mousemove", function (e) {
            findxy('move', e)
        }, false);
        canvas.addEventListener("mousedown", function (e) {
            findxy('down', e)
        }, false);
        canvas.addEventListener("mouseup", function (e) {
            findxy('up', e)
        }, false);
        canvas.addEventListener("mouseout", function (e) {
            findxy('out', e)
        }, false);
        // Set up touch events for mobile, etc
        canvas.addEventListener("touchstart", function (e) {
            var touch = e.touches[0];
            var mouseEvent = new MouseEvent("mousedown", {
                clientX: touch.clientX,
                clientY: touch.clientY
            });
            canvas.dispatchEvent(mouseEvent);
             e.preventDefault();
        }, false);
        canvas.addEventListener("touchend", function (e) {
            var mouseEvent = new MouseEvent("mouseup", {});
            canvas.dispatchEvent(mouseEvent);
        }, false);
        canvas.addEventListener("touchmove", function (e) {
            var touch = e.touches[0];
            var mouseEvent = new MouseEvent("mousemove", {
                clientX: touch.clientX,
                clientY: touch.clientY
            });
            canvas.dispatchEvent(mouseEvent);
             e.preventDefault();
           
        }, false);
       
        // Get the position of a touch relative to the canvas
        function getTouchPos(canvasDom, touchEvent) {
            var rect = canvasDom.getBoundingClientRect();
            return {
                x: touchEvent.touches[0].clientX - rect.left,
                y: touchEvent.touches[0].clientY - rect.top
            };
        }
       
        function findxy(res, e){
            const rect = canvas.getBoundingClientRect();
            if (res == 'down') {
                prevX = currX;
                prevY = currY;
                currX = e.clientX - rect.left ;
                currY = e.clientY -  rect.top;
               
                flag = true;
                dot_flag = true;
                if (dot_flag) {
                    ctx.beginPath();
                    ctx.fillStyle = x;
                    ctx.fillRect(currX, currY, 2, 2);
                    ctx.closePath();
                    dot_flag = false;
                }
            }
            if (res == 'up' || res == "out") {
                flag = false;
            }
            if (res == 'move') {
                if (flag) {
                    prevX = currX;
                    prevY = currY;
                    currX = e.clientX -  rect.left;
                    currY = e.clientY - rect.top;
                    draw(component,ctx);
                }
            }
        }
        function draw() {
            ctx.beginPath();
            ctx.moveTo(prevX, prevY);
            ctx.lineTo(currX, currY);
            ctx.strokeStyle = x;
            ctx.lineWidth = y;
            ctx.stroke();
            ctx.closePath();
        }
       
    },
    eraseHelper: function(component, event, helper){
        var m = confirm("Want to clear");
        if (m) {
            var canvas=component.find('can').getElement();
            var ctx = canvas.getContext("2d");
            var w = canvas.width;
            var h = canvas.height;
            ctx.clearRect(0, 0, w, h);
       }
    },
    saveHelper:function(component, event, helper){
        var pad=component.find('can').getElement();
        var dataUrl = pad.toDataURL();
        console.log('dataUrl:='+dataUrl);
        var strDataURI=dataUrl.replace(/^data:image\/(png|jpg);base64,/, "");
        alert(strDataURI);
      
    }
})

Some findings the issue is on touch events 
Any help to resolve the above issue

Hi ,
After spring 19 to test sandbox we are experincing the following issue in digital signature component.
Only for ipad and tablets device 

Uncaught TypeError: Reflect.defineProperty called on non-object
/*Component*/

<aura:component  implements="force:appHostable">
    
    <aura:handler name="render" value="{!this}" action="{!c.Init}"/>

    <div style="text-align: center;">
        <canvas aura:id="can" style="border:2px solid #ddd;background: transparent;"></canvas>
    </div>
    <div style="text-align: center;margin: 7px;">
        <button class="slds-button slds-button_brand" onclick="{!c.erase}">Clear</button>
        <button class="slds-button slds-button_brand" onclick="{!c.save}">Save</button>
    </div>
</aura:component>
/*Controller*/
({
    Init : function(component, event, helper) {
        helper.doInit(component, event, helper);
    },
    erase:function(component, event, helper){
        helper.eraseHelper(component, event, helper);
    },
    save:function(component, event, helper){
        helper.saveHelper(component, event, helper);
    },
})
/*helper*/
({
    doInit : function(component, event, helper) {
            var canvas, ctx, flag = false,
            prevX = 0,
            currX = 0,
            prevY = 0,
            currY = 0,
            dot_flag = false;
       
        var x = "black",
            y = 2,
            w,h;
        canvas=component.find('can').getElement();
        var ratio = Math.max(window.devicePixelRatio || 1, 1);
        w = canvas.width*ratio;
        h = canvas.height*ratio;
        ctx = canvas.getContext("2d");
        console.log('ctx:='+ctx);
       
        canvas.addEventListener("mousemove", function (e) {
            findxy('move', e)
        }, false);
        canvas.addEventListener("mousedown", function (e) {
            findxy('down', e)
        }, false);
        canvas.addEventListener("mouseup", function (e) {
            findxy('up', e)
        }, false);
        canvas.addEventListener("mouseout", function (e) {
            findxy('out', e)
        }, false);
        // Set up touch events for mobile, etc
        canvas.addEventListener("touchstart", function (e) {
            var touch = e.touches[0];
            var mouseEvent = new MouseEvent("mousedown", {
                clientX: touch.clientX,
                clientY: touch.clientY
            });
            canvas.dispatchEvent(mouseEvent);
             e.preventDefault();
        }, false);
        canvas.addEventListener("touchend", function (e) {
            var mouseEvent = new MouseEvent("mouseup", {});
            canvas.dispatchEvent(mouseEvent);
        }, false);
        canvas.addEventListener("touchmove", function (e) {
            var touch = e.touches[0];
            var mouseEvent = new MouseEvent("mousemove", {
                clientX: touch.clientX,
                clientY: touch.clientY
            });
            canvas.dispatchEvent(mouseEvent);
             e.preventDefault();
           
        }, false);
       
        // Get the position of a touch relative to the canvas
        function getTouchPos(canvasDom, touchEvent) {
            var rect = canvasDom.getBoundingClientRect();
            return {
                x: touchEvent.touches[0].clientX - rect.left,
                y: touchEvent.touches[0].clientY - rect.top
            };
        }
       
        function findxy(res, e){
            const rect = canvas.getBoundingClientRect();
            if (res == 'down') {
                prevX = currX;
                prevY = currY;
                currX = e.clientX - rect.left ;
                currY = e.clientY -  rect.top;
               
                flag = true;
                dot_flag = true;
                if (dot_flag) {
                    ctx.beginPath();
                    ctx.fillStyle = x;
                    ctx.fillRect(currX, currY, 2, 2);
                    ctx.closePath();
                    dot_flag = false;
                }
            }
            if (res == 'up' || res == "out") {
                flag = false;
            }
            if (res == 'move') {
                if (flag) {
                    prevX = currX;
                    prevY = currY;
                    currX = e.clientX -  rect.left;
                    currY = e.clientY - rect.top;
                    draw(component,ctx);
                }
            }
        }
        function draw() {
            ctx.beginPath();
            ctx.moveTo(prevX, prevY);
            ctx.lineTo(currX, currY);
            ctx.strokeStyle = x;
            ctx.lineWidth = y;
            ctx.stroke();
            ctx.closePath();
        }
       
    },
    eraseHelper: function(component, event, helper){
        var m = confirm("Want to clear");
        if (m) {
            var canvas=component.find('can').getElement();
            var ctx = canvas.getContext("2d");
            var w = canvas.width;
            var h = canvas.height;
            ctx.clearRect(0, 0, w, h);
       }
    },
    saveHelper:function(component, event, helper){
        var pad=component.find('can').getElement();
        var dataUrl = pad.toDataURL();
        console.log('dataUrl:='+dataUrl);
        var strDataURI=dataUrl.replace(/^data:image\/(png|jpg);base64,/, "");
        alert(strDataURI);
      
    }
})

Some findings the issue is on touch events 
Any help to resolve the above issue
Hi , 
I have a requirement that there is a Revenue text field in Account object, so whenever we give some information into that field ,status will need to be change Pending to Submit.
Thanks in Advance.
HI,
I'm trying to use the following code to add and delete records from a mileage report object.  Everything is working great, except if the user hits the add row button ("add expense") and then changes his mind and hits "delete" button, the row won't delete until user puts values in the required field of the row he's trying to delete.  Is there a way to simply cancel adding the row?  I'm just getting started with VF/Apex and trying to make the code work.  Any help is appreciated.  
<apex:page standardController="Expense_Report__c" extensions="addMileageExpense" sidebar="false">
 <table>
    <colgroup>
            <col span="2" /><col />
  	</colgroup>
  <tr>
    <td><h2>
        Expense Report Name:</h2></td>
      <td> <apex:outputField value="{! Expense_Report__c.Name__c }"/></td>  
  </tr>
  <tr></tr>
  <tr>
      <td><h2>
          
          Start Date:</h2> </td>
      <td><apex:outputField value="{! Expense_Report__c.Start_Date__c}"/></td>
  </tr>

    <br/>
    <br/>
            <td><h2>
          Expense Report:</h2> </td>
      
     <td><apex:outputField value="{!Expense_Report__c.id}"/>	</td>
</table>
        <br/>
    <br/>
    <apex:form >

 		<apex:pageBlock title="Mileage Report" id="er">
 		
            <apex:pageMessages />
 		<apex:variable var="rowNumber" value="{!0}"/>
               <apex:pageblockSection columns="1" id ="mytable">
                   <apex:actionSupport event="onchange" reRender="mytable"/>   
 				<apex:pageBlockTable title="Mileage Expenses" var="me" value="{!expenseList}"> 

 					<apex:column headerValue="Entry" style="width:20px; text-align:center;" headerClass="centertext">
 						<apex:outputText value="{0}" style="text-align:center;"> 
 							<apex:param value="{!rowNumber+1}" /> 
 						</apex:outputText>
					</apex:column> 
 					
                    <apex:column headerValue="Date of trip" >
                       <apex:inputField value="{!me.Date__c}"  required="true"/>
 					</apex:column>
                    
                    <apex:column headerValue="Purpose and Description" >
                       <apex:inputField value="{!me.Name}" id="name" required="true"/>
 					</apex:column> 
 


                    <apex:column headerValue="{! Expense_Report__c.Program_1_Number__c}" 
                                 style="width:50px" footerValue="{! Expense_Report__c.Program_1_Number__c}" 
                                 rendered = "{! If(Expense_Report__c.Program_1_Number__c== null ,false,true) }">
                        <apex:inputField value="{!me.Prgm_1_Miles__c}" style="width:50px" ></apex:inputField>
                     </apex:column>
                        
                        <apex:column headerValue="{! Expense_Report__c.Program_2_Number__c}" 
                                     style="width:50px" footerValue="{! Expense_Report__c.Program_2_Number__c}" 
                                     rendered = "{! If(Expense_Report__c.Program_2_Number__c== null ,false,true) }">
                            <apex:inputField value="{!me.Prgm_2_Miles__c}"  style="width:50px"  ></apex:inputField>
 					    </apex:column> 
                            
                      <apex:column headerValue="{! Expense_Report__c.Program_3_Number__c}" 
                                   style="width:50px" footerValue="{! Expense_Report__c.Program_3_Number__c}" 
                                   rendered = "{! If(Expense_Report__c.Program_3_Number__c== null ,false,true)}">
                          <apex:inputField value="{!me.Prgm_3_Miles__c}"  style="width:50px"  ></apex:inputField>
 					</apex:column> 
                          
                        <apex:column headerValue="{! Expense_Report__c.Program_4_Number__c}" 
                                     style="width:50px" footerValue="{! Expense_Report__c.Program_4_Number__c}" 
                                     rendered = "{! If(Expense_Report__c.Program_4_Number__c== null ,false,true) }">
                            <apex:inputField value="{!me.Prgm_4_Miles__c}"  style="width:50px"  ></apex:inputField>
 					</apex:column> 
                            
                            <apex:column headerValue="{! Expense_Report__c.Program_5_Number__c}" 
                                         style="width:50px" footerValue="{! Expense_Report__c.Program_5_Number__c}" 
                                         rendered = "{! If(Expense_Report__c.Program_5_Number__c== null ,false,true) }">
                                <apex:inputField value="{!me.Prgm_5_Miles__c}"  style="width:50px"  ></apex:inputField>
 					</apex:column> 
                        
                      <apex:column headerValue="{! Expense_Report__c.Program_6_Number__c}" 
                                   footerValue="{! Expense_Report__c.Program_6_Number__c}" style="width:50px" 
                                   rendered = "{! If(Expense_Report__c.Program_6_Number__c== null ,false,true) }">
                          <apex:inputField value="{!me.Prgm_6_Miles__c}"  style="width:50px"  ></apex:inputField>
 					</apex:column> 
                
                    <apex:column headerValue="Total Miles" footerValue= "Total Miles" style="width:50px">
                        <apex:inputField value="{!me.Total_Miles__c}"  style="width:50px"  ></apex:inputField>
 					</apex:column> 
                          
                             
                    <apex:column headerValue="Action" >
                         <apex:commandButton value="Delete" action="{!deleteRow}" reRender="er">
 						<apex:param name="rowIndex" value="{!rowNumber}"/>
                      </apex:commandButton>
                         <apex:variable var="rowNumber" value="{!rowNumber+1}"/>
                        </apex:column> 

                 </apex:pageBlockTable>
                                    
               <apex:commandButton action="{!addRow}" value="Add Expense" reRender="er"/>
 	           </apex:pageblockSection>
                              
 			<apex:pageBlockButtons >
 		                <apex:commandButton value="Save" action="{!ave}" />
 		         <apex:commandButton value="Cancel" action="{!cancel}"/>
 			</apex:pageBlockButtons>
 		</apex:pageBlock>

       
 		
 	</apex:form> 
 </apex:page>

And here's the controller: 
 
public class addMileageExpense {
public Expense_Report__c reports;
 public Mileage_expense__c del;
 public List<Mileage_expense__c> addexpenseList {get;set;}
 public List<Mileage_expense__c> delexpenseList {get;set;}
 public List<Mileage_expense__c> expenseList {get;set;}
 public Integer totalCount {get;set;}
 public Integer rowIndex {get;set;}
 public List<Mileage_expense__c> delexpense {get; set;} 
 public addMileageExpense(ApexPages.StandardController controller) {
 
 reports = (Expense_Report__c)controller.getRecord();
 expenseList = [Select id, Name, Expense_Report__c, Miles__c, Total_Miles__c,   
                Date__c, Prgm_1_Miles__c, Prgm_2_Miles__c, Prgm_3_Miles__c, Prgm_4_Miles__c, 
                Prgm_5_Miles__c, Prgm_6_Miles__c from Mileage_expense__c where Expense_Report__c =: reports.ID];
 totalCount = expenseList.size();
 
 delexpenseList = new List<Mileage_expense__c>();
 delexpense = new List<Mileage_expense__c>();
 }
 
 public void addRow(){
 addexpenseList = new List<Mileage_expense__c>();
 expenseList.add(new Mileage_expense__c(Expense_Report__c = reports.Id));
 }
 
 public PageReference ave(){
 
 upsert expenseList;
 delete delexpenseList;
 return (new ApexPages.StandardController(reports)).view();
 } 
 
 public void deleteRow(){
 
 rowIndex = Integer.valueOf(ApexPages.currentPage().getParameters().get('rowIndex'));
 System.debug('row to be deleted ' + rowIndex );
 System.debug('row to be deleted '+ expenseList[rowIndex]);

     del = expenseList.remove(rowIndex);
 
         delexpenseList.add(del);
     
 }
 }


 
Hello everyone, I just get started with Salesforce development. Is there a possibility that the total amount can show up on the page I post. I want to get the sum of the Amount and display the number on this page. 
User-added image
Exactly as stated in the title.

Here's my code:
 
<apex:page sidebar="false" showHeader="false">
    <script>
    oNewDoc = window.open('https://domain--sandbox.lightning.force.com/one/one.app#/sObject/0F92C00000TESTURL/view?a:t=','_self');
    </script>
</apex:page>

Here're my results:

User-added image
Hello,

I have written a test class for a fucntion.
I  wrote some debug logs in the function.

The debug logs are getting executed but the code coverage is non.

The logic between debug logs should have been executed as the system.debug got executed..
i wonded how to resolve this issue..
 
  • February 03, 2017
  • Like
  • 0
Hi,

I would like to remove a trigger in both production and sandbox by means of the developer console. 
Is this possible at all and if so, how can I do this?

Thanks
Dennis
I have a scenerio where jquery ui's autocomplete functionlity doesn't work. It does not generate combo box for autocomplete. Is there any compatibility issue? Please have a look into code and help with the issue

Component Markup
<aura:component >
<ltng:require styles="/resource/slds0120/assets/styles/salesforce-lightning-design-system.css" /> 
<ltng:require styles="/resource/jsAssets/jquery-ui.min.css" scripts="/resource/jsAssets/jquery.js,/resource/JqueryUINew/jquery-ui.min.js" afterScriptsLoaded="{!c.documentReady}" /> 
<button type="button" title="Add Organization" aria-haspopup="true" class="slds-button slds-button--icon-border-filled slds-button--icon-small custom-add"><span class="slds-icon__container slds-icon-utility-add">
    <c:adminifiedIcons class="slds-button__icon slds-icon--x-small" svgPath="/resource/SLDS0120/assets/icons/utility-sprite/svg/symbols.svg#add" />
    <span class="slds-assistive-text"> </span> </span> </button>
    <span class="ss"></span>
<input type="text" id="topic_title" class="select-org"/>

<ui:inputSelect aura:id="org_drop_down" class="selOrg select-org">

</aura:component>
Controller js code
 
({
documentReady : function(component, event, helper) {
    /* globals $ */
    var availableTags = ["ActionScript","AppleScript","Asp","BASIC"];
    $( ".select-org" ).autocomplete({
        source: availableTags,

    });

    $.widget( "custom.combobox1", {
        _create: function() {
            this.wrapper = $( "<span>" )
            .addClass( "custom-combobox" )
            .insertAfter( this.element );
            this.element.hide();
            this._createAutocomplete();
            this._createShowAllButton();
        },
        _createAutocomplete: function() {
            var selected = this.element.children( ":selected" ),
                value = selected.val() ? selected.text() : "";
            this.input = $( "<input autofocus class='slds-input slds-input--small' placeholder='Organization'>" )
            .appendTo( this.wrapper )
            .val( value )
            .attr( "title", "" )
            .addClass( "custom-combobox-input ui-widget ui-widget-content ui-state-default ui-corner-left")
            .autocomplete({
                delay: 0,
                minLength: 0,
                source: $.proxy( this, "_source" )
            })
            .tooltip({
                tooltipClass: "ui-state-highlight"
            });

            this._on( this.input, {
                autocompleteselect: function( e, ui ) {
                    ui.item.option.selected = true;
                    this._trigger( "select", e, {
                        item: ui.item.option
                    });
                },
                autocompletechange: "_removeIfInvalid"
            });
        },

        _createShowAllButton: function() {
            var input = this.input,
                wasOpen = false;
            $( "<a>" )
            .attr( "tabIndex", -1 )
            .appendTo( this.wrapper )
            .button({
                icons: {
                    primary: "ui-icon-triangle-1-s"
                },
                text: false
            })
            .removeClass( "ui-corner-all" )
            .addClass( "custom-combobox-toggle ui-corner-right" )
            .mousedown(function() {
                wasOpen = input.autocomplete( "widget" ).is( ":visible" );
            })
            .click(function() {
                input.focus();
                // Close if already visible
                if ( wasOpen ) {
                    return;
                }
                // Pass empty string as value to search for, displaying all results
                input.autocomplete( "search", "" );
            });
        },

        _source: function( request, response ) {
            var matcher = new RegExp( $.ui.autocomplete.escapeRegex(request.term), "i" );
            response( this.element.children( "option" ).map(function() {
                var text = $( this ).text();
                if ( this.value && ( !request.term || matcher.test(text) ) )
                    return {
                        label: text,
                        value: text,
                        option: this
                    };
            }) );
        },

        _removeIfInvalid: function( e, ui ) {
            // Selected an item, nothing to do
            if ( ui.item ) {
                return;
            }

            // Search for a match (case-insensitive)
            var value = this.input.val(),
                valueLowerCase = value.toLowerCase(),
                valid = false;
            this.element.children( "option" ).each(function() {
                if ( $( this ).text().toLowerCase() === valueLowerCase ) {
                    this.selected = valid = true;
                    return false;
                }
            });

            // Found a match, nothing to do
            if ( valid ) {
                return;
            }

            // Remove invalid value
            this.input
            .val( "" )
            .attr( "title", value + " didn't match any item" )
            .tooltip( "open" );
            this.element.val( "" );
            this._delay(function() {
                this.input.tooltip( "close" ).attr( "title", "" );
            }, 1500 );
            this.input.autocomplete( "instance" ).term = "";
        },

        _destroy: function() {
            this.wrapper.remove();
            this.element.show();
        }
    });
        var opts = [];
        opts.push({ class: "optionClass", label: "shankar", value: "shankar" }); 
        opts.push({ class: "optionClass", label: "singh", value: "singh" }); 
        //component.find("org_drop_down").set("v.options", opts);
        $('.select-org').combobox1({
            source: opts,
        });



}
})

Thanks in advance.

 
I have two custom fields on the Opportunity object, a text field and a lookup field.  The text field gets populated from an outside source and I want to populate the contents of text field  and have it display in the lookup field.

I need help to create a simple trigger for this on the Opportunity object.

**Opportunity object**
text field - Discount_Code__c 
lookup field - Discount_code_LU__c 

Basic logic would be "Discount_Code_LU__c = Discount_Code__c"
Hello All,

I am trying to get the attachment parent owner id via SOQL, but it did not return any data.
Currently i have written individual query for each object to get the ownerId.
The problem here is, if we are having more than 10 parent objects then we have to write individual SOQL for each object, which looks quote ugly.
Any suggestion or solution is much appreciated.

Thanks in advance!!
Hi Experts,

I have small requirement , i need to create custom clone button on opportunity for prospecting record type opportunity record, so when ever i click on that particular button , prospecting record type opportunity need to clone and that respected record id needs to populate in a field called Prospecting_opportunity__c(field will be there in the same opportunity object

Thanks in advance