• shailesh_rawte
  • NEWBIE
  • 55 Points
  • Member since 2018

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 2
    Likes Given
  • 1
    Questions
  • 25
    Replies
Hi all, i am new to this so thanks in advance for help. I am struggling to create a test class for my Invocable Method. I just cant get it to work - i keep getting the error Method Does not exist Or incorrect Signature. I know i am doing something wrong. Below is the two classes - 
 
public class PrevetActive4 {

    
@InvocableMethod(label='Get Prevett and update MATT' description='Returns the list of Prevett names corresponding to the specified account IDs.')
  
    public static void getPrevett2(List<Id> Ids) {

       
        List<Prevet_Checklist__c> mt = [Select Name, id,Active_Prevett__c, Open_Closed__c FROM Prevet_Checklist__c WHERE Id in :Ids AND Open_Closed__c = 'Queue' AND OwnerId = '00528000000kb5s' Order by CreatedDate ASC Limit 1];
       
        for (Prevet_Checklist__c one1 : mt) {
            one1.Open_Closed__c = 'Ready';
            one1.Active_Prevett__c = true;
            
            
        }
        update mt ;

}
}
 
@IsTest
private class TEST_Prevett2

{
    private static testMethod void myPrevettTest2() 
    {

     
       Prevet_Checklist__c PV = new Prevet_Checklist__c(Open_Closed__c = 'Queue', Active_Prevett__c = False, OwnerId = '00528000000kb5s');

       Insert PV;
        
       
       PrevetActive4.getPrevett2(PV);

    
       Prevet_Checklist__c result = [Select ID, OwnerId, Open_Closed__c, Name, Active_Prevett__c, Client_Name__c, Name_of_Adviser__c From Prevet_Checklist__c WHERE Open_Closed__c = 'Ready' AND OwnerId = '00528000000kb5s' Order by CreatedDate ASC Limit 1];
       System.assertEquals('Ready', result.Open_Closed__c);
       System.assertEquals(True, result.Active_Prevett__c);



    }
}



Thanks
 
Hello All,

As you know that future not working in Batch or its not be chained.
But in my scenario i can able to call future method from Batch Class.

Regards,
Shailesh Rawte
Hello All,

As you know that future not working in Batch or its not be chained.
But in my scenario i can able to call future method from Batch Class.

Regards,
Shailesh Rawte
I found this amazing open source project that allows inline editing of related lists: https://github.com/peterdesio/SFRelatedListEditor

It works so beautifully so for what I need, but then I hit a big old brick wall today when I realized that it doesn't seem to work in a community. I can add the component in the community detail page and the outer part loads, but no data. I know that the community user has access to the data I am trying to load since I can see it in the regular related list on the same page. Any ideas for how to debug this or what could be causing this difference just in the community?

Thanks for any suggestions!
here i have created two lightning component 
1. OpportunityOnAccount.cmp which shows all opportunity on the accout record page with add Opportunity button
2. OpportunityOfAccount.cmp which shows all opportunity of current account on account record page this component also have Component event handler which is get fired from OpportunityOnAccount.cmp controller
<--! OpportunityComponentContainer.cmp-->
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
	
        <c:OpportunityOnAccount recordId="{!v.recordId}"/>    
    <c:OpportunityOfAccount recordId="{!v.recordId}"/>

</aura:component>
this is my main component which is calling both my component
 
<!--OpportunityOnAccount.cmp-->
<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId" access="global"  controller = 'OpportunityOfContactHandler'>
    <!-- attributes -->
    <aura:attribute name = "allOpportunity" type = "List"/>
    <aura:attribute name="recordId" type="string" />
    <!--Event regster-->
    <aura:registerEvent name = "registerOppOfAcc"  type = "c:OpportunityOfAccountEvt"></aura:registerEvent>
<!-- handlers-->
    <aura:handler name="init" value="{! this }" action="{! c.doInit }"/>
    <aura:handler event="c:searchOppoertunity" action="{!c.handleOpportunitySearchEvent}"  />
<!-- <aura:handler name = "removerIndexOfOpportunity" event = "c:OppIndexRemover" action = "{!c.handleOpportunityRemove}" />
 				-->
        <lightning:card title="All Opportunities on Account" iconName="standard:opportunity" footer="All Opportunity End">
     <div class="slds-box">
        <table>
    	 <thead>
               <tr class="slds-text-heading--label"> 
                   <div class="slds-p-left_small">
                       <th scope="col"><div class="slds-truncate" title="Name">Opportunity Name</div></th>
                   </div>
             </tr>
         </thead>
         <tbody>
            <aura:iteration items="{!v.allOpportunity}" var ="x">
                <tr>
                    <td>
                        <div class="slds-p-top_x-small">
                            <div class="slds-p-left_medium">
                                <div class="slds-truncate" title="">{!x.Name}</div>
                            </div>
                        </div>
                    </td>
                    <td>      
                        <div class="slds-p-top_x-small">
                            <div class="slds-p-left_medium">
                                <div class="slds-truncate" title="">
                                    <lightning:button variant="brand"  label="Add Opportunity" name="Add"  value="{!x}" onclick="{! c.handleRowAction }"/>
                                </div>
                            </div>
                        </div>
                    </td>
                </tr>
             </aura:iteration>
         </tbody>
    </table>
        </div>
    </lightning:card>    
</aura:component>
<!--OpportunityOnAccountController.js-->

