• John Pipkin 14
  • NEWBIE
  • 325 Points
  • Member since 2016
  • Senior Salesforce Developer
  • OpFocus, Inc

  • Chatter
    Feed
  • 10
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 68
    Replies
Hello,

I want to implement the email to case for an object "opportunity" and also for an "custom object"
The working will be same as email to case.

How can i implement it for Opportunity ?

Thank you for any suggestions

Thank you for suggestion
  • November 16, 2018
  • Like
  • 0
I have contact fields that i need to validate on client side and if everything is ok then insert that contact. But when i go into js for validation and call controller method from js using action fucntion all my inputField values are null. Contact does not get values that i have written, Please help!
VF:
<apex:pageBlock rendered="{!IsPkg}" id="contactPageBlock">
            <apex:pageBlockSection title="Guest Registration" columns="1" collapsible="false" id="contactSection">
                <apex:inputField value="{!contactObj.FirstName}" label="First Name" id="fname"/>
                <apex:inputField value="{!contactObj.LastName}" label="Last Name" id="lname"/>
                <apex:inputField value="{!contactObj.Email}" label="Email" id="cmail"/>
            </apex:pageBlockSection>
                <apex:commandButton onclick="validate();return false;" value="Save"/>
                <apex:actionfunction name="callfromJS" action="{!saveContact}" immediate="true"/>
        </apex:pageBlock>

Js
function validate(){
            try{
                var fNameObj = document.getElementById("{!$Component.form.contactPageBlock.contactSection.fname}");
                var lNameObj = document.getElementById("{!$Component.form.contactPageBlock.contactSection.lname}");
                var eNameObj = document.getElementById("{!$Component.form.contactPageBlock.contactSection.cmail}");
                console.log(fNameObj.value);
                console.log(lNameObj.value);
                console.log(eNameObj.value);
                if(trim(fNameObj.value) == "" || trim(lNameObj.value) == "" || trim(eNameObj.value) == ""){
                    console.log("Inside If");
                    window.alert("All fields are mandatory!");
                    return false;
                } else if(trim(eNameObj.value) != ""){
                    var x = eNameObj.value;
                    var atpos = x.indexOf("@");
                    var dotpos = x.lastIndexOf(".");
                    if (atpos<1 || dotpos<atpos+2 || dotpos+2>=x.length) {
                        window.alert("Not a valid e-mail address");
                        return false;
                    }else {
	                    var r = confirm("Register a new guest?");
	                    if(r==true){
	                        callfromJS();
	                        return true;
	                    }else{
	                       return false;
	                    }
	                }
	            }
            } catch(e){
                console.log("Inside Catch");
            }
        }
    </script>

​Controller method
public void saveContact(){
        System.debug('Inside Save');
        System.debug('Contact Constructed is::'+contactObj);
        System.debug('selectedEventId:::'+selectedEventId);
        System.debug('selectedPackageId:::'+selectedPackageId);
        if(String.isNotBlank(selectedPackageId)){
            System.debug('Contact Constructed is::'+contactObj);
            if(contactObj.LastName != null){
                System.debug('Contact Constructed is::'+contactObj);
                contactObj.Package__c = selectedPackageId;
                try{
                    System.debug('Contact Constructed is::'+contactObj);
                    //insert contactObj;
                } catch(Exception e){
                    
                }
            }
        }
    }

 
I am getting Error: Compiled formula is too big to execute (6,166 characters). Maximum size is 5,000 characters for the formula below. How can I correct this? 
 
IF( RecordTypeId='012700000009OvZAAU',
IF( Data_Quality_Score__c =5,"All Contact Details Captured", "Missing: "& 
IF( ISBLANK( Name), "Account Name, ","")&""&
IF( ISPICKVAL(Account_Vertical__c,""), "Account Vertical,","")&""&
IF( ISBLANK( BillingStreet), "Street, ","")&""&
IF( ISBLANK( BillingCity), "City, ","")&""&
IF( ISBLANK( BillingState),  "State, ","")&""&
IF( ISBLANK( BillingPostalCode),  "Postal Code, ","")&""&
IF( ISBLANK( BillingCountry), "Country, ","")&""&
IF( ISBLANK( NumberOfEmployees ),  "Number Of Employees, ","")&""&
IF( ISBLANK( DunsNumber), "Duns Number, ","")&""&
IF( ISPICKVAL( Preferred_Language__c,""), " Preferred Language,","")&""&
IF( ISPICKVAL( Segment_2__c,""), "Segment,","")),

IF(RecordTypeId='012700000009OvoAAE' ,
IF( Data_Quality_Score__c =5,"All Contact Details Captured", "Missing: "&
IF( ISBLANK( Name), "Account Name, ","")&""&
IF( ISPICKVAL(Account_Vertical__c,""), "Account Vertical,","")&""&
IF( ISBLANK( BillingStreet), "Street, ","")&""&
IF( ISBLANK( BillingCity), "City, ","")&""&
IF( ISBLANK( BillingState),  "State, ","")&""&
IF( ISBLANK( BillingPostalCode),  "Postal Code, ","")&""&
IF( ISBLANK( BillingCountry), "Country, ","")&""&
IF( ISBLANK( NumberOfEmployees ),  "Number Of Employees, ","")&""&
IF( ISBLANK( DunsNumber), "Duns Number, ","")&""&
IF( ISPICKVAL( Preferred_Language__c,""), " Preferred Language,","")&""&
IF( ISPICKVAL( Segment_2__c,""), "Segment,","")&""&
IF( ISBLANK( NaicsCode ), "NAICS Code, ","")&""&
IF( ISBLANK( Servicing_Division__c), "Servicing Division, ","")),""))

 
Hi All,

