• Umesh Rathi
  • NEWBIE
  • 70 Points
  • Member since 2019
  • Salesforce Developer
  • Accenture


  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 20
    Replies
If I have an object in Salesforce that a profile currently does not have any access to however I want to add a button which updates a field on a record in that object is that possible?

Can there be any customization which can allow the update to happen as a user which does have access to the object or even as an admin or is giving access to the object the only option?
  • September 17, 2019
  • Like
  • 0
Hi Everyone;
In each interview i am being asked this question but i am unable to write and run it properly.
Here is question:
write a trigger which will populate sum of child field values on prarent.(basically count Rollup summary trigger for lookup relationship)
I did search in community and got below program which is still not working:

trigger SumTrigger on Contact (before insert) {
list<Account>accts=new list<Account>();
set<ID>IDs=new set <ID>() ;
  if(trigger.isInsert||trigger.isUndelete){
      for(contact con:trigger.new) {  
      IDs.add(con.accountId) ;      
      }}   
    
  else if(trigger.isDelete){
      for(contact con:trigger.old) {  
      IDs.add(con.accountId) ;      
      }}   
 
else if(trigger.isUpdate){
      for(contact con:trigger.new) {
          if(con.AccountId !=null){
           IDs.add(con.accountId) ;   
          }     
            
      }}   
      
  if(IDs.size()>0){
 accts=[select id,TotalValue__c,(select id,value__c from contacts ) from Account where id in :IDs];              
  }     

  for(Account a:accts)  {
    for (contact c:a.contacts){
    a.TotalValue__c +=c.value__c;    
    }
        update accts; 
    }
}

No complie error but when inserting contact record getting below error:

SumTrigger: execution of BeforeInsert caused by: System.NullPointerException: Attempt to de-reference a null object Trigger.SumTrigger: line 30, column 1

also on modifying a section like below 

for(Account a:accts)  {
    decimal Value=0;
    for (contact c:a.contacts){
    value += c.value__c;
        
    }
    a.TotalValue__c =value;    
        
    }
     update accts;                 
}

again getting below error on insering any contact record:
SumTrigger: execution of BeforeInsert caused by: System.NullPointerException: Argument cannot be null. Trigger.SumTrigger: line 29, column 1

Please help me with easy trigger code to make it work.

Thanks in advance;

I am facing issue while coming back from external URL within Salesforce Mobile app built using LWC
I am using and navigating to an external URl from salesforce mobile app. However, if we click mobile back button it doesnt get me back. Every time i have to close the app and start over again. Also, if i navigate to menu -> my app it still lands me on the external url.
<form name="frm" action={meta.ActionURL} method="post" target="_self"> <input type="hidden" name="msg" value={meta.ActionCode}> <input type="submit" value={meta.ButtonName} class="buttonClass" onclick={onClose}> </form>

Any help is appreciated.
Thanks
I have a Listview Named: 'My Open Cases' when i change user's language to Spanish i can see Spanish translation of that Listview. Where can i find this translation
Hello!

I'm trying to get the values from some account fields that are related to an opportunity. I'm not sure why I was able to get the account name but not the custom fields...What am I doing wrong? 

I would appreciate your help

This one is working fine:
import { LightningElement, api, wire } from 'lwc';
import { getRecord } from 'lightning/uiRecordApi';
import LightningAlert from 'lightning/alert';
import ACCOUNTNAME_FIELD from '@salesforce/schema/Opportunity.Account.Name'
import VALIDATEADDRESS_FIELD from '@salesforce/schema/Opportunity.Account.Address_Verified__c'
import ACCOUNTMANAGERFORGETT_FIELD from '@salesforce/schema/Opportunity.Account.Account_Manager_for_GT__c'
import VATNUMBER_FIELD from '@salesforce/schema/Opportunity.Account.Company_Id__c'
import PRIMARYCONTACT_FIELD from '@salesforce/schema/Opportunity.Account.Primary_Contact__c'
import FINANCECONTACT_FIELD from '@salesforce/schema/Opportunity.Account.Finance_Contact__c'
import LEGALCOMPANYNAME_FIELD from '@salesforce/schema/Opportunity.Account.Legal_Company_Name__c'
import PAYMENTMETHOD_FIELD from '@salesforce/schema/Opportunity.Account.Payment_Method__c'
import PAYMENTTERM_FIELD from '@salesforce/schema/Opportunity.Account.Payment_Term__c'
import ACCOUNTID_FIELD from '@salesforce/schema/Opportunity.AccountId'
export default class CompanyCreationAlerts extends LightningElement {
    accRecordId
    @api recordId

    
    @wire(getRecord, { recordId: '$recordId', fields: [ACCOUNTNAME_FIELD]})
    oppHandler({ data, error }) {
        if (data) {
            console.log(data)
        }
        if (error) {
            console.error(error)
        }
    }
}