({
    doInit: function (component, event, helper) {
     //   var ContactRecordId = component.get("v.recordId");
        helper.fetchData(component);
    },

    handleRowAction: function (cmp, event, helper) {
        var action =  event.getSource().get('v.name');
        var row = event.getSource().get('v.value');

          //alert('Adding Opportunity: ' + JSON.stringify(row));
  			console.log('Adding Row Detail->'+JSON.stringify(row));
                helper.addRecord(cmp,row);
    },
    handleOpportunitySearchEvent: function(cmp, event) { 
    console.log("Searching Opportunities in handler....!");
    var x = event.getParam("searchOpp"); 
        //Set the handler attributes based on event data 
        cmp.set("v.allOpportunity", x);     
    } ,
    handleOpportunityRemove : function (cmp, event, helper) {
        var rows = cmp.get('v.data');
        var indexObj = event.getParam('opportunityObj');
        console.log('Index obj handleOpportunityRemove '+indexObj.Name);
        var rowIndex = rows.indexOf(indexObj);
        rows.splice(rowIndex, 1);
        cmp.set('v.data', rows);
    },
});
<!--OpportunityOnAccountHelper.js-->
({ 
    fetchData: function (component) {
       var action = component.get("c.getAllOpportunityOnAccount");
             // Load all contact data
        action.setCallback(this, function(response) {
            var state = response.getState();
            if (state === "SUCCESS") {
                var result = response.getReturnValue();
                component.set('v.allOpportunity', result);
            }
            else if (state === "INCOMPLETE") {
                alert('Response is Incompleted');
            }
                else if (state === "ERROR") {
                var errors = response.getError();
                if (errors) {
                    if (errors[0] && errors[0].message) {
                        alert("Error message: " + errors[0].message);
                    }
                } else {
                    alert("Unknown error");
                }
            }
        });
        $A.enqueueAction(action);
    },
    addRecord: function(component,row){
                console.log("Add Event fire succsess...! "+row);
        var opportunityOnContacEvt = component.getEvent("registerOppOfAcc");
        opportunityOnContacEvt.setParams({
            opp : row
        });
        opportunityOnContacEvt.fire();
    },
})
<!--OpportunityOfAccount.cmp-->
<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId" access="global" controller = 'OpportunityOfContactHandler'>
  <!--  -->
    <!-- attributes -->
    	<!--List of all the opprtunity-->
     <aura:attribute name="opportunities" type="list"/>
    <aura:attribute name="recordId" type="string" />

    <aura:handler name = "registerOppOfAcc" event = "c:OpportunityOfAccountEvt" action = "{!c.handleOppOfAccEvent}" />

    <aura:registerEvent name = "removerIndexOfOpportunity"  type = "c:OppIndexRemover"></aura:registerEvent>

    <!-- handlers-->
    <aura:handler name="init" value="{! this }" action="{! c.Init }"/>
       {!v.recordId}
    <lightning:card variant="Narrow" title="Account Opportunities" iconName="standard:Opportunity" footer="Opportunity of Current Accountr">
     <div class="slds-box">
		<table>
    	 <thead>
               <tr class="slds-text-heading--label">
                   <div class="slds-p-left_small">
                       <th scope="col"><div class="slds-truncate" title="Name">Opportunity Name</div></th>
                   </div>
             </tr>
         </thead>
         <tbody>
            <aura:iteration items="{!v.opportunities}" var ="x">
                <tr>
                    <td>                   
                        <div class="slds-p-left_medium">
                            <div class="slds-p-top_x-small">
                                <div class="slds-truncate" title="">{!x.Name}</div>
                            </div>
                        </div>
                    </td>
                    <td>
                        <div class="slds-p-top_x-small">
                            <div class="slds-truncate" title="">
                                <lightning:button variant="brand"  label="Remove Opportunity" name="delete"  value="{!x}" onclick="{! c.handleRowAction }" />
                            </div>
                        </div>
                    </td>
                </tr>
                <tr><td>  <p></p></td></tr>
  
             </aura:iteration>
         </tbody>
    </table>
        </div>
    </lightning:card>
</aura:component>
<!--OpportunityOfAccountController.js-->
({
    Init: function (component, event, helper) {
       
        var AccountRecordId = component.get("v.recordId");
        console.log('ID RECORD->'+AccountRecordId);
    //     component.set('v.opportunities', component.get("v.opportunities").splice(0,component.get("v.opportunities").length));
        helper.fetchData(component, AccountRecordId);
    },

    handleRowAction: function (cmp, event, helper) {
		console.log("On row Action...!");
        var action =  event.getSource().get('v.name');
        var row =  event.getSource().get('v.value');
        console.log('Date : '+JSON.stringify(row)+' Action : '+action);
                helper.removeOpportunity(cmp, row);
         },
    handleOppOfAccEvent: function(Component,event,helper)    {
        console.log('Here Handeling Event...!');
        var AccountRecordId = Component.get("v.recordId");
         var Opp = event.getParam('opp');
         helper.updateOpportunity(Component,Opp,AccountRecordId);
        console.log('My Data -> '+Opp.Name+' RecordId -> '+ AccountRecordId);
        
      /*   var removeOpportunity = Component.getEvent("removerIndexOfOpportunity");
        removeOpportunity.setParams({
            opportunityObj : Opp
        });
        removeOpportunity.fire();
        */

    }
});
<!--OpportunityOFAccountHelper.js-->
({
    removeOpportunity: function (cmp, row) {
        var rows = cmp.get('v.opportunities');
        var rowIndex = rows.indexOf(row);
        rows.splice(rowIndex, 1);
        cmp.set('v.opportunities', rows);
    },
        fetchData: function (component, AccountRecordId) {
       var action = component.get("c.getOpportunityOfAccount");
             // Load all contact data
             console.log('Record Id '+AccountRecordId);
        action.setParams({"acccountId" : AccountRecordId});
            
        action.setCallback(this, function(response) {
            var state = response.getState();
            if (state === "SUCCESS") {
                //Set event attribute value
             	  var result = response.getReturnValue();
                console.log("Return Result... "+response.getReturnValue());
                  component.set('v.opportunities',result );
            }
            else if (state === "INCOMPLETE") {
                alert('Response is Incompleted');
            }
                else if (state === "ERROR") {
                var errors = response.getError();
                if (errors) {
                    if (errors[0] && errors[0].message) {
                        alert("Error message: " + errors[0].message);
                    }
                } else {
                    alert("Unknown error");
                }
            }
        });
        $A.enqueueAction(action);
    },
     updateOpportunity: function (Component,Opp,AccountRecordId) {
         console.log('Updating Opportunity....! '+Opp.Id+' '+AccountRecordId+' Stringfy ->'+JSON.stringify(AccountRecordId));
       var action = Component.get("c.updateOpportunity");
       action.setParams( 
           {accouhtId : AccountRecordId,
            oppObj : Opp.Id}
       );
           
       action.setCallback(this, function(response) {
            var state = response.getState();
            if (state === "SUCCESS") {
				  var oldOpp=Component.get("v.opportunities");
    		oldOpp.push(response.getReturnValue());
        	Component.set("v.opportunities", oldOpp);
                console.log('update Succsess....!'+response.getState());
             	console.log('Updated Object-> '+JSON.stringify(response.getReturnValue()));
             
              
            }
            else if (state === "INCOMPLETE") {
                alert('Response is Incompleted');
            }
                else if (state === "ERROR") {
                var errors = response.getError();
                if (errors) {
                    if (errors[0] && errors[0].message) {
                        alert("Error message: " + errors[0].message);
                    }
                } else {
                    alert("Unknown error");
                }
            }
        });
        $A.enqueueAction(action);
    },
    
    
})
<!--EVENT-->
<aura:event type="COMPONENT">
    <aura:attribute name = 'opp' type = 'Object'/>    
