• Deepali Kulshrestha
  • PRO
  • 3488 Points
  • Member since 2016
  • Salesforce Developer
  • Cloud Analogy


  • Chatter
    Feed
  • 116
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 1082
    Replies
I want to call a function in every 5-second lightning component controller. 
I am getting NullPointerException error while saving a new contact record.
Here is the exact error message:
Error: Invalid Data. 
Review all error messages below to correct your data.
Apex trigger ContactTrigger caused an unexpected exception, contact your administrator: ContactTrigger: execution of AfterInsert caused by: System.NullPointerException: Attempt to de-reference a null object: ()

I am new to apex coding and this code isn't written by me, so finding it hard to troubleshoot the issue. Would anyone be able to help?
Here is Apex Trigger:
trigger ContactTrigger on Contact (before delete, after insert, after update,after delete,after undelete) { 
    if(Trigger.isAfter) {
            if(Trigger.isUpdate) {
            ContactTriggerHandler.onAfterUpdate(Trigger.new,Trigger.oldMap);
            }
            
            if(Trigger.isInsert){
             ContactTriggerHandler.OnAfterInsert(Trigger.new);
            }
            
            if(Trigger.IsDelete){
                ContactTriggerHandler.OnAfterDelete(Trigger.old);
            }
            
            if(Trigger.IsUnDelete){
                ContactTriggerHandler.OnUndelete(Trigger.new);
            }
    }
    if(Trigger.isBefore){
            if(Trigger.IsDelete){
            }
    }
}

And here is the Apex Class:
public class ContactTriggerHandler {
    
    public static void onAfterUpdate(List<Contact> newContacts, Map<id,Contact> oldContacts) {
            updateSortedCorrespondencePreferneceData(newContacts,oldContacts);
            updateSalutationOnCommunicationContent(newContacts,oldContacts); 
            id cpCapitalPartnerRT = fetchRecordTypeId('Account','CP Capital Partner');
            List<Contact> newList = new List<Contact>();
            
            set<Id> oldAndNewAccountIds = new set<id>();
            for(Contact con : newContacts) {
                oldAndNewAccountIds.add(con.accountId);
                oldAndNewAccountIds.add(oldContacts.get(con.id).accountId);
            }
            
            Map<Id,Account> accountDetails = new Map<Id,Account>([Select Id,RecordTypeId from Account where Id in :oldAndNewAccountIds]);
            for(Contact con : newContacts) {
                    if(accountDetails !=NULL && con!= Null && con.accountId != oldContacts.get(con.Id).accountId  ) { 
                        if(  accountDetails.containsKey(con.accountId) && (accountDetails.get(con.accountId).recordTypeId == cpCapitalPartnerRT || accountDetails.get(oldContacts.get(con.Id).accountId).recordTypeId == cpCapitalPartnerRT) ) {
                            newList.add(con);
                        }

                    } else if(accountDetails !=NULL && con!= Null && accountDetails.get(con.accountId).recordTypeId == cpCapitalPartnerRT ) {  
                        newList.add(con);
                    }
            }        
           
            Email_InformationClass.getEmailTableData(newList,oldContacts); 
			
            updateCPIntralinksAccess(newContacts,oldContacts);
			
    }
    
	
    public static void OnAfterDelete(contact[] oldList){
        
        updateCPIntralinksAccess(oldList, null);
    }
    
     public static void OnAfterInsert(contact[] newList){
        
        updateCPIntralinksAccess(newList, null);
    }
     
    public static void OnUndelete(contact[] newList){ 
         
         updateCPIntralinksAccess(newList,null);
    }
	