I am looking for a batch apex where i can add some string to the end of the email ID to make it inactive. ex: abc_123@gmai.com+007
some vaule at the end of the email ID. I have a free text where users enters multiple email addresses in this ( Format: salesforce@yahoo.com;sdfc@hotmail.com;developer_sdfc@aol.com). Now i have a batch apex which adds a dummy string at the end of the value in the that field. However i want to add a dummy string after every .com. So how should i find that .com from that field and add some sting to it using batchapex.

Thank you
Hello,

I am copying records from one object to another.
On the old object there exisit a lookup(ManagedPackage__Opportunity__c) to opportunity object, and in New object there exisit a Masterdetail(opportunity__c ) to opportunity

x.opportunity__c = c.ManagedPackage__Opportunity__c;

this line gives error when i try to insert like below
User-added image
de|"common.apex.runtime.impl.DmlExecutionException: Insert failed. First exception on row 0; first error: INVALID_CROSS_REFERENCE_KEY, invalid cross reference id: []"|0x4951b823
 
  • April 11, 2016
  • Like
  • 0
I want to create a custom field that parses the domain of an email and inserts it in there through a trigger.  Could someone help me create that trigger please?

i.e. if Leads email is jonsmith@abc.com    then custom field = abc.com 
Hi

   I am getting below error when trying to compare value with a integer please suggest me how to fix this issue and make the change. 