</aura:event>

After adding into Account page

User-added imageEvent is firing but it is not handeling in another component 
so plase help me with that 
what is the problem with that 
is it because of my container component ?

and when i use two seperate component why it doesn't work with component event 



 
I have created a trigger for Order Object and only want specific fields to be pulled from that object to creat a custom JSON data structure. I have tried saving the fields that I need from the object into local variables, placing them into a list and then serializing them but the output is wrong. The curly brackets are missing and commas are not being added in the proper locations. Please reference my code below.
 
trigger ActiveOrder on Order (after insert, after update) 
{
            
/***********************************************************************/
/*          *Order Object* variables decleration Start:			   	   */ 
/***********************************************************************/

   	private String ordAccountId;
    private String ordBillingStreet;
    private String ordBillingCity;
    private String ordBillingState;
    private String ordBillingPostalCode;
    private String ordBillingCountry;
    private String ordDescription;
    private Double ordTotalAmount;
    private String ordOrderNumber;
    private String ordShipToContact;
    private String ordShipToMethod;
    private String ordShippingStreet;
    private String ordShippingCity;
    private String ordShippingState;
    private String ordShippingPostalCode;
    private String ordShippingCountry;
    private String ordBillToAttn;
    private String ordCustomerPO;
    private String ordShipToAttn;
            
/***********************************************************************/
/*  		*Order Object* variables declearation End:				   */ 
/***********************************************************************/

    for(Order o : Trigger.New)
    {
        
        If(o.Status == 'Activated')
        {
            
            ordAccountId = o.AccountId;
            ordBillingStreet = o.BillingStreet;
            ordBillingCity = o.BillingCity;
            ordBillingState = o.BillingState;
            ordBillingPostalCode = o.BillingPostalCode;
            ordBillingCountry = o.BillingCountry;
            ordDescription = o.Description;
            ordTotalAmount = o.TotalAmount;
            ordOrderNumber = o.OrderNumber;
            ordShipToContact = o.Ship_To_Name__c;
            ordShippingStreet = o.ShippingStreet;
            ordShippingCity = o.ShippingCity;
            ordShippingState = o.ShippingState;
            ordShippingPostalCode = o.ShippingPostalCode;
            ordShippingCountry = o.ShippingCountry;
            ordBillToAttn = o.BillToAttn__c;
            ordCustomerPO = o.Customer_PO__c;
            ordShipToAttn = o.Ship_to_Attention__c;
            
            
            List<String> ordInvoice = new List<String>();
            

			ordInvoice.add('Account Id: ' + ordAccountId + ', ' 
                           + 'Billing Street: ' + ordBillingStreet + ', ' 
                           + 'Billing City: ' + ordBillingCity + ', ' 
                           + 'Billing State: ' + ordBillingState + ', ' 
                           + 'Billing Postal Code: ' + ordBillingPostalCode + ', ' 
                           + 'Billing Country: ' + ordBillingCountry + ', ' 
                           + 'Description: ' + ordDescription + ', ' 
                           + 'Total Amount: ' + ordTotalAmount + ', ' 
                           + 'Order Number: ' + ordOrderNumber + ', ' 
                           + 'Ship To Contact: ' + ordShipToContact + ', ' 
                           + 'Shippin Street: ' + ordShippingStreet + ', ' 
                           + 'Shipping City: ' + ordShippingCity + ', ' 
                           + 'Shipping State: ' + ordShippingState + ', ' 
                           + 'Shipping Postal Code: ' + ordShippingPostalCode + ', ' 
                           + 'Shipping Country: ' + ordShippingCountry + ', ' 
                           + 'Bill To Attn: ' + ordBillToAttn + ', ' 
                           + 'Customer PO: ' + ordCustomerPO + ', ' 
                           + 'Ship To Attn: ' + ordShipToAttn);

            System.debug('Pre JSON: ' + ordInvoice);
            
            
            String ordInvoiceJSON = JSON.serialize(ordInvoice);
            
            System.debug('Post JSON: ' + ordInvoice);
            System.debug('Post JSON: ' + ordInvoicePostJSON);

            
        }
    }
}

Any help would be much appreciated. Thank you all in advance.
Hi,
Can anyone please help me here:
User-added image

My task is to remove this workflow and create the process builder with same condition. Problem here is with Owner, Case Owner Can be a user or Queue, in workflow condition we are checking the Case owner's name but we have to check this only when owner is Queue.
I have tried to implement this using following way:
 
AND(ISPICKVAL([Case].Status , 'Open') ,[Case].CaseRecordTypeName__c = 'Global Lead Management Intake' ,IF(BEGINS([Case].OwnerId, '00G')  ,IF([Case].Owner:Queue.DeveloperName <> 'GBL_Case_Management_Queue', True, False) , True) )