    private static void updateSalutationOnCommunicationContent(List<Contact> newContacts, Map<id,Contact> oldContacts){
        set<id> contactsToProcess = new set<id>();

        for(Contact con : newContacts) {
		
            if((String.isNotBlank(con.email) && !con.email.contains('@generalatlantic.com'))  && ((con.Seniority_Rank__c != oldContacts.get(con.Id).Seniority_Rank__c) ||
                                                                                                  (con.FirstName != oldContacts.get(con.id).FirstName)) || (con.International_Salutation_Type__c!= oldContacts.get(con.Id).International_Salutation_Type__c || String.isBlank(oldContacts.get(con.Id).email))
              )
			  
            {
                
                        contactsToProcess.add(con.id);
            }
        }
        if(contactsToProcess.size() > 0) {
            List<Correspondence_Preference__c> corrPrefToProcess = new List<Correspondence_Preference__c>([Select Id, Company__c, RecordType.Name from Correspondence_Preference__c where Recipient_Type__c = 'To' AND Contact__c In :contactsToProcess]);
            set<string> cpNames = new Set<String>();
            set<string> accountNames = new Set<String>();
            for(Correspondence_Preference__c cp : corrPrefToProcess) {
                cpNames.add(cp.RecordType.Name);
                accountNames.add(cp.Company__c);
            }
            List<Communications_Content__c> ccList = new List<Communications_Content__c>([Select Id,Salutation__c,Company__c,Correspondence_Preference__c from Communications_Content__c where Company__c IN :accountNames AND Correspondence_Preference__c IN :cpNames]);
            CommunicationContentTriggerHandler handler = new CommunicationContentTriggerHandler(true,200,true);
            handler.updateSalutationField(null,ccList); 
        }
		
    private static void updateSortedCorrespondencePreferneceData(List<Contact> newContacts, Map<id,Contact> oldContacts) {
        set<id> contactsToProcess = new set<id>();
        for(Contact con : newContacts) {
            if((con.Seniority_Rank__c != oldContacts.get(con.Id).Seniority_Rank__c) ||
               (con.Email != oldContacts.get(con.id).Email)
              ) {
                  contactsToProcess.add(con.id);
              }
        }
        
        if(contactsToProcess.size() > 0) {
            List<Correspondence_Preference__c> corrPrefToProcess = new List<Correspondence_Preference__c>([Select Id, Commitment__c, RecordTypeId from Correspondence_Preference__c where Contact__c In :contactsToProcess]);
            
            CorrespondenceTriggerHandler.getCommRecTypeData(corrPrefToProcess,null,false);
        }
    }
	
    private static id fetchRecordTypeId(string sObj, string rt) {
        System.debug('fetch params>>'+sObj + '<<<rt>>>'+rt);
        String recordtypeId = Schema.getGlobalDescribe().get(sObj).getDescribe().getRecordTypeInfosByName().get(rt).getRecordTypeId(); 
        return Schema.getGlobalDescribe().get(sObj).getDescribe().getRecordTypeInfosByName().get(rt).getRecordTypeId();
		
    }
	
    public static void updateCPIntralinksAccess(List<Contact> newContacts, Map<id,Contact> OldMap){
        
        Map<ID,List<contact>> mapConWithAcc = new Map<ID,List<contact>>();
        List<account> accList = new List<account>();
        String temp= '';
        Map<Id,String> accUpdateMap = new Map<Id,String>();
        Set<ID> accid = new Set<ID>();
        
        for(contact con: newContacts){
            if(oldMap == null || (oldMap.get(con.id).CP_Intralinks_Access__c != con.CP_Intralinks_Access__c)){ 
                accid.add(con.accountid); 
            }
            if(oldMap.get(con.Id).AccountId != con.AccountId)
            {
               accid.add(con.AccountId);
               accid.add(oldMap.get(con.Id).AccountId);
            }
        }
        

		
        for(Account acc : [Select id,CP_Intralinks_Access__c,(Select id,CP_Intralinks_Access__c,accountid from contacts) from account where id in :accid]) {
            set<string> val = new set<string>();
            String finalVal = '' ;
            for(Contact ct : acc.contacts) {
                if(String.isNOtBlank(ct.CP_Intralinks_Access__c)) {
                    val.addAll(ct.CP_Intralinks_Access__c.split(';')); 
                }
            }
            List<String> valList = new List<String>();
            valList.addAll(val);
            if(valList.size() > 0) {
                finalVal = String.join(valList,',');
            }
            acc.CP_Intralinks_Access__c = finalVal ;
            accList.add(acc);
        }
        if(accList.size() > 0) {
            update accList ;
        }
    }
}

 
I have found a way through CSS to change the colour of the label for all of my <lightning:input> fields using the code below:

.THIS label.slds-form-element__label{
    
    font-size: 1.00rem;
    color: blue;
}

but I have 2 fields that are <ui:inputDate> fields, how do I change the colour of their label?

User-added image

Here is the code for the Purchase Date field:

<ui:inputDate aura:id="PurchaseDate" label="Purchase Date" class="field" value="{!v.AcctForm.PurchaseDate__c}" displayDatePicker="true" /> 

Thank you in advance for any assitance you can provide.
Hello Everyone

Need Small Help

I am new to the slds, i am trying to display certain lightning cards, my Requirement is when i click on that card it should change the color
can anyone please suggest how can i do that

below is my code and snapshot

<aura:component >
 <a class="slds-badge__icon" href="javascript:void(0);">1BHK Available</a>
<a class="slds-button slds-button_neutral" href="javascript:void(0);">2BHK Available</a>
<a class="slds-button slds-button_brand" href="javascript:void(0);">3BHK Available</a>
<a class="slds-button slds-button_outline-brand" href="javascript:void(0);">1BHK Blocked</a>
<a class="slds-button slds-button_destructive" href="javascript:void(0);">1BHK Blocked</a>
<a class="slds-button slds-button_text-destructive" href="javascript:void(0);">1BHK Blocked</a>
<a class="slds-button slds-button_success" href="javascript:void(0);">1BHK Blocked</a>
</aura:component>

User-added image
Hi,
Using validation rule How to  make sure no two Opportunities have same Name. 
Rule will throw error only if “Some Field” field “value” is checked to false.
And able to control email sending behaviour based on User/Profile.

Thanks,
Aj

Hi,
I dont want to  allow making Opportunity Stage = “Closed Won” or “Closed Lost” when the Opportunity Amount is greater or equal $500,000.

Thanks,

AJ

I need to implement a validation rule which should take effect  for all new record created after a specific date. I have a field called  Unit_Cost__c , this field can not be blank for all records created after  July 25, 2019. Below is a draft of my work.  The error message is: Syntax error. Missing ')'

AND(DateValue(CreatedDate)=>Date(2019, 07,25 ), 
(ISBLANK(  Unit_Cost__c  )))
Hello, I am beginner. Help me with This,
1.When Should we use Map In Trigger.
2.Give me some trigger scenerios for account, contact, lead, opportunity in which Map can be used.
Hi,
i am getting error while solving trailhead challange. please find below error.

"Method does not exist or incorrect signature: void generateStringArray(Integer) from the type StringArrayTest"

I tried some code given as best answers.

1. First Code I tried
public class StringArrayTest
{
public static List<String> generateStringArray(Integer n) {
List<String> myArray = new List<String>();
for(Integer i=0;i<n;i++) {
myArray.add('Test '+i);
System.debug(myArray[i]);
}
return myArray;
}
}

2. Second Code I tried
public class StringArrayTest {
public static List<String> generateStringArray(Integer n) {
List<String> List1 = new List<String>();
for(Integer i =0; i < n; ++i)
List1.add('Test ' + i);
return List1;
}
}

I am executing this code from DEBUG > Open Execute Anonymous Window and writing below code to call method.

StringArrayTest.generateStringArray(5);

Please suggest, How can I fix this

Thanks
Pradeep
I'm currently using the Document object/table in SOQL to extract attachments in Salesforce classic.
As far as I'm aware in Lightning it is necessary to use File instead of Document object to extract attachments.
In SOQL there is no such File table and I need to know how to extract attachments data in Lightning Experience?
I'm new to code, can someone help and give me an idea how I can create an entry form as below with Lightning Component?
User-added image
Thanks!
Can anyone explain Difference between Process Builder and Flows with example ? 
Thanks in Advance. 
AJ
public with sharing class AccountListCon {
    static List<String> TARGET_FIELDS = new List<String>{
      'Name'
      ,'ServerName__c'
    };

    public SearchCondition condition{ get;set; }
    public List<AccountList__c> results { get;set; }
    public String sortingField { get;set; }


    public void init(){
        this.condition = new SearchCondition();
        this.results = new List<AccountList__c>();
    }


    public PageReference clear(){
        init();
        return null;
    }

    public PageReference search() {


        if( condition.validate() ){
            return null;
        }


        String soqlQuery = condition.getSoqlQuery();
        System.debug('[soql] ' + soqlQuery);

        try{
            this.results = database.query(soqlQuery);
            System.debug(this.results);
        }catch(DmlException e){
            ApexPages.addMessages(e);
            System.debug('[DmlException]' + e);
        }catch(Exception e){
            ApexPages.addMessages(e);
            System.debug('[Exception]' + e);
        }
        return null;
    }


    public PageReference sort(){

        if(this.sortingField == null ){
            return null;
        }


        if(this.sortingField == this.condition.sortkey){
            this.condition.setOrderReverse();
        }
        else {
            this.condition.sortkey = this.sortingField;
        }
        search();
        return null;
    }

    public String getSortKey(){
        return this.condition.sortkey;
    }

    public String getSortOrder(){
        return this.condition.sortOrderToString();
    }


    public Class SearchCondition {

    private Time JST_AM0 = Time.newInstance(9, 0, 0, 0);

        public AccountList__c obj {get;set;}

        public String sortkey { get;set; }
        public String order { get;set; }

        public SearchCondition() {
            this.obj = new AccountList__c();

            sortkey = 'LastModifiedDate';
            order = 'DESC';
        }


        public boolean validate(){
            boolean isError = false;

            return isError;
        }



        public String getSoqlQuery(){
            List<String> param = new String[]{ getFieldList(), getWhere(), getOrder() };
            return String.format('SELECT {0} FROM AccountList__c {1} {2} LIMIT 500', param);
        }

        private String getFieldList(){
            return String.join(TARGET_FIELDS, ',');
        }

        private String getWhere(){
            List<String> param = new String[]{ };

            if( !String.isBlank(this.obj.ServerName__c) ){
                param.add('ServerName__c LIKE \'%' + obj.ServerName__c + '%\'');
            }


            if(param.isEmpty()){
                return '';
            }
            return 'WHERE ' + String.join(param, ' AND ');
        }

        private String getOrder(){
            List<String> param = new String[]{ sortkey, order };
            return String.format('ORDER BY {0} {1}', param);
        }

        private DateTime adjustJSTtoGMS(DateTime day){
            JST_AM0 = Time.newInstance(15, 0, 0, 0);
            return Datetime.newInstance(day.date(), JST_AM0);
        }



        public String sortOrderToString(){
            if(this.order == 'DESC'){
                return '▼';
            }
            return '▲';
        }

        public void setOrderReverse(){
            if(this.order == 'DESC'){
                this.order = 'ASC';
            }
            else {
                this.order = 'DESC';
            }
        }
    }


}



VF
<apex:page controller="AccountListCon" action="{!init}" sidebar="false" Id="AccountRequestList" >

<script type="text/javascript">
    beenFocused = true;
</script>
<apex:form id="form1">
    <apex:pageBlock title="検索">
        <apex:pageMessages id="messagearea" showDetail="false"/>
        <apex:pageblockSection id="conditionSection" title="検索" columns="1">
            <apex:outputpanel id="searchcondition">
                <ul id="conditionTable">