Line: 126, Column: 6
Comparison arguments must be compatible types: Set<Integer>, Integer
Decimal LineMaxDiscount;
 Decimal LineMaxACV;
 Decimal SubLineMaxDiscount;
 Decimal SubLineMaxACV;
 Decimal SerLineMaxDiscount;
 Decimal SerLineMaxACV;
 Map<ID, Quote> ParentQuote = new Map<ID, Quote>();
 String SALREPID;
 String MRGID;
 String SALID;
 String CFOID;
 String Level;
 Set<Integer> GSublevel1Count = new Set<Integer>();
 Set<Integer> GSublevel2Count = new Set<Integer>();
 Set<Integer> GSublevel3Count = new Set<Integer>();
 Set<Integer> GSublevel4Count = new Set<Integer>();
 Set<Integer> GSerlevel1Count = new Set<Integer>();
 Set<Integer> GSerlevel2Count = new Set<Integer>();
 Set<Integer> GSerlevel3Count = new Set<Integer>();

 List<Id> listIds = new List<Id>();
 //Set<Id> listIds = new Set<Id>(); 
    
 List<Quote> QuotetList = new List<Quote>();  
 
 for (QuoteLineItem childquoteline : [SELECT id,QuoteId,Discount,Discount_Percent__c from QuoteLineItem where quoteid = '0Q0180000008isQ'])
 {
        listIds.add(childquoteline.QuoteId);
    }
    
  ParentQuote = new Map<Id, Quote>([SELECT id,Level_1__c,Level_2__c,Level_3__c,Level_4__c FROM Quote WHERE ID IN :listIds]);
 
 /* Subscription Discount and ACV */
  List<AggregateResult> MaxSubscription = [select max(Discount_Percent__c) SubQuoteLineMaxDiscount,SUM(UnitPrice) SubQuoteLineMaxACV 
                                                   from  QuoteLineItem 
                                                   where quoteid in :listIds and Subscription_Terms__c <> NULL ];
  
  for (AggregateResult SubQuoteMaxDiscount : MaxSubscription)
  {
  SubLineMaxDiscount = (Decimal)SubQuoteMaxDiscount.get('SubQuoteLineMaxDiscount');
  SubLineMaxACV = (Decimal)SubQuoteMaxDiscount.get('SubQuoteLineMaxACV');
  }
   
   system.debug('Subscription Line Discount  :' + SubLineMaxDiscount);
   system.debug('Subscription Line ACV  :' + SubLineMaxACV);

   /* Service Discount and ACV */
  List<AggregateResult> MaxService = [select max(Discount_Percent__c) SerQuoteLineMaxDiscount,SUM(UnitPrice) SerQuoteLineMaxACV 
                                      from  QuoteLineItem 
                                      where quoteid in :listIds and Custom_Product_Name__c like 'CBSVC%'];
 
  for (AggregateResult SerQuoteMaxDiscount : MaxService)
  {
  SerLineMaxDiscount = (Decimal)SerQuoteMaxDiscount.get('SerQuoteLineMaxDiscount');
  SerLineMaxACV = (Decimal)SerQuoteMaxDiscount.get('SerQuoteLineMaxACV');
  }
  
   system.debug('Service Line Discount  :' + SerLineMaxDiscount);
   system.debug('Service Line ACV  :' + SerLineMaxACV);

 
  List<AggregateResult> GetLineDiscount = [select max(Discount_Percent__c) QuoteLineMaxDiscount,SUM(UnitPrice) QuoteLineMaxACV from  QuoteLineItem where quoteid in :listIds];
     
  for (AggregateResult QuoteMaxDiscount : GetLineDiscount)
  {
  LineMaxDiscount = (Decimal)QuoteMaxDiscount.get('QuoteLineMaxDiscount');
  LineMaxACV = (Decimal)QuoteMaxDiscount.get('QuoteLineMaxACV');
  }
      
  Quote Qot = [select id,OpportunityID
               from quote
               where
               id in :listIds];    
      
  Opportunity Opp = [select Subscription_Term__c,ownerid
                    from opportunity
                    where
                    id = :Qot.OpportunityId];
   
  system.debug('Subscription Term  :' + Opp.Subscription_Term__c);

  User Usr = [select managerid from user where id = :opp.ownerid]; 
   
   
   /* Subscription Query to get level 1..4 values */
   if ( Opp.Subscription_Term__c != null &&
        SubLineMaxACV != null &&
        SubLineMaxDiscount != null)
   {                             
       GSublevel1Count = ApprovalUtils.SubLevel1(new Set<Decimal>{Opp.Subscription_Term__c},new Set<Decimal>{SubLineMaxACV},new Set<Decimal>{SubLineMaxDiscount});
       
       system.debug('Subscription Level1 :' + GSublevel1Count);
       
       GSublevel2Count = ApprovalUtils.SubLevel2(new Set<Decimal>{Opp.Subscription_Term__c},new Set<Decimal>{SubLineMaxACV},new Set<Decimal>{SubLineMaxDiscount});
       
       system.debug('Subscription Level2 :' + GSublevel2Count);
       
       GSublevel3Count = ApprovalUtils.SubLevel3(new Set<Decimal>{Opp.Subscription_Term__c},new Set<Decimal>{SubLineMaxACV},new Set<Decimal>{SubLineMaxDiscount});
       
       system.debug('Subscription Level3 :' + GSublevel3Count);
       
       GSublevel4Count = ApprovalUtils.SubLevel4(new Set<Decimal>{Opp.Subscription_Term__c},new Set<Decimal>{SubLineMaxACV},new Set<Decimal>{SubLineMaxDiscount});
       
       system.debug('Subscription Level4 :' + GSublevel4Count);
       
   }   

    /* Service Query to get level 1..4 values */
   if (SerLineMaxACV != null && SerLineMaxDiscount != null)
    { 
        GSerlevel1Count = ApprovalUtils.SerLevel1(new Set<Decimal>{SerLineMaxACV},new Set<Decimal>{SerLineMaxDiscount});
       
       system.debug('Service Level1 :' + GSerlevel1Count);  
        
        GSerlevel2Count = ApprovalUtils.SerLevel2(new Set<Decimal>{SerLineMaxACV},new Set<Decimal>{SerLineMaxDiscount});
       
       system.debug('Service Level2 :' + GSerlevel2Count);  
        
        GSerlevel3Count = ApprovalUtils.SerLevel3(new Set<Decimal>{SerLineMaxACV},new Set<Decimal>{SerLineMaxDiscount});
       
       system.debug('Service Level3 :' + GSerlevel3Count); 
    }   
    

 If( GSublevel1Count != 0 || GSerlevel1Count != 0 )
   {
    SALREPID = Opp.OwnerId;
    MRGID = null;
    SALID = null;
    CFOID = null;
    Level = '1';
   }
   else If (GSublevel2Count != 0 || GSerlevel2Count != 0)
   {
    SALREPID = NULL;
    MRGID = Usr.managerid;
    SALID = null;
    CFOID = null;
    Level = '2';
   }
   else If ( GSublevel3Count != 0 || GSerlevel3Count != 0 )
   {
    SALREPID = NULL;
    MRGID = Usr.managerid;
    SALID = '00580000007jaoA';
    CFOID = null;
    Level = '3';
   }

   else If ( GSublevel4Count != 0  )
   {
    SALREPID = NULL;
    MRGID = Usr.managerid;
    SALID = '00580000007jaoA';
    CFOID = '00580000006HV0w';
    Level = '4';
   }

    system.debug('Sales Rep' + SALREPID);  
    system.debug('Manager ' + MRGID);  
    system.debug('Sales Ops' + SALID);  
    system.debug('CEO CFO'  + CFOID);


Thanks
Sudhir
In the object Opportunities there's a field named Expected Order Month.
If the date in that field has expired, I want to make a login flow that doesn't let the user do other thing if he doesn't set a new date.
 
Hi guys,

Here is my Trigger::::::
 