But it did not worked for me, can anyone please help me to get the exact formula.

Thanks,
Rahul
 

      Public static Void  territoryFinancialsDj(List<Territory_Plan__c> tpe){
           Set<Id> ownerIds =New set<Id>();
           List<Event> evtList = new List<Event>();
           List<Territory_Plan__c > ObjectRec = new List<Territory_Plan__c >(); 
           List<Territory_Plan__c > tpList = new List<Territory_Plan__c >(); 
           List<Territory_Plan__c > ObjectBList = new List<Territory_Plan__c >(); 
            List<Opportunity> oppoList = new List<Opportunity>();
  
           For(Territory_Plan__c t:tpe){
               ownerIds.add(t.Account_Executive__c);
           }
           
           Map<Id, Opportunity> oppoMap = new Map<Id, Opportunity>([SELECT Id, StageName, ownerId FROM Opportunity WHERE OwnerId IN : ownerIds]);
           evtList = [SELECT Id, WhatId, Status__c, Type, ownerId FROM Event WHERE Status__c='Completed' AND Type='On-Site at PSCU' AND ownerID IN:ownerIds ];
               for(Territory_Plan__c tp:tpe){
                               for(Event e: evtList){
                   if(tp.Account_Executive__c==e.ownerId && oppoMap.containsKey(e.WhatId) && tp.Account_Executive__c==oppoMap.get(e.WhatId).ownerId){
                       oppoList.add(oppoMap.get(e.WhatId));
                     
                   }
               }    
             tp.of_Onsite_at_PSCU_YTD__c = oppoList.size();
               tpList.add(tp);
               
           }
           
      }
      
hi i am a beginner in salesforce.i have a requirement . there are 2 sections in a vf page .in first section there is only one input textbox which takes values for a country field . and a button called "add" once this button is clicked in the backend it has to add the value in country textbox to a selectlist. so how many times we click on add button those many values must be added to select list.there is another button submit. once submit button is clicked the country list must be displayed in 2nd pageblock section . how can i achieve this

vf page code is :
<apex:page Controller="selectlistoption">
    <apex:form >
    <apex:pageBlock >
        <apex:pageBlockSection >
        
            <apex:outputlabel value="Enter Country"/>
            <apex:inputText value="{!str}"/>
            <apex:commandButton value="Add" action="{!setCountry}"/> 
            <apex:commandButton value="submit" rerender="showdetails"/>
        </apex:pageBlockSection>    
        
    <apex:pageBlockSection id="showdetails">
        
            <apex:selectlist size="1" value="{!str}">
           
                <apex:selectoptions value="{!country}"/>
                 </apex:selectlist>
        
 
        
        </apex:pageBlockSection>
                    </apex:pageBlock>
    </apex:form>
 
</apex:page>

------------------------------------------------------------------------apex code -------------------------------------------------------------
public class selectlistoption {
    
    
      public   string str{get;set;}
    

   public  list<selectoption> country{get;set;}
    
    public void setCountry()
    {
         
        country.add(new selectoption(str,str));
       
    }
    
   

}
 
apex class :
public with sharing class EnrollmentFormClass {
public Contact con {get;set;}
public Contact conc {get;set;}
public Contact conct {get;set;}
public List<Contact> concAddList{get;set;}
public Account acc {get;set;}
    
public EnrollmentFormClass() {
     con  = new Contact();
     conc = new Contact();
     conct = new Contact();
     acc  = new Account();
     concAddList  = new List<Contact>();  
     //concAddList.add(con);
     }
    public void AddRow(){
        conct = new Contact();
        concAddList.add(conct);
        //concAddList.add(new Contact());
    }
public void save(){
    insert con;    
    acc.name = con.lastName;
    insert acc;
    con.AccountId = acc.Id;
    conc.AccountId = acc.Id;
    conct.AccountId = acc.Id;
    
    insert conc;
    insert conct;
    insert concAddList;
    update con;
   
    }
     
}
visualforcepage :