                <li>
                    <span class="label"><apex:outputLabel value="サーバ名" for="ServerName" styleClass="labelCol" /></span>
                    <span><apex:inputField id="ServerName" value="{!condition.obj.ServerName__c}" /></span>
                </li>

                </ul>
            </apex:outputpanel>
        </apex:pageblockSection>
        <apex:pageBlockButtons id="buttonSection" location="bottom" >
            <apex:commandLink value="検索" action="{!search}" reRender="searchresult,messagearea" />

            <apex:commandLink value="クリア" action="{!clear}"   reRender="searchcondition,searchresult,messagearea"/>

        </apex:pageBlockButtons>
    </apex:pageBlock>
</apex:form>
<apex:outputpanel id="searchresult">
    <apex:pageBlock title="検索結果:" rendered="{!(results.size == 0)}">
         検索条件に該当するデータがありません
    </apex:pageBlock>

    <apex:form id="resultForm">
        <apex:pageBlock id="resultBlock" title="一覧" rendered="{!(results.size > 0)}">
            <apex:outputtext style="width:110px" value="結果 : {!results.size}件"/>

            <apex:pageblockTable id="resultTable" value="{!results}" var="o" frame="box">


                <apex:column style="width:80px">
                    <apex:facet name="header">
                        <apex:commandLink action="{!sort}" value="ID{!IF(sortKey == 'Name', sortOrder, ' ')}">
                            <apex:param value="Name" name="String" assignTo="{!sortingField}" />
                        </apex:commandLink>
                    </apex:facet>
                    <apex:outputlink value="/{!o.Id}"><apex:outputField style="width:80px" value="{!o.Name}"/></apex:outputlink>
                </apex:column>