This one is not working:
import { LightningElement, api, wire } from 'lwc';
import { getRecord } from 'lightning/uiRecordApi';
import LightningAlert from 'lightning/alert';
import VALIDATEADDRESS_FIELD from '@salesforce/schema/Opportunity.Account.Address_Verified__c'
import ACCOUNTMANAGERFORGETT_FIELD from '@salesforce/schema/Opportunity.Account.Account_Manager_for_GT__c'
import VATNUMBER_FIELD from '@salesforce/schema/Opportunity.Account.Company_Id__c'
import PRIMARYCONTACT_FIELD from '@salesforce/schema/Opportunity.Account.Primary_Contact__c'
import FINANCECONTACT_FIELD from '@salesforce/schema/Opportunity.Account.Finance_Contact__c'
import LEGALCOMPANYNAME_FIELD from '@salesforce/schema/Opportunity.Account.Legal_Company_Name__c'
import PAYMENTMETHOD_FIELD from '@salesforce/schema/Opportunity.Account.Payment_Method__c'
import PAYMENTTERM_FIELD from '@salesforce/schema/Opportunity.Account.Payment_Term__c'
import ACCOUNTID_FIELD from '@salesforce/schema/Opportunity.AccountId'
export default class CompanyCreationAlerts extends LightningElement {
    accRecordId
    @api recordId

    
    @wire(getRecord, { recordId: '$recordId', fields: [ACCOUNTID_FIELD,VALIDATEADDRESS_FIELD,ACCOUNTMANAGERFORGETT_FIELD,
        VATNUMBER_FIELD, PRIMARYCONTACT_FIELD,FINANCECONTACT_FIELD, LEGALCOMPANYNAME_FIELD,PAYMENTMETHOD_FIELD, PAYMENTTERM_FIELD]})
    oppHandler({ data, error }) {
        if (data) {
            console.log(data)
        }
        if (error) {
            console.error(error)
        }
    }
}



 
Create an Apex trigger that will count the number of contacts associated with an account(create a field at account level). Must update the count in insertion and deletion of contact by using MAP Collection.
Hi Everyone,

I have LWC component wrapped in aura component. My LWC component is using gerRecord to get the recordType info of the record. 
The problem I'm facing is when i first time click the button, wire method is not called and on refresh of the screen it's working as expected.

Note: Two scenarios @wire is not getting called are below,
1) on first time load of screen
2) when screen is left ideal for few minutes.

Please let me know if anyone has any suggestions on this.

Thanks
@isTest
public class OpportunityAmountInWordsTest
{
  
    Public static testmethod void OpportunityAmountInWordsTM()
    {
        RecordType rt = [select id,Name from RecordType where SobjectType='Account' and Name='Supplier' Limit 1];
        Account Acc =New Account();
            Acc.RecordTypeId=rt.id;
            Acc.Name='Test';
            Acc.GST_Reg_No__c='test1';
            Acc.TAX_IDENTIFICATION_NUMBER_VAT__c='Test11';
            Acc.IMPORT_EXPORT_CODE_IEC__c='test12';
            Insert Acc;
       
       Product2 Pro =New Product2 ();
            Pro.Name ='tEST';
            Pro.CurrencyIsoCode='USD';
            Insert Pro;
       Order odd =New Order();
            odd.AccountId=acc.id;
            odd.EffectiveDate=System.today();
            odd.Status__c='Draft';
            odd.Product_Name__c=pro.id;
            odd.Quantity__c=1234;
            odd.Quantity_per_Container__c=23;
            odd.Quantity_per_Packaging_Material__c =55;
            odd.Status='Draft';
            Insert odd;
            
        Opportunity opp =New Opportunity();
            opp.Name='Test';
            opp.accountId = Acc.id;
            opp.CloseDate=system.today();
            opp.CurrencyIsoCode ='USD';
            opp.Worked_by__c='Neha';
            opp.Product_Name__c=pro.id;
            opp.Description_of_Goods__c='test';
            opp.Origin__c='test';
            opp.Packaging_Details__c='trueuus';
            opp.Quantity__c=10000;
            opp.H_S_Code__c='amit';
            opp.Container_Size__c='20 FCL';
            // opp.Agent_Name__c=Customer.id;
            opp.StageName='Enquiry';
            // opp.Agent_Fee_IO__c=123;
            Insert opp;
            
            List<Cost_Price__c> lCostPr = new List<Cost_Price__c>();
            Cost_Price__c Cost1 =New Cost_Price__c();
            Cost1.Opportunity__c=opp.id;
            Cost1.Supplier_Name__c=Acc.id;
            //Cost1.Opportunity__c=opp.Accountid;
            Cost1.Country_of_Final_Destination_Picklist__c='India';
            Cost1.CurrencyIsoCode='USD';
            Cost1.UOM__c='Tonnes';
            cost1.Payment_Status__c = 'DUE';
            cost1.Payment_Receivable_Date__c = System.now().date().addDays(-40);
               
           lCostPr.add(cost1);
            Insert lCostPr;          
           
}
    
}
If I have an object in Salesforce that a profile currently does not have any access to however I want to add a button which updates a field on a record in that object is that possible?