trigger UpdateActivityCountonAccountContactOptyevent on Event (after insert, after delete) {

map<id,integer> mopportunityCount = new map<id,integer>();
  map<id,integer> maccountCount = new map<id,integer>();
  map<id,integer> mcontactCount = new map<id,integer>();
  
  Integer OptyCount = 0;
 Integer AccountCount = 0;
 Integer ContactCount = 0;
 
  if (trigger.isinsert){
   for(event e :trigger.new) {


    if(e.whoId != null) {
      if(string.valueOf(e.WhoId).left(3) == '003') {
         
         
         if(mcontactCount.containsKey(e.WhoId)) {
           ContactCount = mcontactCount.get(e.WhoId);
            }
         
         ContactCount = ContactCount + 1;
      
         mcontactCount.put(e.whoid,ContactCount);
      }
    }
  
    if(e.whatId != null) {
      if(string.valueOf(e.WhatId).left(3) == '006') {
         
         
         if(mopportunityCount.containsKey(e.WhatId)) {
           OptyCount = mopportunityCount.get(e.WhatId);
            }
         
         OptyCount = OptyCount + 1;
      
         mopportunityCount.put(e.whatid,OptyCount);
      }
      
    if(string.valueOf(e.WhatId).left(3) == '001') {
         
         
         if(maccountCount .containsKey(e.WhatId)) {
           AccountCount = maccountCount.get(e.WhatId);
            }
         
         AccountCount = AccountCount + 1;
      
         maccountCount.put(e.whatid,AccountCount);
      }
    }
   }
  }

  if (trigger.isdelete){
   for(event e :trigger.old) {


    if(e.whoId != null) {
      if(string.valueOf(e.WhoId).left(3) == '003') {
         
         
         if(mcontactCount.containsKey(e.WhoId)) {
           ContactCount = mcontactCount.get(e.WhoId);
            }
         
         ContactCount = ContactCount - 1;
      
         mcontactCount.put(e.whoid,ContactCount);
      }
    }
  
    if(e.whatId != null) {
      if(string.valueOf(e.WhatId).left(3) == '006') {
         
         
         if(mopportunityCount.containsKey(e.WhatId)) {
           OptyCount = mopportunityCount.get(e.WhatId);
            }
         
         OptyCount = OptyCount - 1;
      
         mopportunityCount.put(e.whatid,OptyCount);
      }
      
    if(string.valueOf(e.WhatId).left(3) == '001') {
         
         
         if(maccountCount .containsKey(e.WhatId)) {
           AccountCount = maccountCount.get(e.WhatId);
            }
         
         AccountCount = AccountCount - 1;
      
         maccountCount.put(e.whatid,AccountCount);
      }
    }
  }
 }
  if(mcontactCount.keyset().size()>0) {
    list<contact> contactToUpdate = new list<contact>([SELECT id,Count_of_Activity__c FROM contact WHERE Id IN :mcontactCount.keyset()]);

    for(contact o :contactToUpdate) {

        
    o.Count_of_Activity__c = o.Count_of_Activity__c + mcontactCount.get(o.id);
    }
   
    if(contactToUpdate.size()>0) {
      update contactToUpdate;
    }
   } 
 

  if(mopportunityCount.keyset().size()>0) {
    list<opportunity> opportunityToUpdate = new list<opportunity>([SELECT id,Count_of_Activity__c FROM opportunity WHERE Id IN :mopportunityCount.keyset()]);
     for(opportunity o :opportunityToUpdate ) {
     o.Count_of_Activity__c = o.Count_of_Activity__c + mopportunityCount.get(o.id);
    }
   if(opportunityToUpdate.size()>0) {
      update opportunityToUpdate;
    }
   } 
   if(maccountCount.keyset().size()>0) {
    list<account> accountToUpdate = new list<account>([SELECT id,Count_of_Activity__c FROM account WHERE Id IN :maccountCount.keyset()]);

    for(account a :accountToUpdate ) {

        
    a.Count_of_Activity__c = a.Count_of_Activity__c + maccountCount.get(a.id);
    }
   
    if(accountToUpdate.size()>0) {
      update accountToUpdate;
    }
   } 
  }
and Test class:::: if I used Contact instance hits governor limit of Soql .