                <apex:column style="width:80px">
                    <apex:facet name="header">
                        <apex:commandLink action="{!sort}" value="サーバー名{!IF(sortKey == 'ServerName__c', sortOrder, ' ')}">
                            <apex:param value="ServerName__c" name="String" assignTo="{!sortingField}" />
                        </apex:commandLink>
                    </apex:facet>
                    <apex:outputField style="width:150px" value="{!o.ServerName__c}"/>
                </apex:column>

            </apex:pageblockTable>

        </apex:pageBlock>
    </apex:form>
</apex:outputpanel>
</apex:page>

It was possible to here.
But how do I get pagination?


 
  • July 23, 2019
  • Like
  • 0
Hi All,

I have made a visualforce page and I want to render it as pdf and store in one field. I have created the apex class and using future callout for the generation of PDF. When I tried from the backend then the PDF is generating correctly but at the same time when I am trying from the site guest user then the content is not rendering on PDF. It is generating only the blank PDF. 

Please help me with this. How to resolve this issue.

Thanks!
I don't know how to write code in Salesforce but after a lot of digging and searching, I found a possible way of adding the Case Creator as a Case Team Member every time a new Case was created. Thus, I copied and paste one in my Sandbox and made the adjustments necessary to make it work for my ORG.
It is working fine in Sandbox, but while trying to deploy it from my sandbox using Change Sets. The trigger is failing with the following error:

"The following triggers have 0% code coverage. Each trigger must have at least 1% code coverage."

As I don't do coding I don't know what I can do in order to be able to move this successfully to my production environment. Any help is really appreciated. 

Thank you,
Erica
Hi All,
I want to get grand total of formula field.My report is meant to give the movement of work in progress value from month to month. For the same I have created two formula fields and every thing is working fine. Now what I want is to get grand total of one of the formula field. It is a matrix report. Please help me with this.

Thanks in advance.User-added image
 
Hi,
I created a process builder recently. As it was no longer in use I deleted it from my org. Now, while making any changes in the records I am still receiving the mail with error message regarding process builder failure. 
Error element myRule_1_A1 (FlowRecordUpdate).
The flow tried to update these records: 0034100000TxUl2AAF. This error occurred: ALL_OR_NONE_OPERATION_ROLLED_BACK: Record rolled back because not all records were valid and the request was using AllOrNone header.

It would be helpful of you if you can solve my problem.
Regards,
Deepali
Hi,
I am trying to create dashboard using Sales Analytics app. It seems that lot has been changed in Winter'18 release. While creating new app I am getting following ERROR: 33 User Dataflow Instructions executed, 41 failed.Please let me know how to resolve it. Thanks 
Hi All, 
I am new to Pardot. My requirement is to send email alert to user and an additional email whenever a Prospect is created in Pardot. I want to send the same email which is generated by default to assigned user only. I tried creating engagement studio and one-to-one email but was not able to find the solution. Please help me solve my issue
Hi All,
While setting up developer console for my Enterprise edition I don't know why it is not showing up in lightning inspite of the fact that lightning is enabled for the org.​ Can anyone help me with it?​
User-added image

Regards,
Deepali
Hi there, I'm not sure what's wrong with my logic here:

AND ( ISPICKVAL(A_la_carte__c, "")
)
OR (
ISPICKVAL( Opportunity_Type__c, "Video Ad Server"),  
ISPICKVAL( Opportunity_Type__c, "VAD Renewal"),
ISPICKVAL( Opportunity_Type__c, "Amendment"),
) )