<apex:page controller="EnrollmentFormClass">
    <apex:form >
    <apex:pageBlock title="Opportunitiy Zone Enrollment Form">
              <apex:pageBlockSection columns="3">
              <apex:inputField value="{!con.Student_Name__c}"/>
              <apex:inputField value="{!con.School__c}"/> 
              <apex:inputField value="{!con.Date__c}"/> 
            </apex:pageBlockSection>
            <br/> 
            <br/>
                    SPARC programs are funded by United Way of Greater Atlanta. As such, we are required to report demographic, income, educational and health access information on every individual/family we serve. With the United Way belief that serving one family member serves them all, we collect general information on each member of your household. We appreciate your willingness to complete this form in its entirety so that we can continue providing free programs to the community. Thank you!
            <br/>  
            <br/> 
            <apex:pageBlockSection title="Head of Household Information:">
                <apex:inputField value="{!con.FirstName}"/>
                <apex:inputField value="{!con.LastName}"/>
                <apex:inputField value="{!con.Date_of_Birth__c}"/>
                <apex:inputField value="{!con.Gender__c}"/> 
                <apex:inputField value="{!con.Do_you_have_a_primary_medical_provider__c}"/>
                <apex:inputField value="{!con.Do_you_have_a_primary_medical_provider__c}"/>
                <apex:inputField value="{!con.Address__c}"/>
                <apex:inputField value="{!con.City__c}"/>
                <apex:inputField value="{!con.State__c}"/>
                <apex:inputField value="{!con.County__c}"/>
                <apex:inputField value="{!con.Phone__c}"/>
                <apex:inputField value="{!con.Email_Address__c}"/>
                <apex:inputField value="{!con.Preferred_Method_of_Contact_Circle_One__c}"/>
            </apex:pageBlockSection>
            <apex:pageBlocksection title="Demographic Data: (All information is confidential and is used in applying for grants to fund this program.)" columns="3">
                 <apex:inputField value="{!con.Spanish_translation_Services_Needed__c}"/>
                 <apex:inputField value="{!con.Race_Check_One__c}"/>
                 <apex:inputField value="{!con.Marital_Status_check_one__c}"/>
                 <apex:inputField value="{!con.HIGHEST_LEVEL_OF_EDUCATION_Check_one__c}"/>
                 <apex:inputField value="{!con.Employment_check_one__c}"/>
            </apex:pageBlocksection>
            <apex:pageBlocksection title="Income:" columns="3">
                <apex:inputField value="{!con.Annual_Income__c}"/> 
                <apex:inputField value="{!con.Source_of_Income__c}"/> 
                <apex:inputField value="{!con.Primary_Method_of_Transportation__c}"/>
            </apex:pageBlocksection>
            <apex:pageBlocksection title="HOUSEHOLD Information:" columns="3">
                <apex:inputField value="{!conc.Other_Adult_First_Name__c}"/>
                <apex:inputField value="{!conc.LastName}"/>
                <apex:inputField value="{!conc.Date_of_Birth__c}"/>
                <apex:inputField value="{!conc.Gender__c}"/> 
                <apex:inputField value="{!conc.Relationship_Primary_Care_Provider__c}"/>
                <apex:inputField value="{!conc.Medical_Insurance__c    }"/> 
            </apex:pageBlocksection>
                <apex:pageBlockButtons location="bottom" >
                <apex:commandButton action="{!save}" value="save"/>
            </apex:pageBlockButtons> 
            <apex:pageBlocksection title="Children (all children currently in your household, INCLUDING those participating in this program):" columns="1">
             <apex:pageBlockTable value="{!conct}" var="c">
             <apex:column headerValue="Name">
             <apex:commandButton action="{!AddRow}" value="AddRow"/>
             </apex:column>
             <apex:column headerValue="Name">
             <apex:inputfield value="{!c.LastName}"/>  
             </apex:column> 
             <apex:column headerValue="Date of Birth">
             <apex:inputfield value="{!c.Date_of_Birth__c}"/>
             </apex:column>
             <apex:column headerValue="Gender">
             <apex:inputfield value="{!c.Gender__c}"/>
             </apex:column>
             <apex:column headerValue="Relationship Primary Care Provider">
             <apex:inputfield value="{!c.Relationship_Primary_Care_Provider__c}"/>
             </apex:column>
             <apex:column headerValue="Medical Insurance">
             <apex:inputfield value="{!c.Medical_Insurance__c}"/>
             </apex:column>             
       </apex:pageBlockTable> 
       </apex:pageBlocksection>
       </apex:pageBlock>
    </apex:form>
</apex:page>
  • February 13, 2018
  • Like
  • 0
Hi Team,

After delete & update code not covered in trigger. please give me any idea about this requirement.

Trigger:
----------
trigger FinancialsCountTrigger on Financials__c (after insert, after update, after delete, after undelete) {
    
    if(checkRecursive.runOnce()){
        
        List<Account> updateAcc = new List<Account>();
        Set<Id> accid = new Set<Id>();
        
        Decimal totalRevenue;
        Decimal totalEBITDA;
        
        if(Trigger.isAfter && (Trigger.isInsert || Trigger.isUpdate || Trigger.isUndelete)){
            for(Financials__c fin : Trigger.New){
                if(fin.AccountName__c != null){
                    accid.add(fin.AccountName__c);
                }
            }
        }
        
        if(Trigger.isAfter && (Trigger.isUpdate || Trigger.isDelete)){
            for(Financials__c fin : Trigger.Old){
                if(fin.AccountName__c != null){
                    accid.add(fin.AccountName__c);
                    //system.debug('-----'+accid);
                }
            }
        }
        
            if(accid.size() > 0){
            List<Account> acclist = [select id,Name,Global_Revenue_Total__c,Global_EBITDA_B4_Total__c,
                                     (select id,Global_Revenue_Total__c,Global_EBITDA_B4_Total__c from Financial__r) from Account where id in :accid];
            
            for(Account acc : acclist){
                
                
                List<AggregateResult> aggres = [Select sum(Global_Revenue_Total__c)revtot,sum(Global_EBITDA_B4_Total__c)ebitdatot
                                                from Financials__c where AccountName__c=:acc.id and Year__c='FY-2017'];
                for(AggregateResult ag : aggres){
                    totalRevenue = (Decimal)ag.get('revtot');
                    totalEBITDA = (Decimal)ag.get('ebitdatot');
                }
                acc.Global_Revenue_Total__c = totalRevenue;
                acc.Global_EBITDA_B4_Total__c = totalEBITDA;
                updateAcc.add(acc);
            }
          }
          update updateAcc;
        
    }
    
}
Test Class
-----------------
@isTest
public class TestFinancialsCountTrigger {
    
    public static testMethod void financialCount(){
        
        Account acc = new Account(Name='3M Corporation',Industry='Conglomerate');
        insert acc;
        
        Account acc2 = new Account(Name='3M Corporation2',Industry='Conglomerate');
        insert acc2;
        
        Financials__c fin = new Financials__c(AccountName__c=acc.id,Name='Test',Year__c='FY-2017',Global_Revenue_Total__c=100,Global_EBITDA_Total__c=200);
        insert fin;
        
        Financials__c fin2 = new Financials__c(AccountName__c=acc2.id,Name='Test2',Year__c='FY-2017',Global_Revenue_Total__c=500,Global_EBITDA_Total__c=400);
        insert fin2;
        
        fin.Global_Revenue_Total__c = 500;
        update fin;
        delete fin;
                
        Test.startTest();
        
        List<Financials__c> finlist = [select id from Financials__c where AccountName__c = :acc.Id and Year__c='FY-2017'];
        delete finlist;
        
        Test.stopTest();
        
        
    }

}
Please give me reply any one......