@isTest (SeeAllData=true)
private class UpdateCountonAccountContactOptyeventTest{
   @isTest
    static void testMethodOne() {
    
    
    
       Profile p = [SELECT Id FROM Profile WHERE Name='System Administrator' LIMIT 1];
      User u = new User(Alias = 'standt', Email='manasauser@thomsonreuters.com',
      EmailEncodingKey='UTF-8', LastName='Testing', LanguageLocaleKey='en_US',
      LocaleSidKey='en_US', ProfileId = p.Id,  
      TimeZoneSidKey='America/Los_Angeles', UserName='manasauser@testorg.com', tfcrmTeamRole__c= 'Relationship Manager');

      System.runAs(u) {  
        
            Account testAccount1 = new Account(ShippingStreet='test',ShippingCity='test',ShippingPostalCode='123',ShippingCountry='United States');
            testAccount1.Name = 'FXall_Account1';
            testAccount1.trAccountClass__c='Global: F2FDirT';
            testAccount1.tfcmCountryCode__c = 'ATG';        
            insert testAccount1;  
             
             Event eve1 = new Event();
           eve1 .WhatId =testAccount1.Id;
          eve1 .subject='call';
          eve1 .StartDateTime = System.now();
          eve1.EndDateTime= System.now();
           eve1.Status__c = 'Cancelled';
           eve1.Type = 'Client Meeting';
           Insert eve1;
           
            Account accNew = [select  Count_of_Activity__c from Account where Id =: testAccount1.Id LIMIT 1];
        
        System.assertEquals(1, accNew.Count_of_Activity__c);
        
       
        
        
            
        
            
            opportunity opp1 = new Opportunity();
            opp1.NAME = 'opp1';
            opp1.AccountId = testAccount1.Id;
            opp1.CloseDate = system.today().addDays(14);
            opp1.Type = 'test';
            opp1.tfcrmMkt__c='Corporate Route';
            opp1.StageName = Label.Opportunity_Stage_6;
            opp1.PROBABILITY = 10.0;
            opp1.TOCEXPECTEDREVENUEDATE__C = system.today().addDays(40);
            opp1.TFCRMMKT__C = 'Reuters';
            opp1.TFCRMGLOBALDEAL__C = false;
            opp1.TFCRMTYPE__C = 'Notified Cancellation';
            opp1.tfcrmWinLossReason__c= 'Community/Connectivity';
            opp1.tfcrmWinLossCommentary__c= 'Sample';
            opp1.Current_Competitive_System__c= 'Sample';
            opp1.Lost_to_Competitor__c= 'Sample';
            opp1.Competitors__c= 'Actimize';
            opp1.PriceBook2Id= Label.Opportunity_Pricebook2Id;       
             
            insert opp1;  
            
            
        
         Event eve = new Event();
         eve .WhatId =opp1.Id;
          eve .subject='call';
          eve .StartDateTime = System.now();
          eve .EndDateTime= System.now();
           eve.Status__c = 'In Progress';
           eve.Type = 'Client Meeting';
          
           Insert eve;
          
            
        Opportunity oppNew = [select Count_of_Activity__c from Opportunity where Id =: opp1.Id LIMIT 1];
        
        System.assertEquals(1, oppNew.Count_of_Activity__c);
           
             delete eve;
                 
        Opportunity oppNew1 = [select Count_of_Activity__c from Opportunity where Id =: opp1.Id LIMIT 1];
        
        System.assertEquals(0, oppNew1.Count_of_Activity__c);
        
        
         
             Contact con = new Contact();
            con.AccountId=testAccount1.Id;
            con.FirstName='Dummy';
            con.LastName='Test';
            con.Salutation='Mr.';
            con.Phone='12345678';
            con.Email='dummytest1@thomsonreuters.com';
            insert con;    
            
          
        
         Event eve2 = new Event();
         eve2.WhoId =con.Id;
          eve2 .subject='call';
          eve2.StartDateTime = System.now();
          eve2.EndDateTime= System.now();
           eve2.Status__c = 'In Progress';
           eve2.Type = 'Client Meeting';
          
           Insert eve;
          
            
        Contact conNew = [select Id, Count_of_Activity__c from Contact where Id =: con.Id];
        
        System.assertEquals(1, conNew.Count_of_Activity__c);
          
        
        
         
          
         
        
        
     
        
      }  
        
    }
}
 
Hi there experts, I'm looking for a solution to the following:
I have two fields, one Next Step MEC (picklist field) and the other Next Step Date (date field). What I'm looking for is that when a change is made to the picklist value, the date must be updated too. This is not happening now.
Can anyone provide me with a formula to make sure that this happens?

Here's my current formula on the Date

AND(
NOT(ISPICKVAL(Next_Step_MEC__c, "")),
ISNULL( Next_Step_Date__c ),
RecordTypeId="xxxxxx")

I also have the following validation rules set:
Next_Step_Date If Next Step MEC contains a picklist value then Next Step Date must be entered
Stages_for_Next_Step_MEC Next Step MEC is required when stage is different from Closed Lost/Closed Won

Thanks!
Hi everyone!

I'm having the following JSON:
 
{
	"log": {
		"id": 776812465,
		"date": "2022-02-25",
		"vehicles": [
			{
				"vehicle": {
					"id": 112334,
					"number": "308 R"
				}
			},
			{
				"vehicle": {
					"id": 112337,
					"number": "#309",

				}
			}
		],
		"odometers": {
			"#309": [
				{
					"end": 83810,
					"start": 83810,
					"metric_units": false
				},
				{
					"end": 83823,
					"start": 83810,
					"metric_units": false
				}
			],
			"308 R": [
				{
					"end": 194414,
					"start": 194310,
					"metric_units": false
				},
				{
					"end": 194487,
					"start": 194414,
					"metric_units": false
				}
			]
		}
	}
}

I used JSON to APEX tool to get wrapper class:
 
public class fromJSON{
	public cls_log log;
	class cls_log {
		public Integer id;	//776812465
		public String date;	//2022-02-25
		public cls_vehicles[] vehicles;
		public cls_odometers odometers;
	}
	class cls_vehicles {
		public cls_vehicle vehicle;
	}
	class cls_vehicle {
		public Integer id;	//112334
		public String number;	//308 R
	}
	class cls_odometers {
		public cls_#309[] #309;
		public cls_308 R[] 308 R;
	}
	class cls_#309 {
		public Integer end;	//83810
		public Integer start;	//83810
		public boolean metric_units;
	}
	class cls_308 R {
		public Integer end;	//194414
		public Integer start;	//194310
		public boolean metric_units;
	}
	public static fromJSON parse(String json){
		return (fromJSON) System.JSON.deserialize(json, fromJSON.class);
	}
}