Can there be any customization which can allow the update to happen as a user which does have access to the object or even as an admin or is giving access to the object the only option?
  • September 17, 2019
  • Like
  • 0
Hello, I'm new to Lightning Components and I decided to create a calculator using Lightning Components.
Given two numbers, when I click "Add" the result should be displayed.

Here's the code:

calculator.cmp
<aura:component >
    <aura:attribute name = 'num1' type = 'Integer' default = '15'></aura:attribute>
    <aura:attribute name = 'num2' type = 'Integer' default = '20'></aura:attribute>
    <aura:attribute name = 'sum' type = 'Integer'></aura:attribute>
    <div>
        <p>Add</p><lightning:button label = 'Add' onClick = '{!c.add}'/>
        <p>{!v.num1} + {!v.num2} = {!v.sum}</p>
    </div>
</aura:component>

calculatorController.js
({
    add : function(component, event, helper) {     
        //Add numbers
        var num1 = component.get('v.num1');
        var num2 = component.get('v.num2');
        var sumResult = num1 + num2;
        component.set('v.sum', sumResult);
        
    }
})

The add result doesn't show up when I click the button. It'd be great if someone helps! Thanks!
trigger countContact on Contact (after insert, after update, after delete, after undelete)
{
  Set<Id> setAccountIds = new Set<Id>();
 
  //Whenever your working with After Undelete operation you can access data through
  //Trigger.new or Trigger.newMap but not with Trigger.old or Trigger.oldmap variables
  if(Trigger.isInsert || Trigger.isUndelete || Trigger.isUpdate)
  {
   for(Contact con : Trigger.new)
   {
    setAccountIds.add(con.AccountId);
   }
  }
 
  if(Trigger.isDelete)
  {
   //if you use Trigger.new below in place of Trigger.old you will end up with
   //System.NullPointerException:Attempt to de-reference a null object
   for(Contact con : Trigger.old)
   {
    setAccountIds.add(con.AccountId);
   }
  }
 
 List<Account> listAccs = [Select id,name,Total_No_Of_Contacts__c ,(Select id from contacts) from Account where Id in : setAccountIds];
  for(Account acc :listAccs)
  {
   acc.Total_No_Of_Contacts__c = acc.contacts.size();
  }
          List<Account> listAccs1 = [Select id,name,No_of_active_contacts__c ,(select id from contacts where Contact_Roll__c = True) from Account where Id in : setAccountIds];
  for(Account acc1 :listAccs1)
  {
   acc1.No_of_active_contacts__c = acc1.contacts.size();
  }
  update listAccs;
  update listAccs1;
 
}
 
  • March 26, 2019
  • Like
  • 0
Hi Everyone;
In each interview i am being asked this question but i am unable to write and run it properly.
Here is question:
write a trigger which will populate sum of child field values on prarent.(basically count Rollup summary trigger for lookup relationship)
I did search in community and got below program which is still not working:

trigger SumTrigger on Contact (before insert) {
list<Account>accts=new list<Account>();
set<ID>IDs=new set <ID>() ;
  if(trigger.isInsert||trigger.isUndelete){
      for(contact con:trigger.new) {  
      IDs.add(con.accountId) ;      
      }}   
    
  else if(trigger.isDelete){
      for(contact con:trigger.old) {  
      IDs.add(con.accountId) ;      
      }}   
 
else if(trigger.isUpdate){
      for(contact con:trigger.new) {
          if(con.AccountId !=null){
           IDs.add(con.accountId) ;   
          }     
            
      }}   
      
  if(IDs.size()>0){
 accts=[select id,TotalValue__c,(select id,value__c from contacts ) from Account where id in :IDs];              
  }     

  for(Account a:accts)  {
    for (contact c:a.contacts){
    a.TotalValue__c +=c.value__c;    
    }
        update accts; 
    }
}

No complie error but when inserting contact record getting below error:

SumTrigger: execution of BeforeInsert caused by: System.NullPointerException: Attempt to de-reference a null object Trigger.SumTrigger: line 30, column 1

also on modifying a section like below 

for(Account a:accts)  {
    decimal Value=0;
    for (contact c:a.contacts){
    value += c.value__c;
        
    }
    a.TotalValue__c =value;    
        
    }
     update accts;                 
}

again getting below error on insering any contact record:
SumTrigger: execution of BeforeInsert caused by: System.NullPointerException: Argument cannot be null. Trigger.SumTrigger: line 29, column 1

Please help me with easy trigger code to make it work.

Thanks in advance;
Hello Guys,

I am working on one vf Page where I have two check boxes for each row, so if I check one checkbox then other should be unchecked.
I mean in one row,I can select only one check.

User-added image
In above screenshot if I select approved then disapproved should get unchecked and vice versa.