Regards
Lakshmi

 
I need help with making 2 custom fields created to be required if the Do not create Opp checkbox is not checked. If it is checked then the 2 fields shud be required. I also need to map the value of these fields to 2 custom fields in Opportunity. Code from Class below : 
 
public with sharing class ConvertLeadExtn
{
    Final Lead curLead;
    public boolean IsSendEmailChecked{get;set;}
    public String SelectedAccType{get;set;}
    public Contact ContactAcctToRefer{get;set;}
    public boolean IsOppChecked{get;set;}
    public String SelectedConvrtdStatus{get;set;}
    
    //Returns the list of account types
    public list<selectOption> lstAccountType
    {
        get
        {
            List<selectOption> lstAcctType = new List<selectOption>();
            lstAcctType.add(new selectOption('','--None--'));
            lstAcctType.add(new selectOption('Create New Account','Create New Account'));
            lstAcctType.add(new selectOption('Attach to Existing','Attach to Existing'));
            return lstAcctType;
        }
        set;
    }
    
    // Returns the converted Status list
    public List<selectOption> lstConvertedStatusList
    {
        get
        {
            List<selectOption> lstConvertedStatus = new List<selectOption>();
            LeadStatus leadStatus = [Select Id, MasterLabel from LeadStatus where IsConverted=true limit 1];
            lstConvertedStatus.add(new selectOption(leadStatus.MasterLabel,leadStatus.MasterLabel));
            return lstConvertedStatus;
        }
        set;
    }
     
    //Controller
    public ConvertLeadExtn(ApexPages.StandardController controller)
    {
        this.curLead = (Lead)controller.getRecord();
        if(curLead.Id!=null)
        {
            ContactAcctToRefer = new Contact();
        }
    }
           
    //Converts the Lead
    public PageReference ConvertLead()
    {
        Id accountId;
        PageReference accPage;
        try
        {
            Database.LeadConvert leadCnvrt = new database.LeadConvert();
            if(SelectedAccType == null || SelectedAccType =='')
            {
                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'Please Select Account Type!'));
                return null;
            }
            
            //Sets all the fields that are required
            leadCnvrt.setLeadId(curLead.Id);
            leadCnvrt.setOwnerId(curLead.OwnerId);
            leadCnvrt.setSendNotificationEmail(IsSendEmailChecked);            
            leadCnvrt.setDoNotCreateOpportunity(IsOppChecked);
            leadCnvrt.setConvertedStatus(SelectedConvrtdStatus);
           
            if(SelectedAccType == 'Attach to Existing')
            {
                if(ContactAcctToRefer.accountId !=null)
                {
                    leadCnvrt.setAccountId(ContactAcctToRefer.accountId);
                }
                else
                {
                    ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'Please Select Existing account to attach!'));
                    return null;
                }
            }
            
            if(!leadCnvrt.isDoNotCreateOpportunity())
            {
                leadCnvrt.setOpportunityName(curLead.Company);
            }
            
            Database.LeadConvertResult leadCnvrtResult = Database.convertLead(leadCnvrt);
            accountId=leadCnvrtResult.getAccountId();
            System.assert(leadCnvrtResult.isSuccess());
        }
        catch(exception excptn)
        {
            String excptnMsg = excptn.getMessage();
                     
            if(excptnMsg.contains('CANNOT_UPDATE_CONVERTED_LEAD') || excptnMsg.contains('INVALID_CROSS_REFERENCE_KEY'))
            {
                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'Lead Conversion Failed! Lead is already converted!'));
            }
            else if(excptnMsg.contains('TRANSFER_REQUIRES_READ'))
            {
                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'Opportunity can not be created, User do not have Read Permission!'));
            }
            else
            {
                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,excptn.getMessage()));
            }
        }
        if(accountId!=null)
        {
            accPage = new pageReference('/'+accountId);
        }
        return accPage;
    }
}

 
I would like the user to see the number of notifications sent and the latest date. The date stamp is working fine but the number stamp isn't working. I have set the default value to 0 for the number field on case and the field update formula calls the field and adds 1 -  PRIORVALUE (Number_of_Dealer_Reminders_Sent__c) + 1. The problem is that the number field does not update nor does it show the default (0). Please help - is it maybe the way formula when setting the default? Basically I have 0 in the formula field - custom.
 
Error:Apex trigger InquiryTrigger caused an unexpected exception, contact your administrator: InquiryTrigger: execution of AfterUpdate caused by: System.QueryException: List has no rows for assignment to SObject: Class.InquiryTriggerHandler.InquiryHandler: line 13, column 1

How do I fix this issue?

 
public class InquiryTriggerHandler {
    
    public static void InquiryHandler(string caseid){
       
        
        
        
        
        Case cs=[SELECT id,OwnerId,ContactID,Confirmation_Email__c,ContactEmail From Case WHERE id=:caseid];
        
        system.debug('CaseID: '+caseid);
        
        user u=[select id,email from user where id=:cs.ownerid];
        
        system.debug('User Email: '+u.email);
        
        system.debug('Confirmation Mail: '+cs.Confirmation_Email__c);
        
        system.debug('Contact Email: '+cs.ContactEmail);
        
        List<Messaging.SingleEmailMessage> lsem=new List<Messaging.SingleEmailMessage>();
        
        Messaging.SingleEmailMessage sem=new Messaging.SingleEmailMessage();
        
        List<String> address=new List<String>();
        
        //address.add(u.email);
        
        address.add(cs.Confirmation_Email__c);
        
        address.add(cs.contactemail);
        
        address.add('siddharth.koduri@gmail.com');
        
        sem.setToAddresses(address);
        
        sem.setCcAddresses(new string[]{u.email});

        //sem.setSubject('testing');
        
        //sem.setplaintextbody('jjjj');
        EmailTemplate et=[SELECT id,Name FROM EmailTemplate WHERE name='Email Confirmation Template II'];
        
        sem.setTemplateId(et.id);
        
        sem.setTargetObjectId(cs.contactId);
        
        sem.setWhatId(cs.id);
        
       
       OrgWideEmailAddress owd=[SELECT id,Address FROM OrgWideEmailAddress WHERE Address=:system.label.Taconic_Mail_id];
       
       sem.setOrgWideEmailAddressId(owd.id);
        
        
       List<Attachment> att=[SELECT id,Name,Body,ContentType FROM Attachment WHERE ParentID=:caseid];
        
        List<Messaging.EmailFileAttachment> lefa=new List<Messaging.EmailFileAttachment>();
        
        for(Attachment a:att){
            
            Messaging.EmailFileAttachment efa=new Messaging.EmailFileAttachment();
            string contentvalue=(a.contentType).substringAfter('/');
            efa.setBody(a.body);
                efa.setFileName(a.Name);
            lefa.add(efa);
            
        } 
   
        sem.setFileAttachments(lefa); 
          
        
        
        lsem.add(sem);
            
        messaging.sendEmail(lsem);
    
        
        
    }
}

 
  • February 07, 2018
  • Like
  • 0