I'm trying to say, if the opportunity type selected is any of the above, and a value is not selected in the drop down 'A_la_carte__c' then show validation rule. I'm getting the synax error "Extra OR." Thanks in advance for your help.
Hi,

I hit the First error: [null] AsyncApexExecutions Limit exceeded and now I can't start batches on the full sandbox because of It. I read that this is 24h limit so I waited for a day (week atm). Unfortunately, It didn't help. Is there a way to fix the sandbox?
trigger Count_Of_JobApp on job_application__c (after insert,after delete) 
{
    if((Trigger.isInsert && Trigger.isAfter) || (Trigger.isDelete && Trigger.isAfter))
    {
        Set<Id> parentIdsSet = new Set<Id>();
        List<Position__c> positionList = new List<Position__c>();
        if(Trigger.isInsert){
            for(job_application__c jobObj : Trigger.new){
                parentIdsSet.add(jobObj.Total_Job_Application__c);
            }
        }else if(Trigger.isDelete)  {
            for(job_application__c jobObj : Trigger.old){
                parentIdsSet.add(jobObj.Total_Job_Application__c);
            }   
        }
        
        System.debug('parentIdsSet-->'+parentIdsSet);
        if(parentIdsSet.size() > 0){
            positionList = [SELECT Id,
                            Name,
                            Count_Of_Job_App__c,
                            (SELECT Name
                             FROM job_applications__r)
                            FROM Position__c
                            WHERE Id IN : parentIdsSet];
        }
        System.debug('positionList-->'+positionList);
        if(positionList.size() > 0){
            for(Position__c postionObj : positionList){
                postionObj.Count_Of_Job_App__c = postionObj.job_applications__r.size();//Error on this line.
            }
            update positionList;
        }
    }
}
I recently started completing the 'Build Lightning Web Components' trail on Trailhead and as much as it is informational and pretty cool I am getting more and more confused about terminology. 