My vf page code is below.
<apex:page controller="ApproveTimeSheetController" lightningStylesheets="true">
   
   
    <style type="text/css">
       
        .inputcell {width:80px;text-align:center;}
        
        .myFormStyle {
            background-color:#7492B1;
        }
        
        
         
        #customers {
          font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
          border-collapse: collapse;
          width: 100%;
        } 
        
        #customers td, #customers th {
          border: 1px solid #ddd;
          padding: 4px;
        }
        
        #customers tr:nth-child(even){background-color: #eaebef;}
        #customers tr {
            height: 40px;
        }
        #customers tr:hover {background-color: #ddd;}
        
        #customers th {
          padding-top: 5px;
          padding-bottom: 5px;        
          background-color: #a9c2d6;
          color: white;
        }

    
    </style>
   
  
    <apex:form id="timesheetform" styleclass="myFormStyle" rendered="{!!PageInError}">
        
      
        <apex:slds />
            
        <div style="padding: 20px;" >
        
          
            <div class="slds-page-header">
                <div class="slds-page-header__row">
                    
                    <div class="slds-page-header__col-title">
                        <div class="slds-media">
                            <div class="slds-media__figure">
                                <span class="slds-icon_container slds-icon-standard-opportunity" title="Approve Timesheet">
                                    <svg class="slds-icon slds-page-header__icon" aria-hidden="true">
                                        <use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="/assets/icons/standard-sprite/svg/symbols.svg#work_type_group" />
                                    </svg>
                                    <span class="slds-assistive-text">Forecast</span>
                                </span>
                            </div>
                        <div class="slds-media__body">
                            <div class="slds-page-header__name">
                                <div class="slds-page-header__name-title">
                                    <h1><span class="slds-page-header__title slds-truncate">{!Title}</span></h1>
                                </div>
                            </div>
                            <p class="slds-page-header__name-meta">Approve Timesheets</p>
                        </div>
                        <br/>
                         <a href="/{!ParameterId}">Back to Project</a>
                    </div>
                </div>
                </div>
            </div>
    
            <br/>
           
            <apex:pageBlock title="Date Selection" id="DateSelection">
            
                <table width="100%">
                    <COLGROUP width="40%"></COLGROUP>
                    <COLGROUP width="40%"></COLGROUP>
                
                    <tr>
                        <td><apex:outputLabel value="Week Start" />&nbsp;&nbsp;<apex:inputField value="{!fakeWeek1.Week_Start_Date__c}" /></td>
                        <td ><apex:commandButton action="{!Previous}" value="<<"/>&nbsp;&nbsp;<apex:commandButton value="Refresh" action="{!Refresh}"/> &nbsp;&nbsp;<apex:commandButton action="{!Next}" value=">>" /></td>
                     
                        
                    </tr>
                </table>
            </apex:pageBlock>
             
            <br/>
            
            <apex:repeat value="{!TimeSheetsByMembers}" var="member">
                <apex:pagemessages id="ErrorMessages" />  
                <apex:pageBlock title="{!member.TeamMemberName} ({!member.Role})">
                    <apex:outputpanel rendered="{!member.NoTimeThisWeek}">
                       <div style="color:red;"><b>NO TIMESHEET ENTRIES FOR THIS WEEK</b></div>
                    </apex:outputpanel>
                    <apex:outputpanel id="Timesheets" rendered="{!not(member.NoTimeThisWeek)}">
                        <table padding="30px;">
                            <tr><td  style="text-align:right;">  
                        
                                <apex:commandButton value="Approve All" action="{!ApproveAll}" rerender="timesheetform">
                                    <apex:param name="index" value="{!member.TeamMemberid}" assignTo="{!SelectedMemberId}"/>
                                </apex:commandButton>
                            </td></tr>
                        </table>
                        <br/>
                        <table padding="10px;" id="customers">
                            <COLGROUP width="7%"></COLGROUP>
                            <COLGROUP width="12%"></COLGROUP>    
                            <COLGROUP width="12%"></COLGROUP>    
                            <COLGROUP width="7%"></COLGROUP> 
                            <COLGROUP width="5%"></COLGROUP>
                            <COLGROUP width="20%"></COLGROUP>
                            <COLGROUP width="5%"></COLGROUP>
                            <COLGROUP width="5%"></COLGROUP>
                            <COLGROUP width="20%"></COLGROUP>
                            <COLGROUP width="15%"></COLGROUP>
                            
                            <!--headers-->
                           
                            <tr class="dbrow">
                                <th>Date</th>
                                <th style="text-align:center;">Function</th>
                                <th style="text-align:center;">Type of Work</th>
                                <th style="text-align:center;">Hours</th>
                                <th style="text-align:center;">Billable</th>
                                <th>Comments</th> 
                                <th style="text-align:center;">Approved</th>
                                <th style="text-align:center;">Rejected</th>
                                <th>Rejected Comments</th>
                                <th>Click to Edit</th>
                            </tr>    
                            <apex:repeat value="{!member.Times}" var="time"> 
                                <tr>
                                    <td><apex:outputText value="{!time.TimeDate}"/></td>
                                    <td style="text-align:center;"><apex:outputText value="{!time.timerecord.Function__c}"/></td>
                                    <td style="text-align:center;"><apex:outputText value="{!time.timerecord.Type_of_Work__c}"/></td> 
                                    <td style="text-align:center;"><apex:outputText value="{!time.timerecord.Hours__c}"/></td>
                                    <td style="text-align:center;"><apex:outputText value="{!time.timerecord.Billable__c}"/></td>
                                    <td><apex:outputText value="{!time.timerecord.Comments__c}"/></td>   
                                    <td style="text-align:center;">
                                        <apex:inputcheckbox id="apprvchk" value="{!time.Approved}">
                                        
                                        </apex:inputcheckbox> 
                                            
                                    </td>  
                                    <td style="text-align:center;">
                                        <apex:inputcheckbox id="rejectchk" value="{!time.Rejected}">
                                            
                                        </apex:inputCheckbox>
                                    </td>  
                                    <td><apex:inputText value="{!time.timerecord.Rejected_Comments__c}"/></td>  
                                    <td><apex:outputlink value="/{!time.timerecord.Id}" target="_blank">{!time.timerecord.name}</apex:outputlink></td>  
                                </tr>
                              
                            </apex:repeat>
                           
                        </table>
                        <br/>
                         <table padding="30px;">
                            
                            <tr><td style="text-align:right;">
                                <apex:actionStatus id="submitstatus">
                                    <apex:facet name="start"> 
                                         <img style="opacity:1.0;" src="{!$Resource.SavingGif}"/>
                                    </apex:facet>
                                </apex:actionStatus>   
                                &nbsp;&nbsp;
                                <apex:commandButton value="Submit" action="{!SaveCheckboxes}" rerender="Timesheets,ErrorMessages" status="submitstatus">
                                      <apex:param name="index2" value="{!member.TeamMemberid}" assignTo="{!SelectedMemberId}"/>
                                </apex:commandButton>
                            </td></tr>
                        </table>
                    </apex:outputpanel>
                </apex:pageBlock>        
                
                
            </apex:repeat>
            
         
        </div>
        
    </apex:form> 