The problem I'm facing is that vehicle numbers under odometers will be always different. So I can't have something like:
public cls_#309[] #309;
public cls_308 R[] 308 R;
Please advise how I can process this dynamically via wrapper class. Thank you!
 
Record triggered flow, working absolutely fine for one record but receiving the following error when we create multiple records..

The number of results does not match the number of interviews that were executed in a single bulk execution request.
 
public with sharing class FlowInvokableOpportunityLineItemHandler {


    @InvocableMethod(
        label = 'Opportunity Product from Opportunity Accounts'
        description = 'Given list of Accounts return list of OLIs from that account and parent account'
    )

    public static List<List<OpportunityLineItem>> runOppLineItems( List<ID> accIds ) {
        List<OpportunityLineItem> oLIs = new List<OpportunityLineItem>();
        List<Id> accountsIds = new List<Id>();
        List<Account> accIncParents = [SELECT Id, ParentId FROM Account WHERE Id IN: accIds];

        for (Account acc : accIncParents){
            if(acc.ParentId == NULL){
                accountsIds.add(acc.Id);
            }
            else{
                accountsIds.add(acc.Id);
                accountsIds.add(acc.ParentId);
            }
        }
        system.debug('accountsIds >>>>' + accountsIds);

        List<Opportunity> opps = [SELECT Id FROM Opportunity WHERE AccountId IN : accountsIds AND Opportunity.StageName != 'Closed Lost'];
        List<OpportunityLineItem> oLI = [SELECT Id, Product_Family__c, Product2.Name FROM OpportunityLineItem WHERE OpportunityId in :opps];
        
        system.debug('OLI >>>>' + oLI);
        List<List<OpportunityLineItem>> itemListList = new List<List<OpportunityLineItem>>();
        //add the list opps to the list of lists
        itemListList.add(oLI);
        system.debug('itemListList >>>>' + itemListList);

        // send list of lists to the Flow	
        return itemListList;        

    }
}

 
I have picklist field "Funding" on Quote object and text field "Funding" on Opportunity object. I want to copy the picklist values from all Quotes related to the Opportunity and display it on "Funding" field on Opportunity separated by comma. I tried this code but not working, 

I need to use string join instead of split. please help

global class UpdateFunding implements Database.Batchable<sObject> {
    global Database.QueryLocator start(Database.BatchableContext bc) {
        return Database.getQueryLocator([SELECT Id,StageName FROM opportunity where StageName='Closed Won']);
    }

    global void execute(Database.BatchableContext context, List<sObject> batch){
        Set<Id> Opportuniyids = new Set<Id>();

        for (sObject oppy : batch) {
            Opportuniyids.add(oppy.Id);
        }

        updatequote(Opportuniyids);
    }

    global void finish(Database.BatchableContext context) {}

    public void updatequote(set<id> oppyids){
        system.debug('opportuiy ids'+oppyids);
        List<opportunity> opportunities=[SELECT Id ,Funding__c FROM opportunity WHERE Id IN :oppyids];
        for(Opportunity opp:opportunities) {
       Set<String> systems = new Set<String>();
        for (Quote__c oppObj : [SELECT Id, Funding__c, opportunity__c FROM Quote__c WHERE opportunity__c = :opp.id]) {
        if (String.isNotBlank(oppObj.Funding__c)) {
            systems.addAll(oppObj.Funding__c.split(';'));
        }
            System.debug('ccc'+systems);
    }
    String accountSystems = '';
    for (String value : systems) {
        accountSystems += value + ';';
    }
    accountSystems = accountSystems.removeEnd(';');
    try {
        update new Opportunity(Id = opp.id,Funding__c  = accountSystems);
    } catch (Exception e) {
        System.debug('Exception: ' + e.getMessage());
    }
        }       
    }

}
Can an object be created to link a case to other related cases based on a custom field, "Problem" which would be the common factor between the cases. Then any related case with the same problem could be displayed in the related cases. The idea is to group cases together based on a common problem faced by multiple customers.
Hello,

I want to implement the email to case for an object "opportunity" and also for an "custom object"
The working will be same as email to case.

How can i implement it for Opportunity ?

Thank you for any suggestions

Thank you for suggestion
  • November 16, 2018
  • Like
  • 0
I have contact fields that i need to validate on client side and if everything is ok then insert that contact. But when i go into js for validation and call controller method from js using action fucntion all my inputField values are null. Contact does not get values that i have written, Please help!
VF:
<apex:pageBlock rendered="{!IsPkg}" id="contactPageBlock">
            <apex:pageBlockSection title="Guest Registration" columns="1" collapsible="false" id="contactSection">
                <apex:inputField value="{!contactObj.FirstName}" label="First Name" id="fname"/>
                <apex:inputField value="{!contactObj.LastName}" label="Last Name" id="lname"/>
                <apex:inputField value="{!contactObj.Email}" label="Email" id="cmail"/>
            </apex:pageBlockSection>
                <apex:commandButton onclick="validate();return false;" value="Save"/>
                <apex:actionfunction name="callfromJS" action="{!saveContact}" immediate="true"/>
        </apex:pageBlock>

