• Karan Khanna 6
  • NEWBIE
  • 155 Points
  • Member since 2014

  • Chatter
    Feed
  • 4
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 7
    Questions
  • 37
    Replies
Hello,
I am wondering if it is possible to cross-reference a different object inside a VisualForce email template, other than what the template was originally set up as. For example, if I create a VF Email template related to the opportunity, I can reference opportunity fields fine. However, if I need to reference something under the Account object, I have been unable to find a way to do so. Is this possible?

More information:
relatedToType="Opportunity"

{!relatedTo.OpportunityField__c} = works
{!Account.ebp_account_name__c} = does not work
Any help or insight would be appreciated greatly!
Hello

I am new to Salesforce and Apex Code but having to learn on my feet. 

 I have created the following validation rule:

ISCHANGED( OwnerId ) && NOT(ISNEW() ) && OR((BEGINS(BMCServiceDesk__Client_Last_Name__c ,"1")),(BEGINS(BMCServiceDesk__Client_Last_Name__c ,"2")),(BEGINS(BMCServiceDesk__Client_Last_Name__c ,"3")), (BEGINS(BMCServiceDesk__Client_Last_Name__c , "4"))) &&  BMCServiceDesk__Impact_ID__c  = 'HIGH' &&  BMCServiceDesk__Urgency_ID__c = 'HIGH'

 

However I would like this to only produce a validation question or information reminder (FYI) to the user rather than a data error  so they can continue as they were withouth making data input chnages if not required

Is there an easy way to do this?

Many thanks

Sonya

Hiya,

One of our users has reported that they're getting the following issue when attempting to login to Salesforce:

Login issue

Just in case the image does not work:

Sorry, an error occurred. Please provide your Salesforce.com administrator with this error message:

URL: undefined Line: undefined Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 9.1; WOW64; Trident/5.0; SLCC; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E)


The user is using IE9 Version 9.0.8112.16421

Can anyone offer any suggestion as to why this wouldn't work for this particular user, yet anyone else who uses this version of IE doesn't have any issues?
Hi, I have email-to-case & Auto Response rules setup in my org. I would like to know why the auto response rules always create an outgoing (sent) email record in my case? How can I disable that? Please refer below:

 User-added image