They refer to 'Lightning Web Components'... are these different from 'Lightning Components'? If so, how?

'Lightning Components' is just another term for 'Aura Components', right?

Finally, how do 'VisualForce Components' tie into all of this?
  List<Lead> numberOfLeads = [select Id from Lead];
   System.debug(numberOfLeads.size());

I need number of Leads but above my code is returning 0 always, please help me. thanks in advance
Custom roll-up – Keep relation between Position and Job application as lookup. Create a number field on Position object. This field should contain count of its child job applications. Do this using a trigger.
Hello all

i am new to the vf, i am trying to populate the field values in a table format for the custom object, (i have not used Custom controllers)
how do i populate the field values in 2 columns like shown in the snapshot




below is my code

<apex:page standardController="Apartment__c" showHeader="false" renderAs="pdf" DocType="html">
<apex:form >
   <apex:pageBlock title="Appartment Details">
           <apex:pageBlockSection >
         <table style="width:100%">   
         <tr> 
          <td> <apex:outputField value="{! Apartment__c.Name }" /> </td>
          <td> <apex:outputField value="{! Apartment__c.Floor_No__c }"/> </td>
          <td> <apex:outputField value="{! Apartment__c.Phase__c }" /> </td>
         <td> <apex:outputField value="{! Apartment__c.Property_No__c }"/> </td>
         <td> <apex:outputField value="{! Apartment__c.Facing__c }" /> </td>
          <td> <apex:outputField value="{! Apartment__c.Terrace_Area_Cost__c }"/> </td>
          </tr> 
    </table>
    </apex:pageBlockSection>     
</apex:pageBlock>
</apex:form>
</apex:page>

it should show something like this
Hi all,
I have created a batch class but still i am getting error "First error: Too many Email Invocations: 11" .