</apex:page>
Can anyone help me out in this issue if possible please.
 
i am trying as below : (CLASS)
public class Displaycontactbyaccname {
   public Map <string,List<Contact>> contactMap {get;set;}
public Displaycontactbyaccname() {
      contactMap = new Map < string, List < Contact >> ();
        List<Contact> conlist = [Select LastName,Account.Name from Contact Where Account.Name != null ];
        System.debug('conn'+conlist[0].Account.Name);
         for (Contact con : conlist)
       {
          if(contactMap.containskey(con.account.Name))
          contactMap.get(con.account.Name).add(con);
      else
          contactMap.put(con.account.Name,new list<contact>{con});
               } }}


and below VF page is 
<apex:page controller="Displaycontactbyaccname">
 <apex:form >
 <apex:pageBlock >
  <apex:pageBlockTable value="{!contactMap}" var="item"  >
    <apex:column value="{!item}"/>  <!-- key --->
    <apex:column value="{!contactMap[item]}"/>  <!-- Value--->
</apex:pageBlockTable>
</apex:pageBlock>
 </apex:form>
</apex:page>


But output is not right : please help me 
thanks in advance :))

We have made a custom Visualforce:
 
<apex:page id="CloseCases" standardController="Case" recordSetVar="cases">

    <apex:repeat value="{!cases}" var="case">
        {!case.CaseNumber}
        <br/>
    </apex:repeat>

</apex:page>


This is connected to a custom button which is part of a listview. If we select records in the listview they are correctly displayed in the visualforce page. But when we deselect records they are still visibile in the visualforce.
While calling a flow from APEX getting below error:


Sandbox

Apex script unhandled exception by user/organization: 00546000001qdag/00Dq00000001DE1
Source organization: 00DG0000000gNom (null)
Failed to invoke future method 'public static void runFlow(Id)' on class 'invokeFlowForContentVersion' for job id '707q000001EtdbU'

caused by: System.UnexpectedException: Salesforce System Error: 603109869-55056 (-914716401) (-914716401)

Class.invokeFlowForContentVersion.runFlow: line 38, column 1

