• Neha Aggrawal
  • NEWBIE
  • 464 Points
  • Member since 2017
  • initaura.com


  • Chatter
    Feed
  • 15
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 114
    Replies
Please help me to solve this!

Create a custom object called as 'Logs'. Create a long text area field called as 'Error'.
Create 100 Lead records using DML operations having a unique name. For all records which were not inserted into Lead object, insert a record in Log object along with the reason why a record was not inserted. Also, execute assignment rules to auto allocate Lead records to correct owner.

Thanks in advance.
I have created a custom list button:
User-added image
with URL :
User-added imageWhen I am clicking on New Customer, it is redicrecting to this link:
User-added image
but the lookup field is not getting populated:
User-added image

Is there anything I am doing wrong?

Thanks,
Hi,
I'm creating an email service class.
I need to read the body of the email template which I'm receiving and I
need to update the status on the custom field based on the template message.
condition to check id and error reason or success reason.
could you please help me with this.

Thanks in advance.
Hello,

I need some help in my test class which has written on Trigger.

My Test Class :

@isTest
public class AccountNameUpdate {  
  @isTest  static void updateAccount(){
        Account a = new Account();
        a.Name = 'Abhishek Gupta';
        insert a;
        Booking_Link__c bl= new Booking_Link__c();
        bl.Customer_Number__c = a.Customer_Number__pc;
        bl.T2G__c =True;
        bl.Account__c = a.Id;
        bl.OwnerId = a.OwnerId;
        update bl;
    }

}


My Trigger:

trigger AccountNameUpdate on Booking_Link__c (before insert, before update) {
    List<Account> accountList = new List<Account>();
    String CustomNumber;
    for(Booking_Link__c bl : Trigger.new)
    {       
        CustomNumber = bl.Customer_Number__c;
       
    }
    accountList = [Select Id, OwnerId, Customer_Number__pc from Account where Customer_Number__pc =:CustomNumber ];
    for(Booking_Link__c bl : Trigger.new)
    {
        for(Account a : accountList)
        {
           if(bl.Customer_Number__c == a.Customer_Number__pc && bl.T2G__c==True)
            {
                bl.Account__c = a.Id;
                bl.OwnerId = a.OwnerId;
                  
            }
        }
    }  
}

Please Help me out from this

Thanks and Regards,
Azar Khasim.
Here i have created Picklist(Premium_Type :  monthly, quarterly, half-yearly and annually) , Premium_start_Date, End_Date and Premium_Due_Date and with some help updated the code, which is a static one. The code is 