Can anyone solve this issue.
Below is my batch class.
global class batchexpense implements Database.Batchable<sObject> {
    
    global Database.QueryLocator start(Database.BatchableContext BC){
        
       String query = 'Select Name_of_Employee__c from Expense_Management__c where CreatedDate = LAST_N_DAYS:15';
       return Database.getQueryLocator(query);
     }
    
	global void execute(Database.BatchableContext BC, List<Expense_Management__c> scope){
   		Set<String> myset = new Set<String>();
		for(Expense_Management__c aa : scope)
		{
  			myset.add(aa.Name_of_Employee__c);  
		}    
				
		
   		 for(Expense_Management__c cc : [select id,Name_of_Employee__r.email,Name_of_Employee__c from Expense_Management__c WHERE Name_of_Employee__c =: myset ])
        {
         
            list<Messaging.SingleEmailMessage> mails =  new List<Messaging.SingleEmailMessage>();  
            Messaging.SingleEmailMessage semail = new Messaging.SingleEmailMessage();
			Messaging.EmailFileAttachment attach = new Messaging.EmailFileAttachment();
            PageReference pref = page.ExpenseReport;
            pref.getParameters().put('Id',cc.Name_of_Employee__c );
            pref.setRedirect(true);
             Blob b;
             if(Test.isRunningTest()) { 
                b = blob.valueOf('Unit.Test');
            } else {
                b = pref.getContent();
            }
            attach.setFileName('Expense.pdf');
            attach.setBody(b);
            semail.setSubject('Expense details');
            semail.setSaveAsActivity(true);
         
            semail.setReplyTo('noreply@gmail.com');
            semail.setSenderDisplayName('salesforce User');
            semail.setWhatId(cc.Id);
     
            
            List<String> sendTo = new List<String>();//to string
           	sendTo.add(cc.Name_of_Employee__r.email);
            semail.setToAddresses(sendTo);
           
            mails.add(semail);
            String emailBody =' <html><body><p> Dear  ,<br><br> Please find the attached Expense details. <br><br>    Regards, <br> IT Team <br>  Sayaji Groups.</p></body></html>';
            semail.setHtmlBody(emailBody);
            semail.setFileAttachments(new Messaging.EmailFileAttachment[]{attach});
            Messaging.sendEmail(new Messaging.SingleEmailMessage[]{semail});
        }
     }
    
    	global void finish(Database.BatchableContext BC){
        
    	}
}

Thanks in advance
Hi folks,

I've been trying to look for a solution with no luck.
Simply, I'm trying to write an apex trigger to check whether a date/time field is empty while a status field is set to a specific value at the creation or the update of a record...

Any help much appreciated. Thanks
i have this below result from apex 
 
result =

    [  
       {  
          "Id":"0012v00002InPVmAAN",
          "Test__c":"India; Africa; Mombasa",
          "Test1__c":"AFR; TFR; GFR"
       }
    ]

i am able to generate csv as below -
"Id,Test__c,Test1__c
"0012v00002InPVmAAN","India; Africa; Mombasa","AFR; TFR; GFR"

i am want to create a csv file out of the above data, basically splitting semicolon separated values into multiple rows with other data
"Id,Test__c,Test1__c
"0012v00002InPVmAAN","India","AFR"
"0012v00002InPVmAAN","Africa","TFR"
"0012v00002InPVmAAN","Mombasa","GFR"

JS - 
 