Debug Log:
42.0 APEX_CODE,FINEST;APEX_PROFILING,INFO;CALLOUT,INFO;DB,INFO;SYSTEM,DEBUG;VALIDATION,INFO;VISUALFORCE,INFO;WAVE,INFO;WORKFLOW,INFO
19:43:52.0 (371119)|USER_INFO|[EXTERNAL]|00546000001qdag|manit@theranet.io.trgger2|Central Standard Time|GMT-05:00
19:43:52.0 (400527)|EXECUTION_STARTED
19:43:52.0 (406351)|CODE_UNIT_STARTED|[EXTERNAL]|FutureHandler - state load
19:43:52.0 (1589278)|CODE_UNIT_FINISHED|FutureHandler - state load
19:43:52.0 (2409256)|EXECUTION_FINISHED
19:43:52.12 (12209844)|USER_INFO|[EXTERNAL]|00546000001qdag|manit@theranet.io.trgger2|Central Standard Time|GMT-05:00
19:43:52.12 (12222737)|EXECUTION_STARTED
19:43:52.12 (12226036)|CODE_UNIT_STARTED|[EXTERNAL]|01pq0000000SKvr|invokeFlowForContentVersion.runFlow
19:43:52.12 (12666633)|HEAP_ALLOCATE|[72]|Bytes:3
19:43:52.12 (12710395)|HEAP_ALLOCATE|[77]|Bytes:152
19:43:52.12 (12726716)|HEAP_ALLOCATE|[342]|Bytes:408
19:43:52.12 (12743353)|HEAP_ALLOCATE|[355]|Bytes:408
19:43:52.12 (12758201)|HEAP_ALLOCATE|[467]|Bytes:48
19:43:52.12 (12785909)|HEAP_ALLOCATE|[139]|Bytes:6
19:43:52.12 (12800293)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:4
19:43:52.12 (12804925)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:24
19:43:52.12 (12814587)|METHOD_ENTRY|[1]|01pq0000000SKvr|invokeFlowForContentVersion.invokeFlowForContentVersion()
19:43:52.12 (12820648)|STATEMENT_EXECUTE|[1]
19:43:52.12 (12825910)|STATEMENT_EXECUTE|[1]
19:43:52.12 (12829748)|METHOD_EXIT|[1]|invokeFlowForContentVersion
19:43:52.12 (12835376)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:4
19:43:52.12 (12844059)|VARIABLE_SCOPE_BEGIN|[33]|contentDocId|Id|false|false
19:43:52.12 (13008096)|VARIABLE_ASSIGNMENT|[33]|contentDocId|"069q0000000MBDKAA4"
19:43:52.12 (13020904)|STATEMENT_EXECUTE|[33]
19:43:52.12 (13022946)|STATEMENT_EXECUTE|[34]
19:43:52.12 (13045105)|HEAP_ALLOCATE|[34]|Bytes:4
19:43:52.12 (13061652)|VARIABLE_SCOPE_BEGIN|[34]|params|Map<String,ANY>|true|false
19:43:52.12 (13084782)|VARIABLE_ASSIGNMENT|[34]|params|{}|0x7494fffa
19:43:52.12 (13090167)|STATEMENT_EXECUTE|[35]
19:43:52.12 (13094226)|HEAP_ALLOCATE|[35]|Bytes:15
19:43:52.12 (13153039)|HEAP_ALLOCATE|[35]|Bytes:18
19:43:52.12 (13179992)|HEAP_ALLOCATE|[EXTERNAL]|Bytes:-4
19:43:52.12 (13187378)|STATEMENT_EXECUTE|[37]
19:43:52.12 (13190001)|HEAP_ALLOCATE|[37]|Bytes:11
19:43:52.12 (13223069)|HEAP_ALLOCATE|[37]|Bytes:32
19:43:52.12 (13246351)|SYSTEM_METHOD_ENTRY|[9]|Interview.Interview()
19:43:52.12 (13250026)|STATEMENT_EXECUTE|[9]
19:43:52.12 (13256650)|SYSTEM_METHOD_EXIT|[9]|Interview
19:43:52.12 (13274884)|METHOD_ENTRY|[37]||Flow.Interview.createInterview(String, Map<String,ANY>)
19:43:52.12 (19703989)|ENTERING_MANAGED_PKG|Flow__Interview
19:43:52.12 (19722839)|METHOD_EXIT|[1]|doc_sharing
19:43:52.12 (19732510)|HEAP_ALLOCATE|[75]|Bytes:16
19:43:52.12 (19751203)|HEAP_ALLOCATE|[75]|Bytes:8
19:43:52.12 (19756260)|VARIABLE_SCOPE_BEGIN|[5]|this|Flow.Interview.Doc_Sharing|false|false
19:43:52.12 (19782388)|VARIABLE_ASSIGNMENT|[5]|this|null
19:43:52.12 (19788077)|VARIABLE_SCOPE_BEGIN|[5]|initialValues|Map<String,ANY>|true|false
19:43:52.12 (19804415)|VARIABLE_ASSIGNMENT|[5]|initialValues|{"ContentDocument":"069q0000000MBDKAA4"}|0x7494fffa
19:43:52.12 (22040049)|METHOD_EXIT|[37]||Flow.Interview.createInterview(String, Map<String,ANY>)
19:43:52.12 (22052617)|VARIABLE_SCOPE_BEGIN|[37]|docSharingFlow|Flow.Interview|true|false
19:43:52.12 (22106868)|VARIABLE_ASSIGNMENT|[37]|docSharingFlow|"interaction.apex.FlowInterview@13cb3ab4"|0x13cb3ab4
19:43:52.12 (22114602)|STATEMENT_EXECUTE|[38]
19:43:52.12 (22131829)|HEAP_ALLOCATE|[38]|Bytes:26
19:43:52.12 (24863817)|HEAP_ALLOCATE|[38]|Bytes:70
19:43:52.12 (24925354)|FATAL_ERROR|System.UnexpectedException: Salesforce System Error: 603109869-55056 (-914716401) (-914716401)