Thanks.
Hello - I am working with a non profit and we have requirement to display Calendar off custom object records in Experience cloud. we are using Customer Community licenses. any pointers?
we tried using AnyCalendar (https://appexchange.salesforce.com/appxListingDetail?listingId=a0N3A00000Ev8qpUAB) but it’s bit glitchy.
we are exploring this one but it only works with standard Event object - https://appexchange.salesforce.com/appxListingDetail?listingId=a0N3u00000ONzaqEAD
Thanks in advance!
In my lightning component I have sObject list which I render as data table. Some of the cells/fields are editable and onChange of those fields I recalculate other fields.
In my lightning component Helper method (called via controller when field value changes), I call another helper method and pass the field name as String which I need to update. Is there a way to dynamically reference that field and update it's value?
 
//Helper Method 1
calculateSegmentsAmounts : function(component, event, helper) {
        
        var prepayRecord = component.get("v.prepaymentRecord");
        var segmentsList = component.get("v.prepaymentSegmentsList");
        var calculatedTotalPercentage = 0;
        var calculatedTotalPrincipal = 0;
        var calculatedTotalInterest = 0;
        var calculatedTotalPremium = 0;
        var calculatedTotalBreakage = 0;
        var calculatedTotalOther = 0;
        
        for(var i=0; i < segmentsList.length; i++) {
            
            var percentage = 0;
            var principal = 0;
            
            if(segmentsList[i].Selected__c) {
                                    
				percentage = segmentsList[i].PAR_Percentage__c / 100;
				principal = percentage * prepayRecord.Native_Principal__c;                
                
                segmentsList[i].Interest__c = percentage * prepayRecord.Native_Interest__c;
                segmentsList[i].Premium__c = percentage * prepayRecord.Native_Premium__c;
                segmentsList[i].Breakage__c = percentage * prepayRecord.Native_Breakage__c;
                segmentsList[i].Other__c = percentage * prepayRecord.Native_Other__c;
                segmentsList[i].Total_Segment__c = principal + segmentsList[i].Interest__c + segmentsList[i].Premium__c + segmentsList[i].Breakage__c + segmentsList[i].Other__c;
            }
            percentage = percentage * 100;
            calculatedTotalPercentage += percentage;
            segmentsList[i].Principal__c = principal;
               
            calculatedTotalPrincipal += segmentsList[i].Principal__c;
            calculatedTotalInterest += segmentsList[i].Interest__c;
            calculatedTotalPremium += segmentsList[i].Premium__c;
            calculatedTotalBreakage += segmentsList[i].Breakage__c;
            calculatedTotalOther += segmentsList[i].Other__c;
        } // Loop ends
		
		// Update attribute value because it will be referred in below Helper methods
        component.set("v.prepaymentSegmentsList", segmentsList);

        var reCalcTotal = false;
        if(calculatedTotalPercentage == 100.00000000000) {
            if(calculatedTotalPrincipal != 0 && calculatedTotalPrincipal != prepayRecord.Native_Principal__c) {
                helper.adjustExtraAmount(component, event, helper, prepayRecord.Native_Principal__c, calculatedTotalPrincipal, "Principal__c"); // Passing Field name as String
                reCalcTotal = true;
            }
            if(calculatedTotalInterest != 0 && calculatedTotalInterest != prepayRecord.Native_Interest__c) {
                helper.adjustExtraAmount(component, event, helper, prepayRecord.Native_Interest__c, calculatedTotalInterest, "Interest__c"); // Passing Field name as String
                reCalcTotal = true;
            }
            if(calculatedTotalPremium != 0 && calculatedTotalPremium != prepayRecord.Native_Premium__c) {
                helper.adjustExtraAmount(component, event, helper, prepayRecord.Native_Premium__c, calculatedTotalPremium, "Premium__c"); // Passing Field name as String
                reCalcTotal = true;
            }
            if(calculatedTotalBreakage != 0 && calculatedTotalBreakage != prepayRecord.Native_Breakage__c) {
                helper.adjustExtraAmount(component, event, helper, prepayRecord.Native_Breakage__c, calculatedTotalBreakage, "Breakage__c"); // Passing Field name as String
                reCalcTotal = true;
            }
            if(calculatedTotalOther != 0 && calculatedTotalOther != prepayRecord.Native_Other__c) {
                helper.adjustExtraAmount(component, event, helper, prepayRecord.Native_Other__c, calculatedTotalOther, "Other__c"); // Passing Field name as String
                reCalcTotal = true;
            }
            if(reCalcTotal) {
                helper.reCalculateSegmentsRowTotal();
            }
        }
        
        component.set("v.prepaymentRecord", prepayRecord);
        component.set("v.prepaymentSegmentsList", segmentsList);
    },
	
	//Helper Method 2
	adjustExtraAmount : function(component, event, helper, nativeAmount, calculatedTotal, fieldName) {
    	
        var segmentsList = component.get("v.prepaymentSegmentsList");
        var multiplier = 100;
        var difference = (Math.round(multiplier * nativeAmount) - Math.round(multiplier * calculatedTotal)) / multiplier;    
        var absdiff = Math.abs(difference);
        var calculatedMoreThanActual;
        if(nativeAmount < calculatedTotal) {
            calculatedMoreThanActual = true;
        }
        else {
            calculatedMoreThanActual = false;
        }
        if (absdiff >= 0.01 && absdiff < 1) {
    
            var affliatedInvIndex = helper.getLargestaffiliatedINVIndex(component, event, helper, fieldName);  // Another Helper to which fieldName is passed 
            if (affliatedInvIndex == -1) {
                affliatedInvIndex = helper.getLargestSegmentIndex(component, event, helper, fieldName); // Another Helper to which fieldName is passed 
            }       
            var nonAffliatedInvIndex = helper.getLowestNonAffiliatedINVIndex(component, event, helper, fieldName); // Another Helper to which fieldName is passed 
            if (nonAffliatedInvIndex == -1) {
                nonAffliatedInvIndex = helper.getLowestSegmentIndex(component, event, helper, fieldName); // Another Helper to which fieldName is passed 
            }
            var runOnce = false;
            console.log('>>>> Recalculating ' + fieldName);
            for(var i=0; i < segmentsList.length; i++) {
                
                if(segmentsList[i].Selected__c) {
                    
                    var oldValue = 0;
                    oldValue = segmentsList[i].fieldName;   // Need to dynamically fetch the value
                    if(calculatedMoreThanActual) {
                        if (i == nonAffliatedInvIndex && !runOnce) {
                            var delta = oldValue + difference;          
                            segmentsList[i].fieldName = delta;     // Need to dynamically Update the value                       
                            runOnce = true;
                        }   
                    }
                    else {
                        if (i == affliatedInvIndex && !runOnce ) {
                            var delta = oldValue + difference;
                            segmentsList[i].fieldName = delta; 	// Need to dynamically Update the value
                            runOnce = true;
                        }
                    }               
                }
            }
        }
        component.set("v.prepaymentSegmentsList", segmentsList);
    },

 

Hi, I have this peculiar scenario where end user need an ability to export Deal and line items details from the Salesforce UI in excel format (it will look like Deal details in starting rows then line items details below it in table format).

so far it's fine as I can create a VFPage which will show details in this format and then render it as excel.

Issue is they want the ability to do some updates in that excel file and import it in Salesforce.

One way I could think of doing this is have a Macro on the excel file which will convert the excel into csv format which then user can load in salesforce but I would have to put that Macro while creating that excel and I can't seem to find a way to put Macro in salesforce.

any other ideas of achieving it is also welcome.

thanks in advance!

Hi Team,

Like we have System class method currentPageReference() to get the reference of current VFPage, do we have something similar to get the details of running apex class? 
My requirement is to check status of previous instance of my Batch class when it ran last time. Depending on that I need to set certain attributes of current instance.
Currently I am storing Batch Class Id in custom setting and referring that while querying AsyncApexJob for status. Just wondering if there any other way.
 
Hi Team,

I had a business case to run Batch class concurrently, I was successfully able to accomplish that by writing another Batch class which creates chunks of data and call main Batch class n number of times. Now I am trying to make that concurrent class generic so that it can work with any sObject and be able to call any Batch class whose name I will be passing through custom setting.

I am using Type Class to implement this (https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_type.htm%23apex_methods_system_type)

I have used this in past and it works fine with Apex classes but in case of Batch class I am getting below error:
Compile Error: Argument must be an object that implements Database.Batchable at line 87 column 17
 
Type classType = Type.forName('MyBatchClassName');
MyInterFaceName obj = (MyInterFaceName)classType.newInstance();
obj.runBatchConcurrently(); // This is the method which I declared in Interface and implemented in Batch class               
system.debug('### obj'+obj); // In debug I am able to see instance of my Batch class
database.executeBatch(obj, 200); // Compile error is coming here

 
Hi All:

I am using apex:tabPanel and have multiple apex:tab's, each tab show different data table my need is to call controller's method whenever user clicks on a tab so that respective data is loaded only when tab is clicked as otherwise if a query data for all the tabs during load of page then it effects performance adversely and it is not required too. I tried below code but this doesn't seems to be working:

 <apex:tabPanel switchType="ajax" selectedTab="name1" id="tabPanel">
<apex:actionFunction name="callClass" action="{!callClass}" rerender="tabPanel" />       
<apex:tab label="My Table1" name="name1" id="tabOne" status="actionStatus" onClick="callClass()">
 <apex:pageBlockTable value="{!myList}" var="p">
  ....
 </apex:pageBlockTable>
tab2...
tab3....

Hello,

I've created an app which do webservice call within, to fetch the metadata. as i developed it in my Dev Org so I added RSS URL as :

https://c.ap1.visual.force.com

my questions are:

1. will it work if I move my components to another org which has different sub-domain unlike ap1, for eg cs or na? I think it will not.
2. if not then what generic url I can add which can work for all orgs?
 

Hi Team,

Like we have System class method currentPageReference() to get the reference of current VFPage, do we have something similar to get the details of running apex class? 
My requirement is to check status of previous instance of my Batch class when it ran last time. Depending on that I need to set certain attributes of current instance.
Currently I am storing Batch Class Id in custom setting and referring that while querying AsyncApexJob for status. Just wondering if there any other way.
 
Hi Team,

I had a business case to run Batch class concurrently, I was successfully able to accomplish that by writing another Batch class which creates chunks of data and call main Batch class n number of times. Now I am trying to make that concurrent class generic so that it can work with any sObject and be able to call any Batch class whose name I will be passing through custom setting.

I am using Type Class to implement this (https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_type.htm%23apex_methods_system_type)

I have used this in past and it works fine with Apex classes but in case of Batch class I am getting below error:
Compile Error: Argument must be an object that implements Database.Batchable at line 87 column 17
 
Type classType = Type.forName('MyBatchClassName');
MyInterFaceName obj = (MyInterFaceName)classType.newInstance();
obj.runBatchConcurrently(); // This is the method which I declared in Interface and implemented in Batch class               
system.debug('### obj'+obj); // In debug I am able to see instance of my Batch class
database.executeBatch(obj, 200); // Compile error is coming here

 
Hey guys ,

I trying to produce a pdf based on info from a object call document , i have a field call signature_c and if the use field is filed that text will appear in the documento , if not the info will be based on a custom seeting.

My doubt is about the custom setting in the pdf , the custom seeting is called assinatura and will only have one field.

How do i call the custom seeting in the controller and compare with the field in the custom object dociment.

Thank in advance
hi,

Can anybody suggest me few ideasfor impleamenting and learning web services.
I am new to web services implementation and want to learn by starting with simple integrations.
Any help would be appreciated.

Thanks.
I am in a project where i have to update all my test classes in my org with the new fields I am creating. A huge time commitment. What is best practice for apex code? Should I configure one class where I have create my test class records or create the test data in each test class? This affects 50+ test classes in my org.
In Update trigger, Is there a way to know how many fields are updated? I have a scenario where a user should be able to update only one specific field on custom object.
There are more than 100 fields on custom object and I do not want to check old and new value for each and every field.

Thanks in advace for viewing this thread.
How do i give users permission to edit their page layout  on the case object without giving them to many permissions? Any help would be appreciated

Case Page Layout Edit
  • July 22, 2014
  • Like
  • 0
Hello,
I am wondering if it is possible to cross-reference a different object inside a VisualForce email template, other than what the template was originally set up as. For example, if I create a VF Email template related to the opportunity, I can reference opportunity fields fine. However, if I need to reference something under the Account object, I have been unable to find a way to do so. Is this possible?

More information:
relatedToType="Opportunity"

{!relatedTo.OpportunityField__c} = works
{!Account.ebp_account_name__c} = does not work
Any help or insight would be appreciated greatly!
Hi Guys,

I need help increasing my Test Code Coverage for an apex trigger I have. I'm new to Apex and I'm learning on the spot.  I'm at 69% with this but need to get it over 75%. The higher the better.

Thanks

Paul


Trigger

trigger Lead_To_Candidate_2 on Lead (after insert, after update)
{
    set<string> phoneNumbers = new set<string>();
    String disposition;
    String email;
    String firstname;
    String lastname;
      
    for(Lead obj: Trigger.new)
    {
        if (obj.disposition__c != NULL  )
        {
            phoneNumbers.add(obj.Phone);
            disposition = obj.disposition__c;
            firstname = obj.firstName;
            lastname = obj.lastName;
            email = obj.email;
         
                }
    }
 
    List<Candidate_Non_Member__c> candidate = [SELECT Id, Formated_Phone_Number__c, Called__c, Latest_Dispostion__c, Contact_Email__c, Contact_First_Name__c, Contact_Last_Name__c FROM Candidate_Non_Member__c WHERE Formated_Phone_Number__c IN :phoneNumbers];
    List<Candidate_Non_Member__c> candidateUpdateList = new List<Candidate_Non_Member__c>();
 
    for(Candidate_Non_Member__c c: candidate)
    {
        c.Called__c = 1; //this is if called__c is a number field. If it is a text field, the line should be c.Called__c = '1';
        c.Latest_Dispostion__c = disposition;
        c.Contact_Email__c = email;
        c.Contact_First_Name__c = firstname;
        c.Contact_Last_Name__c = lastname;
      
        candidateUpdateList.add(c);
    }
    if(candidateUpdateList.size() > 0)
    {
        update candidateUpdateList;
    }
}




Test Class:

@isTest

/*
* Tests
*/


/*
* This is the basic test
*/

public with sharing class TestLead_To_Candidate_2 {


     public static final String DISPOSITION = 'Registered';
     public static final String COMPANY = 'Test Company';
     public static final String EMAIL = 'tuser15@salesforce.com';
     public static final String FIRSTNAME = 'John';
     public static final String LASTNAME = 'Doe';
     public static final String PHONE = '+12125555403';

    static testMethod void basicTest() {

        // Create dummy lead
        Lead testLead = new Lead(Company='Test Company',FirstName='John',LastName='Doe', Email='tuser15@salesforce.com', disposition__c = 'Registered', Phone = '+12125555403');
        insert testLead;
  
            
        List<Candidate_Non_Member__c> Candidate = [select id, Latest_Dispostion__c, Contact_Email__c, Called__c, Formated_Phone_Number__c, Contact_First_Name__c FROM Candidate_Non_Member__c where Formated_Phone_Number__c=:testLead.Phone];
   
        for (Candidate_Non_Member__c c : Candidate){
        //   System.assertEquals(aLead.ActivityHistories[0].subject, 'Email: '+SUBJECT);
      
            System.assertEquals(testLead.Email, c.Contact_Email__c);
            System.assertEquals(testLead.FirstName, c.Contact_First_Name__c);
            System.assertEquals(c.Called__c, 1);
      
          
          
         
                         
        }
      
      

      

    }


}
I am trying to forward a specific email address to my Salesforce org which will create an opportunity on the same account everytime.

I have tried an app (Vertiba), but was unable to get it to work.

I basically need to replicate the exisiting email to case functionality, but make it email to opportunity. 

Has anyone written an apex class for this? Or found an easier work around? 
If the Account Teams is not enabled, the object AccountTeamMember does not exists and I have a compile error. 
I would like to know to check if the Account Teams is enabled before doing any query. 

Regards
Hello friends, hope u will help me. I want to write a trigger for autonumber field which will start from 1, as day begines. Normally autonumber field is keep on incresing daily. But i dont want that, it should start from 1 as day begins. Help me writing trigger for this.
Hello,
Is it possible to develop an Apex class that will take a file on my computer EVERY DAY and it will stored in Salesforce?
How do I do this?
Does anyone have any code for me to follow as a model?

Thank you,
i want to display or retrieve a user fiels in visualforce pages 
  fields which are in customize! users!fields
which may be standard fields or custom fields



Thanks in Advance 
Hello

I am new to Salesforce and Apex Code but having to learn on my feet. 

 I have created the following validation rule:

ISCHANGED( OwnerId ) && NOT(ISNEW() ) && OR((BEGINS(BMCServiceDesk__Client_Last_Name__c ,"1")),(BEGINS(BMCServiceDesk__Client_Last_Name__c ,"2")),(BEGINS(BMCServiceDesk__Client_Last_Name__c ,"3")), (BEGINS(BMCServiceDesk__Client_Last_Name__c , "4"))) &&  BMCServiceDesk__Impact_ID__c  = 'HIGH' &&  BMCServiceDesk__Urgency_ID__c = 'HIGH'

 

However I would like this to only produce a validation question or information reminder (FYI) to the user rather than a data error  so they can continue as they were withouth making data input chnages if not required

Is there an easy way to do this?

Many thanks

Sonya

I hope I explain this correctly: I have a time-based workflow rule that is supposed to kick off an hour after a new record is created. An automated process creates these records and more than one record may be created by the automated process.

When the time-based workflow rule executes it updates a single checkbox. When the checkbox is checked an After Update Trigger executes. The After Update Trigger checks to see if the newly insert record is a duplicate of an existing record. If it is a duplicate, the trigger updates the existing record with data from the duplicate record. A copy of the duplicate record is sent to another object to record that a duplicate did exist. The duplicate record is then deleted.

If there is only one newly inserted record everything works as it should. However, if there are two or more newly inserted records only the first record is processed as it should. The second record is also processed by the Time Based Workflow and the field update occurs; however, the After Update Trigger never executes against the second record. I have the debug log, but have no way of posting it here as it is too long.