Js
function validate(){
            try{
                var fNameObj = document.getElementById("{!$Component.form.contactPageBlock.contactSection.fname}");
                var lNameObj = document.getElementById("{!$Component.form.contactPageBlock.contactSection.lname}");
                var eNameObj = document.getElementById("{!$Component.form.contactPageBlock.contactSection.cmail}");
                console.log(fNameObj.value);
                console.log(lNameObj.value);
                console.log(eNameObj.value);
                if(trim(fNameObj.value) == "" || trim(lNameObj.value) == "" || trim(eNameObj.value) == ""){
                    console.log("Inside If");
                    window.alert("All fields are mandatory!");
                    return false;
                } else if(trim(eNameObj.value) != ""){
                    var x = eNameObj.value;
                    var atpos = x.indexOf("@");
                    var dotpos = x.lastIndexOf(".");
                    if (atpos<1 || dotpos<atpos+2 || dotpos+2>=x.length) {
                        window.alert("Not a valid e-mail address");
                        return false;
                    }else {
	                    var r = confirm("Register a new guest?");
	                    if(r==true){
	                        callfromJS();
	                        return true;
	                    }else{
	                       return false;
	                    }
	                }
	            }
            } catch(e){
                console.log("Inside Catch");
            }
        }
    </script>

​Controller method
public void saveContact(){
        System.debug('Inside Save');
        System.debug('Contact Constructed is::'+contactObj);
        System.debug('selectedEventId:::'+selectedEventId);
        System.debug('selectedPackageId:::'+selectedPackageId);
        if(String.isNotBlank(selectedPackageId)){
            System.debug('Contact Constructed is::'+contactObj);
            if(contactObj.LastName != null){
                System.debug('Contact Constructed is::'+contactObj);
                contactObj.Package__c = selectedPackageId;
                try{
                    System.debug('Contact Constructed is::'+contactObj);
                    //insert contactObj;
                } catch(Exception e){
                    
                }
            }
        }
    }

 
Hi Everyone,

I want to display static List<String> in VF Page, give me solution for below problem,