Class.invokeFlowForContentVersion.runFlow: line 38, column 1
19:43:52.12 (24935787)|FATAL_ERROR|System.UnexpectedException: Salesforce System Error: 603109869-55056 (-914716401) (-914716401)

Class.invokeFlowForContentVersion.runFlow: line 38, column 1
19:43:52.24 (24941641)|CUMULATIVE_LIMIT_USAGE
19:43:52.24 (24941641)|LIMIT_USAGE_FOR_NS|(default)|
  Number of SOQL queries: 0 out of 200
  Number of query rows: 0 out of 50000
  Number of SOSL queries: 0 out of 20
  Number of DML statements: 0 out of 150
  Number of DML rows: 0 out of 10000
  Maximum CPU time: 0 out of 60000
  Maximum heap size: 0 out of 12000000
  Number of callouts: 0 out of 100
  Number of Email Invocations: 0 out of 10
  Number of future calls: 0 out of 50
  Number of queueable jobs added to the queue: 0 out of 1
  Number of Mobile Apex push calls: 0 out of 10

19:43:52.24 (24941641)|CUMULATIVE_LIMIT_USAGE_END

19:43:52.12 (24970625)|CODE_UNIT_FINISHED|invokeFlowForContentVersion.runFlow
19:43:52.12 (25847955)|EXECUTION_FINISHED
Hi,
 
I would like to display data in tabular format, as below:
 
Customer        Brand         Series     Year    January    February   March     April        May         June                     
Best Solution    Apple          S5          2015    $20,500     $15,300     $12,200    $16,000    $23,700     $28,900
Best Solution    Samsung     A6          2015    $21,000     $23,400     $15,440    $19,700    $25,300     $32,430
Best Solution    Apple          S5          2016    $18,200     $11,100     $18,900    $11,000    $24,600   

My question is what should I do to get my data in above layout. I will appreciate your help, please include code to show to how to write code and layout the fields to get the above output, as I am new to Apex and Visualforce. Thanks. 

 
Please see my apex class and Visualforce page. My apex class and vf page are producing results result as follows:
 
Customer          Brand          Series     Year    Month     Net Sale
Best Solution    Apple          S5          2015    1              $20,500  
Best Solution    Apple          S5          2015    2              $15,300
...
...
...
Best Solution    Apple          S5          2016    1              $18,200
...
...
Best Solution    Samsung     A6          2015    1              $21,000  
...
...
 
Apex Class
 
public with sharing class SaleSum {
 
    public Summary[ ] Summaries { get; set; }
 
 public SaleSum() {
        AggregateResult[ ] results = [
        Select Brand__c, CALENDAR_MONTH(Invoice__r.Invoice_Date__c) InvMn, CALENDAR_YEAR(Invoice__r.Invoice_Date__c) InvYr,
            SUM(Net_Amount_US__c) NetUS, SUM(Net_Amount_CDN__c) NetCDN, Invoice__r.Account__r.Currency_Id__c,     
            Invoice__r.Account__r.Customer_Id__c
        From Invoice_Line__c
        Group By Brand__c, CALENDAR_MONTH(Invoice__r.Invoice_Date__c), CALENDAR_YEAR(Invoice__r.Invoice_Date__c),
            Invoice__r.Account__r.Currency_Id__c, Invoice__r.Account__r.Customer_Id__c
        ];
       
        Summaries = new List<Summary>();
        for (AggregateResult gr : results) {
            Summaries.add(new Summary(gr));
        }
    }
 
    public class Summary {
        public Decimal NetUS { get; private set; }
        public Decimal NetCDN { get; private set; }
        public String Brand { get; private set; }
        public Integer InvMn { get; private set; }
        public integer InvYr { get; private set; }
        public String Curren { get; private set; }
        public String Customer { get; private set; }
       
   public Summary(AggregateResult gr) {
            NetUS = (Decimal) gr.get('NetUS');
            NetCDN = (Decimal) gr.get('NetCDN');
            Brand = (String) gr.get('Brand__c');
            InvMn = (Integer) gr.get('InvMn');
            InvYr = (Integer) gr.get('InvYr');
            Currency = (String) gr.get('Currency_Id__c');
            Customer = (String) gr.get('Customer_Id__c');
        }
    }
 
}
 