Hi. I've tried a few things, but I'm not getting the result that I'm hoping for. I'm trying to extract a fixed length string from a substring. Problem is that the string I'm looking for is not always in the same position in the substring. For example, see the string below. I want to extract "ECN_nnnn" from this. However, the letters "ECN_" isnt always in the same spot.  There will always be 4 characters to the right of "ECN_"

DOCUMENT APPROVAL: ECN_1053 - Auto Refractors Portuguese Labeling for Brazil

I think I'm using FIND and RIGHT, but cant get the syntax right. Thanks!
For system admin itself not working:
code:Trigger:
if(trigger.isafter && trigger.isinsert)
    {
        User_Case__Share userCaseShare=new User_Case__Share();
        User_case__c newUC=[SELECT Id, OwnerId FROM User_Case__c where id =:trigger.new];
        handler.shareUserCaseRec(newUC.Id,newUC.OwnerId);
    }

Hanlder class:
public class USRetail_StatusTypeChangeHandler {

    public void shareUserCaseRec(ID recordIDUC,ID UserOrGroupIdUC)
    {
         User_Case__Share userCaseShare=new User_Case__Share();
        userCaseShare.ParentId=recordIDUC;
        //userCaseShare.RowCause='Manual';
        userCaseShare.UserOrGroupId=UserOrGroupIdUC;
        userCaseShare.AccessLevel='Edit';
        insert userCaseShare;
    }
}
I am getting the above error. My requirement is to change the currency field data, if opportunity already having child quote records. So its not possible through standard . Thus I am working out for custom solution. Earlier its was working on clicking cancel it use to create clonned opportunity but now its not working now on create and on cancel both.

Apex:-


public with sharing class CloneOpportunityExtension {
    //to get opp id from url
    public String recId {get;set;}
    // for new currency and name
    public Opportunity cloneOpp {get;set;}
    
    public CloneOpportunityExtension(ApexPages.StandardController stdCon) {
        cloneOpp = new Opportunity();
        recId = null;
        recId = ApexPages.currentPage().getParameters().get('id'); 
        System.debug('recId'+recId);
        if(recId!=null) {
            // setting the currency on page load
            cloneOpp.CurrencyIsoCode = ((opportunity)stdCon.getRecord()).CurrencyIsoCode;
            // setting Name
            cloneOpp.Name = ((opportunity)stdCon.getRecord()).Name;
            

//setting Account Name
// cloneOpp.Account= ((opportunity)stdCon.getRecord()).Account;
        } else {
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, ' '+Label.select_a_vaild_Opportunity));
        }
    }
   
    /**
    * to save the Clone Opportunity with New Currency
    * 
    */
    public PageReference saveNewOpp(){   
        PageReference pRef = null;
        if(recId!=null) {
            if(cloneOpp!=null) {
                try{
                    // calling clone class
                    String returnId = null;
                    returnId = Cls_CloneOptyRelated.CloneOpportunity(recId, cloneOpp.CurrencyIsoCode, cloneOpp.Name);
                    if(returnId!=null) {
                        pRef = new PageReference('/'+returnId);
                        pRef.setRedirect(true);
                    }
                    else {
                       ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, ' '+Label.Issue_in_Cloning));
                    }
                }
                catch(Exception e) {
                    ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR, ' ' + Label.Issue_in_Cloning + ' ' + e.getMessage()));
                }
            }
        }
        return pRef;
    }
}


Visualforce Page:-

<apex:page standardController="Opportunity" extensions="CloneOpportunityExtension" tabStyle="Opportunity" title="{!$ObjectType.Opportunity.Label} {!$Label.Clone}">
<apex:sectionHeader subtitle="{!Opportunity.Name}" title="{!Opportunity.Name} {!$Label.Clone}" rendered="{!recId != null}"/>
<apex:form >
<apex:pageMessages >
</apex:pageMessages>
<apex:pageBlock title="{!$ObjectType.Opportunity.Label} {!$Label.Clone}">
<apex:pageBlockButtons location="bottom">
<apex:commandButton action="{!saveNewOpp}" value="{!$Label.Clone}" rendered="{!recId != null}"/>
<apex:commandButton action="{!cancel}" value="{!$Label.Cancel}" rendered="{!recId != null}"/>
<apex:outputPanel rendered="{!recId == null}"> <input type="button" name="{!$Label.Back}" value="{!$Label.Back}" class="btn" onclick="window.top.location='/006/o';"/>
</apex:outputPanel>
</apex:pageBlockButtons>
<apex:pageBlockSection columns="1">
<apex:inputField value="{!cloneOpp.Name}" label="{!$ObjectType.Opportunity.fields.Name.Label}"/>
<apex:inputField value="{!cloneOpp.CurrencyIsoCode}" label="{!$ObjectType.Opportunity.fields.CurrencyIsoCode.Label}"/>
<!--- <apex:inputField value="{!cloneOpp.Account.Name}" label="{!$ObjectType.Opportunity.fields.Account.Name.Label}"/> ----> </apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>

Errorr Message:-

Errors