Public static List<String> reslist{get;set;}
@future(callout=true)
    public static void futuremethod(Decimal lat,Decimal lng)
    {
        reslist=new List<String>();
        system.debug('future called');
        HttpRequest req = new HttpRequest();
        req.setEndPoint('https://developers.zomato.com/api/v2.1/geocode?lat='+lat+'&lon='+lng+'');
        req.setMethod('GET');
        req.setHeader('Accept', 'application/json');
        req.setHeader('user-key', '806bc2fff09af32e5cf1ed4b9c11de5c');
        Http http = new Http();
        HttpResponse res;
        if(!Test.isRunningTest())
        {
                String s='some text from response';
                reslist.add(s); 
        }
    }
    
    VF page:
    --------
    <apex:page standardController="Account" extensions="ShowRestaurant_AC">
    <apex:form >
        <apex:pageBlock >
            <apex:commandButton value="Show Restaurants" action="{!callfuture}"/>
            <apex:pageBlockSection title="Contacts in Map">
                <apex:map width="2000px" height="500px" mapType="roadmap" center="{!bstreet},{!bCity},{!bState}" zoomLevel="{!zoomvar}">
                   <apex:repeat value="{!reslist}" var="res">
                        <apex:mapMarker title="{!res}" position="{!res}"/>
                  </apex:repeat>       /**********************HERE I CANNOT DISPLAY STATIC VARIABLE*************************

                </apex:map>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>


I CANNOT DISPLAY reslit (STATIC LIST) IN VF PAGE.HOW TO DO THIS
I am trying to capture picklist field value in a formula of return type checkbox for reports
if the picklist value = the user then it should give true otherwise false

for ex:if the field was a lookup then I would write my formula as IF(lookup field name = $User.Id , True , False)

How should I implement the same for picklist ?
Is it possible to capture records that were not inserted inside the visualforce page.

If for ex: in Lead object 
User-added image

I have a custom controller that inserts lead record,now sometimes the lead does not get inserted and exception is thrown
now can i fetch the Company name or some field value that i entered into the  vfpage but was not inserted as a record

Thanks
sathish

I have 2 org ad I want to provide making calls from one 1 org to another
I have allredy generated wsdl file for my soap webservice 
Original   class  simply looks like

global class SoapTest {
    webservice static String getGreeting() {
        return 'Hi, pal!';
    }
}

My external  call now loooks like:

soapTestParse.SoapTest sp = new soapTestParse.SoapTest();
String output = sp.getGreeting();
System.debug(output);

as a result I'mI getting 

System.CalloutException: Web service callout failed: WebService returned a SOAP Fault: INVALID_SESSION_ID: Invalid Session ID found in SessionHeader: Illegal Session faultcode=sf:INVALID_SESSION_ID faultactor=


I have been reading bunch of posts with the same problem but I still don't know the proper way to solve it

I saw such snippets of code 

in developer guide:

stub.inputHttpHeaders_x.put('Authorization', 'Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==');
 

but How can I dynamically get this token? Even if I hard code session id of target org, error remains the same.

In another poste

partnerSoapSforceCom.LoginResult partnerLoginResult = myPartnerSoap.login('karnashiva@cognizant.com.dev', 'Password123'); 
soapSforceComSchemasClassAccountins.SessionHeader_element webserviceSessionHeader = new soapSforceComSchemasClassAccountins.SessionHeader_element(); 
webserviceSessionHeader.sessionId = partnerLoginResult.sessionId;

I don't have neither login method no loginresult class in my generated from wsdl apex class

In another poste

ws.inputHttpHeaders_x = new Map <String, String>(); 
String b64_string = EncodingUtil.base64Encode(Blob.valueOf('<user_name>:<password>')); ws.inputHttpHeaders_x.put('Authorization', 'Basic ' + b64_string);
it still doesn't work

Can someone help, or give some tips or proper examples of soap callouts?
I am getting Error: Compiled formula is too big to execute (6,166 characters). Maximum size is 5,000 characters for the formula below. How can I correct this? 
 
IF( RecordTypeId='012700000009OvZAAU',
IF( Data_Quality_Score__c =5,"All Contact Details Captured", "Missing: "& 
IF( ISBLANK( Name), "Account Name, ","")&""&
IF( ISPICKVAL(Account_Vertical__c,""), "Account Vertical,","")&""&
IF( ISBLANK( BillingStreet), "Street, ","")&""&
IF( ISBLANK( BillingCity), "City, ","")&""&
IF( ISBLANK( BillingState),  "State, ","")&""&
IF( ISBLANK( BillingPostalCode),  "Postal Code, ","")&""&
IF( ISBLANK( BillingCountry), "Country, ","")&""&
IF( ISBLANK( NumberOfEmployees ),  "Number Of Employees, ","")&""&
IF( ISBLANK( DunsNumber), "Duns Number, ","")&""&
IF( ISPICKVAL( Preferred_Language__c,""), " Preferred Language,","")&""&
IF( ISPICKVAL( Segment_2__c,""), "Segment,","")),

IF(RecordTypeId='012700000009OvoAAE' ,
IF( Data_Quality_Score__c =5,"All Contact Details Captured", "Missing: "&
IF( ISBLANK( Name), "Account Name, ","")&""&
IF( ISPICKVAL(Account_Vertical__c,""), "Account Vertical,","")&""&
IF( ISBLANK( BillingStreet), "Street, ","")&""&
IF( ISBLANK( BillingCity), "City, ","")&""&
IF( ISBLANK( BillingState),  "State, ","")&""&
IF( ISBLANK( BillingPostalCode),  "Postal Code, ","")&""&
IF( ISBLANK( BillingCountry), "Country, ","")&""&
IF( ISBLANK( NumberOfEmployees ),  "Number Of Employees, ","")&""&
IF( ISBLANK( DunsNumber), "Duns Number, ","")&""&
IF( ISPICKVAL( Preferred_Language__c,""), " Preferred Language,","")&""&
IF( ISPICKVAL( Segment_2__c,""), "Segment,","")&""&
IF( ISBLANK( NaicsCode ), "NAICS Code, ","")&""&
IF( ISBLANK( Servicing_Division__c), "Servicing Division, ","")),""))

 
I'm trying to create a trigger that allows the opportunity owner and the admin to be notified when there is no activity on an opportunity in 30 days. I tried creating a workflow that looked at the number of days since last activity, but workflows trigger when an opportunity is created or edited, and I need the field "Days Since Last Activity" to be looked at everyday. Is this possible to do using triggers?
Hi All,

I am looking for a batch apex where i can add some string to the end of the email ID to make it inactive. ex: abc_123@gmai.com+007
some vaule at the end of the email ID. I have a free text where users enters multiple email addresses in this ( Format: salesforce@yahoo.com;sdfc@hotmail.com;developer_sdfc@aol.com). Now i have a batch apex which adds a dummy string at the end of the value in the that field. However i want to add a dummy string after every .com. So how should i find that .com from that field and add some sting to it using batchapex.

Thank you
Hello,

I am copying records from one object to another.
On the old object there exisit a lookup(ManagedPackage__Opportunity__c) to opportunity object, and in New object there exisit a Masterdetail(opportunity__c ) to opportunity

x.opportunity__c = c.ManagedPackage__Opportunity__c;

this line gives error when i try to insert like below
User-added image
de|"common.apex.runtime.impl.DmlExecutionException: Insert failed. First exception on row 0; first error: INVALID_CROSS_REFERENCE_KEY, invalid cross reference id: []"|0x4951b823
 
  • April 11, 2016
  • Like
  • 0
Hi everyone,
I tried to create a class to get executed once a year:
global class CalculOnAccount implements Database.Batchable<sObject>{
    global Database.QueryLocator start(Database.BatchableContext BC) {
       String query = 'SELECT field1__c,field2__c, cal__c FROM Account';
       return Database.getQueryLocator(query);
    }
    
    global void execute(Database.BatchableContext BC, List<Account> scope) {
         for(Account a : scope)
         {
             a.cal__c= ((a.field1__c- a.field2__c)*100 )/(a.field2__c);        
         }
         insert scope;
    }  
     
    global void finish(Database.BatchableContext BC) {
    }
}


My questions are:
How to schedule this to get executed in december each year for example? And what I want also is, depending on the result of cal__c, another field in Account will get updated, where I should put this treatment part? in the finish() ?
Thanks in advance