public with sharing class LICDueDate 
{
  public static void DueDateInsert (list<Life_Insurance_Data__c> Due)
    {
        for(Life_Insurance_Data__c D : Due)
            if(D.Premium_Type__c == 'Monthly')
        {
            D.Premium_Due__c = D.Premium_Start_Date__c.addMonths(1) - 5;
        }
        else if(D.Premium_Type__c == 'Quarterly' )
        {
            D.Premium_Due__c = D.Premium_Start_Date__c.addMonths(3) - 5;       
        }
        else if(D.Premium_Type__c == 'Half-Yearly')
        {
            D.Premium_Due__c = D.Premium_Start_Date__c.addMonths(6) - 5;
        }
        else if(D.Premium_Type__c == 'Yearly')
        {
            D.Premium_Due__c = D.Premium_Start_Date__c.addMonths(12) - 5;
        }                                                                 
     }

Here the code works fine and i got one problem. 

I am getting Due Date correctly for the 1st time and it is not working when the due date has paid, it should move on to the next month due date. please refere the image below.

User-added imageHere i need like If i choose (D.Premium_Type__c == 'Monthly') and start date is 01/02/2019.
The premium due will be : 24/02/2019 ( perfect till now)

when i paid my Due amount on or before 24/2/2019 in my "LIC_Payement_Gateways" and considering my "Paid_Date__c", the  due date should change to next month : 27/03/2019 and it should go on with Monthly, quarterly, half-yearly and yearly ( this is what i want to do )

Any one can help me in this ?

Thanks in advance.
 
Hi All,

I have been stuck in test class and not getting a way to solve the issue.
I have a VF page and controller. VF page is basically an input form where an user can fill up their information and Save.Once Save the controller will exceute and save the record to a custom object.In input form I have an input field where user can key in their email address.Upon save an email should go to the email address which has been specified in email input field.Functionality is working fine though the issue is with the test class.I understand to test email messaging we need to ensure we are inserting the correct data/record which I am doing but upon running the test class I am getting error : System.EmailException: SendEmail failed. First exception on row 0; first error: INVALID_EMAIL_ADDRESS, Email address is invalid: null: [toAddresses, null]
Below is a part from my VF page:
<apex:page standardController="Driver_Survey__c" extensions="SurveyForDriverController" sidebar="false" lightningStylesheets="true">
    
    
    <apex:form > 
       
        <apex:pageBlock mode="edit" >
            <apex:pageBlockSection columns="1" collapsible="false" title="Driver Information"  >
                <apex:inputField label="Name" value="{!survey.Name__c}" required="true"/>
                <apex:inputField label="Mobile" value="{!survey.Mobile__c}" required="true" />
                <apex:inputField label="Email" value="{!survey.Email__c}" required="true" />
                	
  
            </apex:pageBlockSection>
          
            <apex:pageBlockButtons >

                <apex:commandButton value="Save" action="{!doFullSave}"/>
                  
                    <apex:commandButton value="Cancel" action="{!doCancel}" immediate="true"/>
           
            </apex:pageBlockButtons> 
        </apex:pageBlock>

    </apex:form>
</apex:page>

Below is the Save function snippets:
public class SurveyForDriverController{

    public Driver_Survey__c survey{get;set;}

    public SurveyForDriverController(ApexPages.StandardController controller){
         survey=new Driver_Survey__c();
      
    }
    public PageReference doFullSave(){
        system.debug('message1>>'+survey );
       	insert survey; 
      
  
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
        mail.toAddresses = new String[] { survey.Email__c };
            
		system.debug('message110>>'+mail.toAddresses  );
        mail.subject = 'Subject Test Message';
        //mail.plainTextBody = 'This is a test mail';
        String body = 'Hi \n  ';
       
        body += + survey.Name__c+ '<br><br>' ;
        body+= +'Request you to kindly fill in the questionnaire';
     
        mail.setHtmlBody(body);
        Messaging.SingleEmailMessage[] mailss =   new List<Messaging.SingleEmailMessage> {mail};
        Messaging.SendEmailResult[] results = Messaging.sendEmail(mailss);
         if (results[0].success) 
                {
                    System.debug('The email was sent successfully.');
                } else 
                {
                    System.debug('The email failed to send: ' + results[0].errors[0].message);
                }
       
        PageReference pageRef = new PageReference('/'+survey.Id);
        pageRef.setRedirect(true);
        return pageRef;
        }
    public PageReference doCancel(){
        PageReference pageRef = new PageReference('/');
            pageRef.setRedirect(true);
            return pageRef;
    }
   
}

Below is my test clas:
@isTest
public class TestSurveyForDriverController {

    
     static testMethod void test () {
         
       Driver_Survey__c driverSurvey=new Driver_Survey__c();
        driverSurvey.Customer_Experience__c='6';
        driverSurvey.Email__c='test@test.com';
        driverSurvey.Expected_Earnings_Weekly__c=10000;
        driverSurvey.How_long_have_you_been_working_there__c=6;
        driverSurvey.Will_you_be_planning_to_drive_for_Grab__c='Yes';
        driverSurvey.Kind_of_car_are_you_using_Rental_Car__c='Honda City';
        driverSurvey.Name='testuser1';
        driverSurvey.Name__c='testuser1';
        driverSurvey.Customer_Experience__c='All of the Above';
          insert driverSurvey;

       ApexPages.StandardController ctlr = new ApexPages.StandardController(driverSurvey);
       GrabSurveyForDriverController grabController=new GrabSurveyForDriverController(ctlr);

        grabController.doFullSave();
         grabController.doCancel();

    }
}

I am passing correct Email while creating the survey record but test class showing invalid toAddress,null

Any help would be greatly appreciated

Kindly help

Many thanks in advance​​​​​​​​​​​​​​​​​​​​​
string jsonexample1 = ' { "states" : [ "india", "alaska", "china" ] } ';


how to parse the data in the picklist in the apex:repeat functionalities , 

Another scenario :

 if the data is 

 string jsonexample2 =  ' { "overalldata": [ {"stateName": "Andrapradesh",  "taxpercent": 15.0 }, { "stateName": "Telangana",  "taxpercent": 18.0 }, {"stateName": "Banglore",  "taxpercent": 16.0 } , {"stateName": "Maharastra",  "taxpercent": 14.0 }  ] } '; 


here i need to get the statename in the picklist and taxpercent in a  Repeat table .. can anybody guide me how to proceed thanks ... 






 
global class SendReminderEmail implements Database.Batchable<sObject> {
    global Database.QueryLocator start(Database.BatchableContext bc) {
    }
    global void execute(Database.BatchableContext bc, List<Speaker__c> scope) {
    }
    global void finish(Database.BatchableContext bc) {
    }
}
========================================
Compile Error: Missing return statement required return type: Database.QueryLocator at line 2 column 34    
Hello, I created a scheduled job to run every sunday. The code creates an attendance record for each program participant for each day they are signed up for that week. I tested the code and recieved 85% code coverage. I deployed the code to production and the first sunday it did not run at all. I then scheduled it to run from the scheduled job interface. It ran this past sunday but it did not create any attendances. Any help would be appreciated.

global class createSoulAttendance implements Schedulable {
    
    public static final String CRON_EXP = '0 0 12 ? * SUN';
    global static String scheduleIt() {
        createSoulAttendance job = new createSoulAttendance();
        return System.schedule('Soul Attendance', CRON_EXP, job);
    }
    global void execute(SchedulableContext ctx) {
        
        //Create List to store Program Enrollment Ids
        List<id> enroll = new List<id>();
        
        //Find all attending Soul Participants with Status Confirmed
        for(Program_Enrollment__c enrollId : [SELECT ID FROM Program_Enrollment__c WHERE Campaign__r.Name = 'Soul Studio'
                                              AND Status__c = 'Confirmed']) {
                                                  
                                                  enroll.add(enrollId.Id);
                                              }
        
        
        //Create List to store Volunteer Shift Ids
        List<id> vol = new List<id>();

        //Find Volunteer Shift Ids and add them to the list
        for(GW_Volunteers__Volunteer_Shift__C volId : [SELECT ID FROM GW_Volunteers__Volunteer_Shift__C  WHERE Program__r.Name = 'Soul Studio'AND Shift_Start_Date__c > TODAY 
                       AND Shift_Start_Date__c = NEXT_n_DAYS:7]){
                                                           
                                                          vol.add(volId.Id);
                                                       }
        
        //Create Attendance for each program enrollment
        //Loop through enrollments
        for(Integer i = 0; i < enroll.size(); i++) {
            
            Program_Enrollment__c ProEnroll = new Program_Enrollment__c();
            
            ProEnroll.Id = enroll[i];
            
            //Loop through Volunteer Shifts
            for(Integer j = 0; j < vol.size(); j++) {
                
                GW_Volunteers__Volunteer_Shift__c volunteerShift = new GW_Volunteers__Volunteer_Shift__c();
                
                volunteerShift.Id = vol[j];
                
                //Create attendance for each enrollment
                Attendance__c att = new Attendance__c(Session__c = volunteerShift.Id, Program_Enrollment__c = ProEnroll.Id);
                //Insert Attendance
                insert att;
            }
            
        }
    }

}
Hello,
I am having a couple issue on my VF page in regard to rendering Dependant Picklist Value,
The main picklist filed is fine.  But once a value is select the dependant picklist field(Category) are not correct.
Either it does not show or it is duplicated multiple time.

Also, the Last picklist field SubCategory is not populating any values at all and I am not sure if its the VF or Apex Code.
Any help is appreciated,
M

Controller:
public class MerchandisingController {
    
    
    public string Merchandise{ get; set; }
    public string Category{ get; set; }
    public string SubCategory { get; set; }
       
    public MerchandisingController (ApexPages.StandardController controller) 
    {
        Merchandise= Category= SubCategory = null;    
    }

 public List<SelectOption> getListMerch() 
     {
        List<SelectOption> options = new List<SelectOption> { new SelectOption('','-- Choose Merchandise --') };
        for(Schema.PicklistEntry pe:Merchandising__c.Merchandise__c.getDescribe().getPicklistValues()) {
            options.add(new SelectOption(pe.getValue(),pe.getLabel()));
        }
        return options;
    }
    
    
     public List<SelectOption> getListCategory() 
     {
        List<SelectOption> options = new List<SelectOption>();
        if(Merchandise == null || Merchandise == '')
            return options;
        options.add(new SelectOption('','-- Choose Category --'));
        for(Merchandising__c cat:[select id,Merchandise_Category__c from Merchandising__c where Merchandise__c= :Merchandise]) {
            options.add(new SelectOption(cat.id,cat.Merchandise_Category__c ));
        }
        return options;
    }
    
    public List<SelectOption> getListSubCategory() 
    {
        List<SelectOption> options = new List<SelectOption>();
        if(Category==null || Category== '')
            return options;
        options.add(new SelectOption('','-- Choose SubCategory --'));
        for(Merchandising__c sub:[select id,Merchandise_SubCategory__c from Merchandising__c where Merchandise_Category__c = :Category]) {
            options.add(new SelectOption(sub.id,sub.Merchandise_SubCategory__c));
        }
        return options;
    }
    
 }

Visualforce Page
<apex:page standardController="Merchandising__c" extensions="MerchandisingController">

      <apex:form id="Merchandising">
        <apex:sectionHeader title="Choose Merchandizing"/>
        <apex:pageBlock title="Demo Page">
            <apex:pageBlockSection columns="1">
                <apex:pageBlockSectionItem >
                    <apex:outputLabel >Merchandise</apex:outputLabel>
                    <apex:selectList size="1" multiselect="false" value="{!Merchandise}">
                        <apex:selectOptions value="{!ListMerch}"/>
                        <apex:actionSupport reRender="Merchandising" event="onchange"/>
                    </apex:selectList>
                </apex:pageBlockSectionItem>
                <apex:pageBlockSectionItem >
                    <apex:outputLabel >Category</apex:outputLabel>
                    <apex:selectList value="{!Category}" size="1" multiselect="false">
                        <apex:selectOptions value="{!ListCategory}"/>
                        <apex:actionSupport reRender="Merchandising" event="onchange"/>
                    </apex:selectList>
                </apex:pageBlockSectionItem>
                <apex:pageBlockSectionItem >
                    <apex:outputLabel >SubCategory</apex:outputLabel>
                    <apex:selectList value="{!SubCategory}" size="1" multiselect="false">
                        <apex:selectOptions value="{!ListSubCategory}"/>
                        <apex:actionSupport reRender="Merchandising" event="onchange"/>
                    </apex:selectList>
                </apex:pageBlockSectionItem>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
 </apex:page>


 
I have a custom object Daily_Forecast__c, with a field called Forecast_Amount__c (currency) and another field that looks up to User. For each day I need to update the custom field on User.Monday__c with the corresponding Forecast_Amount__c from the Daily_Forecast__c object. There will only ever be one forecast record for each day. I feel I am almost there but my for loop is looping through all forecast records instead of just the one with the correct user lookup. How do I match the User to the Forecast record in my loop? 
//list of forecasts for user & direct reports (this is working)
        fList = new List<Daily_Forecast__c>([SELECT Id,User__r.Name,User__r.Team__c,User__r.Territory__c,User__r.UserRole.Name,Split_Forecast_Amount__c,Forecast_Amount__c,Day__c,Day_Date__c,RecordType.Name 
                                                   FROM Daily_Forecast__c 
                                                   WHERE Date__c = THIS_WEEK 
                                                    AND (RecordType.Name = 'Daily Forecast' OR RecordType.Name='Weekly Forecast - Monday' OR RecordType.Name='Weekly Forecast - Thursday')
                                                   AND User__c IN :myTeam]);
        system.debug('fList '+fList);
//MONDAY - add forecast records from monday to monday list (this is working)
        MondayListE = new List<Daily_Forecast__c>();
            for(Daily_Forecast__c e :fList){
                if(e.Day__c=='Monday' && e.RecordType.Name=='Daily Forecast'){
                    MondayListE.add(e);}}
        system.debug('MondayListE should be daily forecasts from fList with day=monday '+MondayListE);
//get users who are represented in the list of Monday forecasts (this is working)
        userMon = new List<User>([SELECT Id, Name,Monday__c FROM User WHERE Id IN (SELECT User__c FROM Daily_Forecast__c WHERE Id IN :MondayListE)]);
        system.debug('userMon '+userMon);
//my for loop - should loop through the list of users and update them with monday's forecast amount - not working - every user ends up with the same amount, the forecast amount from the last user in the list
        if(userMon.size()>0){
            for(User u :userMon){
                for(Daily_Forecast__c f :MondayListE){
                    u.Monday__c = f.Forecast_Amount__c;
                    update u;
                    system.debug('updates on users '+u);
                }
            }

Please help! Thanks in advance.
I have a custom controller where I have a set of conditional statements (if, else if) to set the mail.setTemplateId.  I am trying to write a test class to cover these if statements but I can't figure out how to use TemplateId for the test.
Hi! 

I am very new to Visualforce and Apex and have recently created a VisualForce form to replace web-to-case and enable attachment uploading. It all seems to work, but I have no idea how to add style to the button. Any suggestions on that maybe?

User-added imageUser-added image
Hi,

Please see below screen shot:

User-added image
How do I add objects in the create section, like I have a custom object called Consulting. How can I show New Consulting here ?

Thanks.
Hi,

I am calling teamup API from Salesforce to get events data. This is my apex code:
global class EventsTeamUp {
@future(callout=true)
    Public Static Void UpdateEvents(){
         HttpRequest req = new HttpRequest();
        HttpResponse res = new HttpResponse();
        String result;
        Http http = new Http();
        datetime dt=System.now();
     	dt=dt-(1);
		String d=dt.format('yyyy-MM-dd');
		List<Event> eventlist = new List<Event>();
        
        req.setMethod('GET' );
        req.setEndpoint('https://api.teamup.com/ks6mg6ziqj7cgg84qz/events?startDate='+d+'&endDate='+d);
        Blob headerValue = Blob.valueOf('teamup-token' + ':' + 'e1bb9869fab6320f4ff7ca23eeb48b80a9e113396b903d794d9e3fcaf857ff3f');
     String authorizationHeader = 'BASIC ' +
     EncodingUtil.base64Encode(headerValue);
     req.setHeader('Authorization', 'authorizationHeader');
        try{
        res=http.send(req);
        result=res.getBody();
Map<String, String> values = (Map<String, String>)
    JSON.deserialize(res.getBody(), Map<String, String>.class);
        System.debug(values);
        for(String key : values.keySet())
        {
           Event e= new Event(IsAllDayEvent=Boolean.valueOf(values.get('all_day')), Subject=values.get('title'), StartDateTime=DateTime.parse(values.get('start_dt')), EndDateTime=DateTime.parse(values.get('end_dt')), Location=values.get('location'), Description=values.get('notes')+'Invitees:'+values.get('who'));
            eventlist.add(e);
        }
        insert eventlist;
        }
    
    catch(Exception e)
    {
       System.debug('The following exception has occurred: ' + e.getMessage()); 
    }
}
}

I am getting 403 Forbidden error. This is the request sent from Adavnced Rest Client, where I am getting back the event details successfully.

User-added image

Any help is appreciated.
Thanks.
I have one requirement: to make one of the multi select picklist fields as searchable. Meaning as I type the first letter, drop down with that value should be shown. How can that be done. I know it is not possible in Salesforce out of box. Can it be done through lightning components.

Thanks
Please help me to solve this!

Create a custom object called as 'Logs'. Create a long text area field called as 'Error'.
Create 100 Lead records using DML operations having a unique name. For all records which were not inserted into Lead object, insert a record in Log object along with the reason why a record was not inserted. Also, execute assignment rules to auto allocate Lead records to correct owner.

Thanks in advance.
Hi, I would like to integrate my website with Salesforce, so that if a website user inputs their information on the contact sheet, all that info will automatically go into Salesforce and I do not have to input it manually. Can anyone help with this?
Hello Developers

i am new to the Salesforce, and i am trying to lear Formula fields, i have been given a task where Start Date and End date should show when custom field(Month__c) is selected, Now if i try to put Year, it shows error, 
 
Quota Start Date

DATE(
YEAR(TODAY()),
CASE(TEXT(Month__c), 
"January", 1, 
"February", 2,
"March", 3,
"April", 4,
"May", 5,
"June",6,
"July", 7,
"August",8, 
"September", 9,
"October", 10,
"November", 11,
"December", 12,
0),
1
)
----------------------------- 
Quota End Date

DATE(
YEAR(TODAY()),
CASE(TEXT(Month__c), 
"January", 1, 
"February", 2,
"March", 3,
"April", 4,
"May", 5,
"June",6,
"July", 7,
"August",8, 
"September", 9,
"October", 10,
"November", 11,
"December", 12,
0),
1
)

Now i want to add Picklist Field Name called Quater Year (Quater_Year__c), it consist of Number of Years from 2020 to 2030

So my requirement is when i select Picklist Quater Year as 2022 and Picklist Month as Jan, the Quota Start Date and Quota End Date should show for that particular Year i.e Jan 1st 2022 and Jan 31st 2022

but i am getting an error

User-added image
How do i resolve this issue??
HI there,

I am very new to salesforce integration. I am trying to consume third party web api so i can push data from salesforce via third party API. I am struggling with setting up the configuration. I have tried to create connected app and added third party api end point as call back. I am not sure if its the right way to do it?  Is there any documentation i can refer to for consuming third party rest API using oauth 2 using named instance?   I be using HTTP call out. So entire confusion is under named instance where i have selected oauth 2 and when i try to set auth provider i am not sure what auth provider type i have to choose i can see salesforce , google, linkedin etc. Since salesforce is consuming it. 
Hi,

As I am unable to complete the code coverage in batch apex.
global class countContactRecordsBatch implements Database.Batchable<sObject> {
    global Database.QueryLocator start(Database.BatchableContext bc) {
        string query='select id,Census_Date__c from hed__Term__c where Census_Date__c=LAST_N_DAYS:1';
        system.debug('query' +query) ;
        return Database.getQueryLocator(query); 
    }
    
    global void execute(Database.BatchableContext bc, List<hed__Term__c> scope){
        
        list<hed__Term__c> termList=[select id from hed__Term__c where Census_Date__c=LAST_N_DAYS:1];
        list<hed__Course_Offering__c> moduleOfferingList=[select hed__Term__r.id,(select hed__Contact__r.id,hed__Program_Enrollment__r.Program__r.id  from hed__Course_Enrollment__r) from hed__Course_Offering__c where hed__Term__r.id IN:termList];
        Map<string,set<string>> termProgramContacts=new Map<string,set<string>>();
        for(hed__Course_Offering__c co:moduleOfferingList) {
            system.debug('Term Id-'+co.hed__Term__r.id);   
            
            for(hed__Course_Enrollment__c ce:co.hed__Course_Enrollment__r){
                string mapKey = co.hed__Term__r.id+'-'+ce.hed__Program_Enrollment__r.Program__r.id;
                if(ce.hed__Program_Enrollment__r.Program__r.id!=null){
                    if(termProgramContacts.containsKey(mapKey)){
                        set<string> existingValue = termProgramContacts.get(mapKey);
                        existingValue.add(ce.hed__Contact__r.id);
                        termProgramContacts.put(mapKey, existingValue);
                    }                       
                    else{
                        set<string> newValue = new set<string>();   
                        newValue.add(ce.hed__Contact__r.id);
                        termProgramContacts.put(mapKey,newValue);
                    }
                }
            }
        }
            
            system.debug('Program Contact- '+termProgramContacts);
            list<hed__Term__c> termProgramList=new list<hed__Term__c>();
            list <Program_Session__c> programSessionList = new list <Program_Session__c>();
            termProgramList=[select id,(select id,Program__r.id from Program_Sessions__r) from hed__Term__c where id IN:termList];
            Map<string,integer> updateCount = new Map<string,integer>();
            for(hed__Term__c termProgram:termProgramList){
                for(Program_Session__c ps:termProgram.Program_Sessions__r){
                    string tpKey = termProgram.id+'-'+ps.Program__r.id;
                    if(termProgramContacts.containsKey(tpKey)){
                        integer contactCount = termProgramContacts.get(tpKey).size();
                        integer existingCount = 0;
                        if(updateCount.containsKey(ps.id)){
                            existingCount = updateCount.get(ps.id);                         
                        }
                        updateCount.put(ps.id,contactCount+existingCount);//progran term id and count
                        system.debug('updateCount'+updateCount.values().size());
                    }
                    ps.Total_enrolments_actual__c=updateCount.get(ps.Id);
                    programSessionList.add(ps);
                    system.debug('Total_enrolments_actual__c' +ps.Total_enrolments_actual__c);                    
                    system.debug('termProgramList ' +termProgramList);            
                }
            }
            if(programSessionList!=null && !programSessionList.isEmpty()){
                update programSessionList;
                
                
            }
        
    }
            global void finish(Database.BatchableContext BC){
                
            }

       
    //code end
    
   
}
===
Test class
=====

@isTest
public class countContactRecordsBatchTest {
    
    static testMethod void contactRecords(){
        
        list<Program_Session__c> psList=new list<Program_Session__c>();
        list<Account> acc=new list<Account>();
        list<hed__Term__c> termList=new list<hed__Term__c>();//term 
        list<Program__c> programList=new list<Program__c>();
        list<hed__Course_Offering__c> mcList=new list<hed__Course_Offering__c>();
        list<hed__Course__c> courseList=new list<hed__Course__c>();
        list<hed__Program_Enrollment__c> prEnrollmentList=new list<hed__Program_Enrollment__c>();
        list<Contact> consList=new list<contact>();
        
        
        Account a=new account();
        a.Name='Test Account';
        acc.add(a);
        
        insert acc;
        
        hed__Term__c te=new hed__Term__c();
        te.Name='test term';
        te.hed__Account__c=acc[0].id;
        te.Census_Date__c=date.today();
        termList.add(te);
        insert termList;//Term
        
        Program__c pc=new Program__c();
        pc.Name='test program ';
        programList.add(pc);//Program ..
        
        
        //insert module offering
        hed__Course_Offering__c mc=new hed__Course_Offering__c();
        hed__Course__c cou=new hed__Course__c();
        cou.name='test course';
        cou.hed__Account__c=acc[0].Id;
        courseList.add(cou);
        insert courseList;
        
        mc.Name='Test Module Offering';
        mc.hed__Course__c=courseList[0].id;
        mc.hed__Term__c=termList[0].id;
        mcList.add(mc);
        
        
        //Insert contact
        contact con=new contact();
        con.lastName='test contact Name';
        consList.add(con);    
        
        
        //program Enrollment
        hed__Program_Enrollment__c pe=new hed__Program_Enrollment__c();
        pe.Program__c=programList[0].id;
        pe.hed__Contact__c=consList[0].id;
        prEnrollmentList.add(pe);
        
        
        Program_Session__c ps=new Program_Session__c();
        ps.Term__c=termList[0].id;
        //     ps.Program__c=programList[0].id;
        ps.Program__c=programList[0].id;
        //ps.Total_enrolments_actual__c=1;
        psList.add(ps);
        database.insert (psList,false);
        
        list<Program_Session__c> prs=[select id ,Term__r.id,Program__r.id,Total_enrolments_actual__c from Program_Session__c];
        for(Program_Session__c pccc:prs){
            pccc.Total_enrolments_actual__c=10;
        }
        
        test.startTest();
        
        database.SaveResult []sr=database.update(prs,false);
        countContactRecordsBatch obj=new countContactRecordsBatch();
        database.executeBatch(obj);
        test.stopTest();
    }
    
}

As I am getting 44% code coverage on it.
Any suggestions.

Thanks
I have created a custom list button:
User-added image
with URL :
User-added imageWhen I am clicking on New Customer, it is redicrecting to this link:
User-added image
but the lookup field is not getting populated:
User-added image

Is there anything I am doing wrong?

Thanks,
Even i changes name field ,update trigger is getting called and adding un-neccessary discount to price.Expected is that it should update only if brand is getting change.How can i remove this ?


trigger MobileShopeeDiscount on Mobile__c (before insert,before Update) {
    if(trigger.isInsert == true ){
        MobileShopeeDiscount.MobileShopeeDiscountFuncation(Trigger.new);
    }
       if(trigger.isUpdate == true){
       MobileShopeeDiscount.OldCustomerDiscountFuncation(Trigger.new);
    }

}

public class MobileShopeeDiscount {

    public static void MobileShopeeDiscountFuncation(list<mobile__c>VarList){
        for(mobile__c tempvar :VarList){
            if(tempvar.Brand__c == 'samsung'){
                tempvar.Price__c = tempvar.Price__c-(tempvar.Price__c *0.1);
                tempvar.DiscountStatus__c = 'Congrates !! You got 10% Discount';
            }else if(tempvar.Brand__c == 'Apple'){
                tempvar.Price__c = tempvar.Price__c-(tempvar.Price__c *0.2);
                tempvar.DiscountStatus__c = 'Congrates !! You got 20% Discount';
            }
        }
    }

public static void OldCustomerDiscountFuncation(list<mobile__c>VarList1){
        for(Mobile__c tempvar :VarList1 ){
            if(tempvar.Brand__c == 'samsung'){
                tempvar.Price__c = tempvar.Price__c-(tempvar.Price__c *0.05);
                tempvar.DiscountStatus__c = 'Congrates !! You got 5% Discount';
            }else if(tempvar.Brand__c == 'Apple'){
               // tempvar.Price__c = tempvar.Price__c-(tempvar.Price__c *0.2);
                tempvar.DiscountStatus__c = 'No Discount Applicable on this purchase';
            }
        }
        
    }


}
I have a list with a date field for each record and i have a aura iterate to the list to show for each record sliders.
Now i only want to show sliders for the records with date greather than today.

What is the best way to do it? I try with aura:if to check list.date with a today attribute create in my controller with var today = new date();

but it did'nt work
Admin transfers the ownership to lead queue. In Queue there are 5 users, in which 1 users are ready to take ownership of that lead record, Need to create custom lightning button so that 1 users can assign themselves by clicking take ownership button, by clicking take ownership button change owner will be changed to that user name.
I'm new to writing Apex triggers, and I'm not really sure where to start, so I'm hoping someone can help me. We currently have a trigger as part of our managed package that creates a new record for an Object called Related Address when you update the address field on a contact record.

I would basically like to copy this trigger for our email address field on the contact. Because it's part of our managed package, I can't view what the Trigger coding is to just mimick it myself. We already have the Related Email object created, so now I just need to figure out how to format the Trigger. Can anybody advise me on a trigger to do this? I would be much appreciated!
Our company uses a project management tool to manage engagements after they've been won in Salesforce. I've set up an Apex callout that will request the status and other information on the engagement from the project management tool's API and will use that status to update Salesforce.

Each of the engagements needs its own separate API call. We might, at any given time, have thousands of open engagements and I need to update these every night.

I've set up a scheduable Apex class that runs a query to find all of the open engagements that are connected to the project management tool. Then, I just loop through the records and for each one I run the API call and update. This seemed to work in the testing phase, but now I have many more records and I'm getting a "Too many future calls: " error.

I was thinking about running a scheduled query beforehand and dividing all of the Salesforce engagements into groups of 50, then scheduling multiple updates of 50 records staggered by a couple of minutes. This doesn't seem like a very scalable, though. Does anyone know of a better way to do this?
My Web to lead is not getting created. I had renamed my Lead as Prospect in my org.

Thanks in advance.
  • November 21, 2019
  • Like
  • 0
Hi everyone,

My sales users want to associate multiple campaigns to ONE opportunity. I have created 1 more lookup field called "Secondary Campaign". Now, they want to add another campaign, I don't want to create another lookup field.

Is there anyway that we can associate multiple campaigns to one opportunity?

Thanks in advance.

Hello all,

I am new to the development side of Salesforce administration. I would like help either making a Flow or creating a Visualforce page.

Here is the scenario: I am working with a non-profit organization that receives furniture donations and then provides furniture to individuals in need. Basically, we need to a way to track donations and pick-ups, and keep inventory current. Products/Orders objects don't work because these are donations, so price books and all of that is irrelevant.

I created a couple of custom objects: Furniture Donations (parent record is Opportunity) and Furniture Scheduling. Furniture Donations is where inventory will be tracked, with each record a piece of donated furniture. Furniture Scheduling will track incoming and outgoing donations.

Because donors often donate several pieces of furniture at a time, I'd like staff to create one Opportunity record, and then add Furniture Donation records (a related list on Opportunity) for each donated piece.

To make data entry more efficient, I'd like staff to be able to add multiple records on one page, rather than have to keep clicking "Save & New." 

Similarly, for outgoing furniture, clients might take multiple pieces of furniture. Thus, I'd like to create one Furniture Scheduling record  (record type 'Outgoing Furniture'), and link it to all applicable Furniture Donation records. Is there a way to do this on one screen? So, Furniture Scheduling would look up to Furniture Donations, and we'd like to be able to add each piece of furniture the clients took on one screen, rather than have multiple look-up fields or clicking save & new.

Any ideas on how to accomplish this, either through Flow or through a Visualforce page? Any help at all is appreciated. Thank you!

Hi,
I'm creating an email service class.
I need to read the body of the email template which I'm receiving and I
need to update the status on the custom field based on the template message.
condition to check id and error reason or success reason.
could you please help me with this.

Thanks in advance.
Hi all,

I'm using Enterprise edition and I'm looking for feedback on how best to implement this scenario using Leads and Opportunities.

At a high level, I'm looking for a way to my customer to update information and send attachments through a web form that will update a lead. 

Scenario

1. When a lead is received (using web-to-lead), I want to automatically send out an email with a link to a web form

2. They user will follow the link in the email and be taken to a web form (no login required). 

3. The user will enter data into fields on the web form and upload documents and submit the form. 

4. On submit, those fields will update the lead and attach the documents to the lead

I'm trying to avoid purchasing pre-setup form, so would prefer to build / set this up myself.

Our website is already hosted elsewhere, so ideally, if I could built the form functionality code myself and then give it to the web developer to embed in a webpage that would be great.

Any advice would be appreciated.

Thanks.
 

isUpdateable() - 

Returns true if the field can be edited by the current user, false
otherwise.

Is this a correct syntax ?

if(!CategoryMobileConfig__c.Active__c.getDescribe().isUpdateable()) // FLS 

{

update mobileAppConfig;

}

 

1

I have one user who has CRUD permission on Case & Read only permission on Custom Object.

When Case record is created ,in Apex class invoked through trigger user is able  to create record for custom object on which user does not have create permission. The Apex class is written using Sharing keyword.

The code in Apex class seems to run in system mode even using after sharing keyword.

Please let me know if is possible to write Apex class which obeys FLS and Object permissions.

2

Documentation says Apex runs in system mode and standard controller runs in user mode. If we click on save button on Case layout then how both these 2 works together? Because std. Controller runs in user mode then the trigger runs in system mode.

Please can someone clarify this?

  • February 28, 2011
  • Like
  • 0