Parent Opportunity: Value does not exist or does not match filter criteria.
Issue in cloning Opportunity, Please Contact System Administrator Insert failed. First exception on row 0; first error: FIELD_FILTER_VALIDATION_EXCEPTION, Value does not exist or does not match filter criteria.: [CBG_Parent_Opportunity__c]
I need help with making 2 custom fields created to be required if the Do not create Opp checkbox is not checked. If it is checked then the 2 fields shud be required. I also need to map the value of these fields to 2 custom fields in Opportunity. Code from Class below : 
 
public with sharing class ConvertLeadExtn
{
    Final Lead curLead;
    public boolean IsSendEmailChecked{get;set;}
    public String SelectedAccType{get;set;}
    public Contact ContactAcctToRefer{get;set;}
    public boolean IsOppChecked{get;set;}
    public String SelectedConvrtdStatus{get;set;}
    
    //Returns the list of account types
    public list<selectOption> lstAccountType
    {
        get
        {
            List<selectOption> lstAcctType = new List<selectOption>();
            lstAcctType.add(new selectOption('','--None--'));
            lstAcctType.add(new selectOption('Create New Account','Create New Account'));
            lstAcctType.add(new selectOption('Attach to Existing','Attach to Existing'));
            return lstAcctType;
        }
        set;
    }
    
    // Returns the converted Status list
    public List<selectOption> lstConvertedStatusList
    {
        get
        {
            List<selectOption> lstConvertedStatus = new List<selectOption>();
            LeadStatus leadStatus = [Select Id, MasterLabel from LeadStatus where IsConverted=true limit 1];
            lstConvertedStatus.add(new selectOption(leadStatus.MasterLabel,leadStatus.MasterLabel));
            return lstConvertedStatus;
        }
        set;
    }
     
    //Controller
    public ConvertLeadExtn(ApexPages.StandardController controller)
    {
        this.curLead = (Lead)controller.getRecord();
        if(curLead.Id!=null)
        {
            ContactAcctToRefer = new Contact();
        }
    }
           
    //Converts the Lead
    public PageReference ConvertLead()
    {
        Id accountId;
        PageReference accPage;
        try
        {
            Database.LeadConvert leadCnvrt = new database.LeadConvert();
            if(SelectedAccType == null || SelectedAccType =='')
            {
                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'Please Select Account Type!'));
                return null;
            }
            
            //Sets all the fields that are required
            leadCnvrt.setLeadId(curLead.Id);
            leadCnvrt.setOwnerId(curLead.OwnerId);
            leadCnvrt.setSendNotificationEmail(IsSendEmailChecked);            
            leadCnvrt.setDoNotCreateOpportunity(IsOppChecked);
            leadCnvrt.setConvertedStatus(SelectedConvrtdStatus);
           
            if(SelectedAccType == 'Attach to Existing')
            {
                if(ContactAcctToRefer.accountId !=null)
                {
                    leadCnvrt.setAccountId(ContactAcctToRefer.accountId);
                }
                else
                {
                    ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'Please Select Existing account to attach!'));
                    return null;
                }
            }
            
            if(!leadCnvrt.isDoNotCreateOpportunity())
            {
                leadCnvrt.setOpportunityName(curLead.Company);
            }
            
            Database.LeadConvertResult leadCnvrtResult = Database.convertLead(leadCnvrt);
            accountId=leadCnvrtResult.getAccountId();
            System.assert(leadCnvrtResult.isSuccess());
        }
        catch(exception excptn)
        {
            String excptnMsg = excptn.getMessage();
                     
            if(excptnMsg.contains('CANNOT_UPDATE_CONVERTED_LEAD') || excptnMsg.contains('INVALID_CROSS_REFERENCE_KEY'))
            {
                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'Lead Conversion Failed! Lead is already converted!'));
            }
            else if(excptnMsg.contains('TRANSFER_REQUIRES_READ'))
            {
                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'Opportunity can not be created, User do not have Read Permission!'));
            }
            else
            {
                ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,excptn.getMessage()));
            }
        }
        if(accountId!=null)
        {
            accPage = new pageReference('/'+accountId);
        }
        return accPage;
    }
}

 
Hi all, i am new to this so thanks in advance for help. I am struggling to create a test class for my Invocable Method. I just cant get it to work - i keep getting the error Method Does not exist Or incorrect Signature. I know i am doing something wrong. Below is the two classes - 
 
public class PrevetActive4 {

    
@InvocableMethod(label='Get Prevett and update MATT' description='Returns the list of Prevett names corresponding to the specified account IDs.')
  
    public static void getPrevett2(List<Id> Ids) {

       
        List<Prevet_Checklist__c> mt = [Select Name, id,Active_Prevett__c, Open_Closed__c FROM Prevet_Checklist__c WHERE Id in :Ids AND Open_Closed__c = 'Queue' AND OwnerId = '00528000000kb5s' Order by CreatedDate ASC Limit 1];
       
        for (Prevet_Checklist__c one1 : mt) {
            one1.Open_Closed__c = 'Ready';
            one1.Active_Prevett__c = true;
            
            
        }
        update mt ;

}
}
 
@IsTest
private class TEST_Prevett2

{
    private static testMethod void myPrevettTest2() 
    {

     
       Prevet_Checklist__c PV = new Prevet_Checklist__c(Open_Closed__c = 'Queue', Active_Prevett__c = False, OwnerId = '00528000000kb5s');

       Insert PV;
        
       
       PrevetActive4.getPrevett2(PV);

    
       Prevet_Checklist__c result = [Select ID, OwnerId, Open_Closed__c, Name, Active_Prevett__c, Client_Name__c, Name_of_Adviser__c From Prevet_Checklist__c WHERE Open_Closed__c = 'Ready' AND OwnerId = '00528000000kb5s' Order by CreatedDate ASC Limit 1];
       System.assertEquals('Ready', result.Open_Closed__c);
       System.assertEquals(True, result.Active_Prevett__c);



    }
}



Thanks