Visualforce Page
<apex:page controller="TestController" title="Monthly Net Amount by Customer" >
    <apex:pageBlock title="Monthly Net Amount by Customer">
    <table>
    <tr>
            <td>Customer</td>
            <td>Brand</td>
            <td>Series</td>
            <td>Year</td>
            <td>Month</td>
            <td>Net Sale</td>
    </tr>
   
<apex:repeat value="{!Summaries}" var="summary">
           <tr>
                <td><apex:outputText value="{!summary.Name}"/></td>               
                <td><apex:outputText value="{!summary.Brand}"/></td>
                <td><apex:outputText value="{!summary.Series}"/></td>
                <td><apex:outputText value="{!summary.InvYr}"/></td>
                <td><apex:outputText value="{!summary.InvMn}"/></td>
                <td><apex:outputText value="{!summary.NetUS}" rendered="{!IF(summary.Curren='US',true,false)}"/></td>
                <td><apex:outputText value="{!summary.NetCDN}" rendered="{!IF(summary.Curren='CAD',true,false)}"/></td>
            </tr>
      </apex:repeat>
      </table>
    </apex:pageBlock>
</apex:page>
 
trigger InvoiceSum on Invoice_Items__c (after insert, after update)
    {
     Set<Id> InvIds = new Set<Id>();   
     for(Invoice_Items__c ii :trigger.new)
     { InvIds.add(ii.InvoiceFK__c); }

        List<Invoice__c> InvRecs = [Select id, Ammount__c from Invoice__c where id in : InvIds ];
       
       for(Invoice__c inv : InvRecs)
        {
          //inv.Ammount__c= [Select sum(Invoice_items__r.Amount__c) from Invoice_Items__c ];
           Decimal total=0;
        //   for (Invoice_items__c iit: inc.Invoice_items__c)
          inv.Ammount__c =inv.Invoice_items__r.Amount__c;
            update inv;
        }
     
    }
Invoice__c is parent object and Invoice_item__c is child, I have to sum the all line items amount and display on Invoice__c record. Please help.

Hi,

 

  I want to display the account and related contacts in the same visual force page. Actually i am achieved this like,

i am displayed the account names in first page block and am kept the command link for that account names if we click on that command link that will displayed the contacts related to that particular account in another pageblock. But, Now i want to display the account name first and all related contacts line by line. like that  i want to displat the contacts for all accounts. please any one help me how to solve this...

 

 

example

Maple Lawn Office III
8161 Maple Lawn Blvd
Fulton, MD 20759

Contact: Lydia Chandlee
G & R Management
840 First Street, NE
Washington, DC 20002

Phone: 301-807-0271
Fax: 202-898-0053
Email: 

Contract: No
Inspection Date: 4/6/2010
Inspection Type: Annual
5 Year Test: 2012
Reg/Serial #: HO1863
Service Company: Kone
Equipment Type: Passenger Hydraulic
Annual Price (per unit): $180
Semi-Annual Prince (per unit): $80

Maple Lawn Office III
8161 Maple Lawn Blvd
Fulton, MD 20759

Contact: Lydia Chandlee
G & R Management
840 First Street, NE
Washington, DC 20002

Phone: 301-807-0271
Fax: 202-898-0053
Email: 

Contract: Yes
Inspection Date: 4/6/2010
Inspection Type: Annual
5 Year Test: 2012
Reg/Serial #: HO1863
Service Company: Kone
Equipment Type: Passenger Hydraulic
Annual Price (per unit): $180
Semi-Annual Prince (per unit): $80

 

 

 

thanks,

yamini

  • March 29, 2011
  • Like
  • 0

Quick (hopefully) question. I need to add a specific user to a public group. Ids for both are listed within an object called Fund Document Entitlments, so all I have to do is use those two ids, but I'm not sure how. Here's my code so far:

 

 

public static void AddUserToPublicGroup(List<Fund_Document_Entitlement__c> items){
	Set<Id> portalIds = new Set<Id>();
	Set<Id> publicGroupIds = new Set<Id>();
	for(Fund_Document_Entitlement__c fde : items){
		portalIds.add(fde.Customer_Portal_User_ID__c);
		publicGroupIds.add(fde.Public_Group_ID__c);
	}
		
	List<Group> pgList = [select Id from Group where Id in: publicGroupIds];
	List<User> uList = [select Id from User where Id in: portalIds];
		
	for(Fund_Document_Entitlement__c fde : items){
		for(Group pgroup : pgList){
			for(User u : uList){
				if(fde.Customer_Portal_User_ID__c == u.Id && fde.Public_Group_ID__c == pgroup.Id){
					//what do I put here
				}
			}
		}
	}
}

 Somehow I need to say "add the user with user Id u.Id into group pgroup.Id. How do I do that? Thanks!

 

  • April 07, 2010
  • Like
  • 0