downloadCSVFile() {
        let rowEnd = '\n';
        let csvString = '';
        // this set elminates the duplicates if have any duplicate keys
        let rowData = new Set();
        // getting keys from data
        this.data.forEach(function (record) {
            Object.keys(record).forEach(function (key) {
                rowData.add(key);
            });
        });
        // Array.from() method returns an Array object from any object with a length property or an iterable object.
        rowData = Array.from(rowData);
        // splitting using ','
        csvString += rowData.join(',');
        csvString += rowEnd;
        // main for loop to get the data based on key value
        for (let i = 0; i < this.data.length; i++) {
            let colValue = 0;

            // validating keys in data
            for (let key in rowData) {
                if (rowData.hasOwnProperty(key)) {
                    // Key value 
                    // Ex: Id, Name
                    let rowKey = rowData[key];
                    // add , after every value except the first.
                    if (colValue > 0) {
                        csvString += ',';
                    }
                    // If the column is undefined, it as blank in the CSV file.
                    let value = this.data[i][rowKey] === undefined ? '' : this.data[i][rowKey];
                    csvString += '"' + value + '"';
                    colValue++;
                }
            }
            csvString += rowEnd;
        }

 
Hey guys , I am beginner to salesforce, My requirement is to write the Apex trigger,
-- Suppose I have 1 account Name X and It has 2 contacts, so for the same account X , the email of the Contacts should not be same , if same It should show error. Suppose 1 contact email is abc@g.com and 2 contact email is xyz @g.com , this should be accepted. if both contact has same email address then it should not be accepted.

But  if have another account Name Y and it has 2 contact, and if email of 1 of the contact is abc@g.com  which is the email of  contact of account  X then it should be accepted, 

So please suggest me the apex trigger for the above requirement.
Note- Please dont share any link for this,, if possible give me explanation with example 

Thank you
I have a visualforce page and the standard object is the Account. I'm trying to map a field from the related child record to the account visualforce page.

I'm not sure how to map the field {!Account.Bids_Sent__c.Test__c} on the visualforce page. 

 I am getting the following error.

Error: Invalid field Bids_Sent__c for SObject Account
 
I use the follwing query to find the median account revenue
List<AggregateResult> totalOppsClosedWon365 = [select AccountId, sum(Amount__c) Revenue, Account.Stage__c
 from Opportunity
where CloseDate = LAST_N_DAYS:365 and StageName = 'Closed Won' 
group by AccountId, Account.Stage__c
order by sum(Amount__c) asc];
but how do I access the Revenue value at the specific index which marks the center of the list? For example the Revenue at index 100 because this is the center of the list. 

I apprechiate any help! 
 
Hi Team,

I need help on testclass for below lightning componnet apex class.
Can anyone help me on this .


public class LightningTabComponentController {
/* Method to fetch the parameters used for framing the URL*/ 
    
   @AuraEnabled
    public static OpptyRelatedData getCustomsettingValue()
    {
       OpptyRelatedData returnrelateddata = new  OpptyRelatedData ();
        
       string cusseturl= SMX_URL__c.getInstance().SMX_URL__c;
       returnrelateddata.SMX = cusseturl;
        
       string cusseturl1 = SFDC_URL__c.getInstance().SFDC_URL__c;
       returnrelateddata.SFDCURL = cusseturl1;
        
       String username = UserInfo.getUsername();
       returnrelateddata.username=username;
        
       String sessionId = UserInfo.getsessionId();
       returnrelateddata.sessionId=sessionId;
        
        
       String npxaccview = SFDC_URL__c.getInstance().NPX_Account_View_Embed__c;
       returnrelateddata.npxaccview=npxaccview;
        
        String npxconview = SFDC_URL__c.getInstance().NPX_Contact_View_Embed__c;
       returnrelateddata.npxconview=npxconview;
        
         string urler = URL.getSalesforceBaseUrl().toExternalForm();
        returnrelateddata.urler=urler;
           
       system.debug('returnrelateddatareturn======>'+returnrelateddata); 
       return returnrelateddata;
    }
    
    public class OpptyRelatedData{
        @AuraEnabled 
        Public string SMX{get;set;}
        @auraEnabled
        public string SFDCURL{get;set;}
        @auraEnabled
        public string username{get;set;}
        @auraEnabled
        public string sessionId{get;set;}
        @auraEnabled
        public string npxaccview{get;set;}
        @auraEnabled
        public string npxconview{get;set;}
        @auraEnabled
        public string urler{get;set;}
        
        
    } 
    
}


Regards,
Isha
I parent Object and child object 

Parent: state
Parent Field: Status(picklist Field): values are:(IN,OUT)
Child :city
Child Field: Yes(Check Box)

Need help in writing a trigger : 

Scenerio:When ever picklist values are changed ex: IN to OUt  or OUT to IN The trigger need to Check the YES filed and immediately Uncheck.

 
  • August 02, 2019
  • Like
  • 0