• Ajay K Dubedi
  • PRO
  • 3999 Points
  • Member since 2015
  • Ajay Dubedi


  • Chatter
    Feed
  • 123
    Best Answers
  • 0
    Likes Received
  • 5
    Likes Given
  • 1
    Questions
  • 1038
    Replies
trigger
trigger MyTrigger on Lead (before insert,before update) {
    
leadhandlerclass handler =new leadhandlerclass();
    
    if(Trigger.isInsert && Trigger.isbefore)
    {
        handler.UpdateLeadStatus(Trigger.new); 
    }

    if(Trigger.isupdate && Trigger.isbefore)
    {
        handler.UpdateLeadStatus(Trigger.new); 
    }
    
}

Testlead
@istest 
private class Testlead {
    
static testmethod void addressOverride(){

      Lead s = new Lead();  
      s.stages__c = 'Booked';
      leadhandlerclass handler =new leadhandlerclass();
      Lead  acc = new  Lead (stages__c = 'Booked');
      insert acc;
      system.debug('----->>> stages__c: ' + acc.stages__c);
    
      Test.startTest(); 
      system.debug('----->>> status__c: ' + acc.status__c);
      Test.stopTest();
  
    }

}
This task isn't creating and I'm not sure why. I know it isn't bulkified. Any help is appreciated.
 
trigger QBRTasks on Task (after update) {

	// Get the record type Id for QBR tasks
	Task qbrTaskRecordTypeId = [SELECT Id 
								  FROM Task 
								 WHERE RecordType.DeveloperName = 'Executive_Business_Review' 
								 LIMIT 1];

	for (Task myTask : Trigger.new) {

		Account acc = [SELECT Id, 
							  Customer_Segment__c, 
							  Task_Counter__c, 
							  Account_Manager__c, 
							  Name, 
							  Type 
						 FROM Account 
						WHERE Id = :myTask.AccountId
						LIMIT 1];

		// Get trigger.old and trigger.new versions of the record
		Task oldTask = Trigger.oldMap.get(myTask.Id);
		Task newTask = Trigger.newMap.get(myTask.Id);

		// Compare statuses on old and new triggers to see if it changed to Completed
		Boolean taskCompleted = (oldTask.Status != 'Completed' && newTask.Status == 'Completed');

		// See if task is completed and a QBR/check-in task
		if (myTask.RecordTypeId == qbrTaskRecordTypeId.Id && taskCompleted && acc.Type == 'Customer') {

			// High Touch - 2nd Check-in task
			if (acc.Customer_Segment__c == 'High Touch' && acc.Task_Counter__c == 1) {
				Task ht2 = new Task();

				ht2.ActivityDate = date.today() + 10;
				ht2.OwnerId      = acc.Account_Manager__c;
				ht2.Priority     = 'Normal';
				ht2.RecordTypeId = qbrTaskRecordTypeId.Id;
				ht2.Status       = 'Not Started';
				ht2.Subject      = '2nd Check-in Call + ' + acc.Name;
				ht2.WhatId       = acc.Id;
				insert ht2;

				acc.Task_Counter__c = 2;
				update acc;
			}

			// Mid Touch - 2nd Check-in task
			if (acc.Customer_Segment__c == 'Mid Touch' && acc.Task_Counter__c == 1) {
				Task mt2 = new Task();

				mt2.ActivityDate = date.today() + 14;
				mt2.OwnerId      = acc.Account_Manager__c;
				mt2.Priority     = 'Normal';
				mt2.RecordTypeId = qbrTaskRecordTypeId.Id;
				mt2.Status       = 'Not Started';
				mt2.Subject      = '2nd Check-in Call + ' + acc.Name;
				mt2.WhatId       = acc.Id;
				insert mt2;

				acc.Task_Counter__c = 2;
				update acc;
			}

			// High Touch - 3rd Check-in task
			if (acc.Customer_Segment__c == 'High Touch' && acc.Task_Counter__c == 2) {
				Task ht3 = new Task();

				ht3.ActivityDate = date.today() + 10;
				ht3.OwnerId      = acc.Account_Manager__c;
				ht3.Priority     = 'Normal';
				ht3.RecordTypeId = qbrTaskRecordTypeId.Id;
				ht3.Status       = 'Not Started';
				ht3.Subject      = '3rd Check-in Call + ' + acc.Name;
				ht3.WhatId       = acc.Id;
				insert ht3;

				acc.Task_Counter__c = 3;
				update acc;
			}

			// Mid Touch = 3+ QBRs
			if (acc.Customer_Segment__c == 'Mid Touch' && acc.Task_Counter__c >= 2) {
				Task mt3 = new Task();

				mt3.ActivityDate = date.today() + 180;
				mt3.OwnerId      = acc.Account_Manager__c;
				mt3.Priority     = 'Normal';
				mt3.RecordTypeId = qbrTaskRecordTypeId.Id;
				mt3.Status       = 'Not Started';
				mt3.Subject      = 'Semi-annual QBR + ' + acc.Name;
				mt3.WhatId       = acc.Id;
				insert mt3;

				acc.Task_Counter__c = acc.Task_Counter__c;
				update acc;
			}


			// High Touch - 4th QBR task
			if (acc.Customer_Segment__c == 'High Touch' && acc.Task_Counter__c == 3) {
				Task ht4 = new Task();

				ht4.ActivityDate = date.today() + 60;
				ht4.OwnerId      = acc.Account_Manager__c;
				ht4.Priority     = 'Normal';
				ht4.RecordTypeId = qbrTaskRecordTypeId.Id;
				ht4.Status       = 'Not Started';
				ht4.Subject      = 'QBR + ' + acc.Name;
				ht4.WhatId       = acc.Id;
				insert ht4;

				acc.Task_Counter__c = 4;
				update acc;
			}

			// High Touch - 5+ QBR Tasks
			if (acc.Customer_Segment__c == 'High Touch' && acc.Task_Counter__c >= 4) {
				Task ht5 = new Task();

				ht5.ActivityDate = date.today() + 90;
				ht5.OwnerId      = acc.Account_Manager__c;
				ht5.Priority     = 'Normal';
				ht5.RecordTypeId = qbrTaskRecordTypeId.Id;
				ht5.Status       = 'Not Started';
				ht5.Subject      = 'QBR + ' + acc.Name;
				ht5.WhatId       = acc.Id;
				insert ht5;

				acc.Task_Counter__c = acc.Task_Counter__c + 1;
				update acc;
			}

		}
	}

}

 
Hi All,

I am relatively new to Apex coding. I have written a class which is giving the error "Missing return statement required return type: Boolean". Could you plz  help me resolve this .

public class CC_JobBoardApp_checkstatus {
    @AuraEnabled
    public static Boolean checkstatus()
    {
        Set<Id> jobid = new Set<Id>() ;
            for(TR1__Job_Board_Application__c jba : 
                [SELECT TR1__Status__c,TR1__Job__c,Job_Id__c    
                 from TR1__Job_Board_Application__c 
                 where Id in :JobId
                 LIMIT 1])
            if(jba.TR1__Status__c=='Rejected')
        {
            return true;
        }
        else
        {
            return false;
        }
    }
}


The class checks if the status of the job application is rejected. If it is rejected, then returns true else returns false. 
Hi,
I am new to salesforce and i am facing an issue my Trigger is not working properly.
I want the trigger to check whether the all Shipping Address field is filled or not , and if not the display the error message.
Any help will be appreciated.
Thanks.
trigger shippingAddress on Account (before insert,before update)
{

    List<Account> accList=new List<Account>();
    
    for(account accObject:trigger.new)
    {
        if(accObject.ShippingStreet !=null && accObject.ShippingCity!=null &&
           accObject.ShippingState!=null && accObject.ShippingPostalCode!=null && 
           accObject.ShippingCountry!=null)
        {
           accList.add(accObject);
        
        }
        
        else
        {
        
            accObject.addError('All Shipping Fields are required');
            
        }

    }
    
    insert accList;
}

 
Hi,

I want to update the contact phone field whenever account phone filed is updated .
Please share the code.

Thanks in advance
Please help me. I am not sure what's the issue with this class its not updating.
 
public class MyFirstClass {
    public static void method(){
    List<Account> accLst = new List<Account>([select id,name,description from Account where name like 'United%']);
    system.debug('The account lists are:' + accLst);
    List<Account> accupdLst = new List<Account>();
    for(Account acc: accupdLst ){
        acc.Description = 'Updated from Apex Class';
        accupdLst.add(acc);
    }
    if(accupdLst != null && accupdLst.size()>0){
    update accupdLst;
        
    }
    system.debug('The updated account lists are:' + accupdLst);
}
}

Please help me!<

 
Hello,

How can i calculate time between last modified date and present modified date and get the time in minutes.
where can i store t, in number field or text field.

thank for suggestion
Hi Friends,
Could anyone please help on this. I want to put validation rule for zipcode to prevent the special character. And this validation rule should work only for one country(market). I used the below logic but its not working.

IF( ISPICKVAL(ZTS_EU_Market__c, Brazil)NOT(REGEX( ZTS_EU_Zip_Postal_Code__c,"^[a-z  A-Z]*$")))
Please help me on this.
 
  • September 05, 2018
  • Like
  • 0
String sch1 = '0 0/10 * 1/1 * ? *';
System.schedule('Scheduled Job 3', sch1, new myScheduleClass());

I generated the cron expression using tool cronmaker.

ERROR:System.StringException: Seconds and minutes must be specified as integers: 0 0/10 * 1/1 * ? *
Hi All,

I would like to create a validation rule that prevents a user from choosing particular values from a picklist, based on a checkbox value.  Both fields are on the Account object.

So, the picklist values are:

New ICP
BDR Working
Cold
Revisit

If the checkbox field 'Allocated Account?' = True, I only want the user to be able to proceed if they choose either New ICP, BDR Working, or Revisit. E.g. 'Cold' is not an option if the Allocated Account box is ticked.

To complicate matters, I also want to restrict the picklist choices if 'Allocated Account?' = False, so in that scenario, there would be an error if they tried to select 'Revisit'.  Would I need 2 validation rules, or can this all be accomplished with one?

Hope that all makes sense? Thanks so much in advance for your help!  (Yes, I know I need the API field names, I'm being lazy....will add them in when I actually build it! :-) )

Emma
Hi all,
I have a validation rule I need to run where 3 things need to be true for it to fire. A needs to = True, B=True and C OR D = True.
I can't figure out the syntax for this.  I thought maybe:
AND(A=True, B=True, OR(C=True,D=True)  But that didn't work.  Any ideas?
User-added image

User-added image

Its throwing this error without showing me a Map or change option in the left panel. So how should I map the custom field here? Any help ?
I have 2 custom objects: Student and Registration.They have a same field class. Registration has a lookup to Student. I need to update all related registration records's class field when the class of student is updated using triggers. (A student can have multiple registrations)
Thanks in advance.
Hi All,

I need a trigger to update Contact Description and Contact related Case object Description whenever Account Description is updated.
Below trigger working fine for updating Contact Description when Account Description is updated. But I need to update Case records of Contact as well.

Here Account is ---> Parent,
Contact is ---> Child,
Case is ---> grand child

trigger ContactDescriptionUpdate on Account (after update) {
    Map < Id,  Account > mapAccount = new Map < Id, Account >();
    List<Contact> listContact = new List<Contact>();
    
    for(Account acct : trigger.new)
        mapAccount.put(acct.Id, acct);
    
    listContact = [ SELECT Description, AccountId FROM Contact WHERE AccountId IN : mapAccount.keySet() ];
    
    if ( listContact.size() > 0 ) {
        for ( Contact con : listContact ) {
            con.Description = mapAccount.get(con.AccountId).Description;
        }
        update listContact;
    }
}

Thanks in advance.
I can see this has been asked a lot, but the answers given aren't helping me change my code to work, so I am really hoping someone can do it for me?

Code below, I just need the background being white. Thanks you!
 
<apex:page standardController="Group_Relationship__c" >
<head>
<style>

tr {
    display: block;
    border-bottom: 1px solid #e6e6e6;
}
td {
    padding-left: 40px;
}
table{
    min-width: 1350px;
    }
</style>
</head>


<apex:form >
<table width="100%"> 
  <tr>
    <td style="width:10%"><apex:image id="ManheimRemarketingBuyer" value="{!If(Group_Relationship__c.Group_Name__r.Group_Buyer_RMA_Count_Form__c >0, $Resource.Remarketing_Buyer_Colour, $Resource.Remarketing_Buyer_BW)}" width="200" height="80"/></td>
    <td style="width:10%"><apex:image url="https://c.eu10.visual.force.com/resource/1513853142000/VolumeBoughtYTDPrevYear2" width="175" height="70"/></td>
    <td style="width:20%"><apex:outputLabel style="vertical-align:top; text-align:center;font-family:calibri;font-size:35px;color:{!IF(Group_Relationship__c.Group_Name__r.Group_Buyer_RMA_Count_Form__c >0, '#004489', '#d9d9d9')};"><apex:outputField label="AccNAme" value="{!Group_Relationship__c.Group_Name__r.Remarketing_Buyer_Volume_Group_Join__c}" /></apex:outputLabel></td>
    
    <td style="width:10%"><apex:image id="DealerAuction" value="{!If(Group_Relationship__c.Group_Name__r.Dealer_Auction_Volume_Group_Form__c >0, $Resource.DealerAuctionImage, $Resource.DealerAuctionImageBW)}" width="200" height="80"/></td>
    <td style="width:10%"><apex:image url="https://c.eu10.visual.force.com/resource/1513853196000/VolumeSoldYTDPrevYear" width="175" height="70"/></td>
    <td style="width:20%"><apex:outputLabel style="vertical-align:top; text-align:center;font-family:calibri;font-size:35px;color:{!IF(Group_Relationship__c.Group_Name__r.Dealer_Auction_Volume_Group_Form__c >0, '#25488e', '#d9d9d9')};"><apex:outputField label="AccNAme" value="{!Group_Relationship__c.Group_Name__r.Dealer_Auction_Volume_Group_Form__c}" /></apex:outputLabel></td>
  </tr>
  <tr>
    <td style="width:10%"><apex:image id="ManheimRemarketingVendor" value="{!If(Group_Relationship__c.Group_Name__r.Group_Vendor_RMA_Count_Form__c >0, $Resource.Remarketing_Vendor_Colour, $Resource.Remarketing_Vendor_BW)}" width="200" height="80"/></td>
    <td style="width:10%"><apex:image url="https://c.eu10.visual.force.com/resource/1513853196000/VolumeSoldYTDPrevYear2" width="175" height="70"/></td>
    <td style="width:20%"><apex:outputLabel style="vertical-align:top; text-align:center;font-family:calibri;font-size:35px;color:{!IF(Group_Relationship__c.Group_Name__r.Group_Vendor_RMA_Count_Form__c >0, '#004489', '#d9d9d9')};"><apex:outputField label="AccNAme" value="{!Group_Relationship__c.Group_Name__r.Remarketing_Vendor_Volume_Group_Join__c}" /></apex:outputLabel></td>
    
    <td style="width:10%"><apex:image id="Motors" value="{!If(Group_Relationship__c.Group_Name__r.Motors_co_uk_Accounts_Group_Form__c >0, $Resource.MotorsImage, $Resource.MotorsImageBW)}" width="200" height="80"/></td>
    <td style="width:10%"><apex:image url="https://c.eu10.visual.force.com/resource/1513853893000/RevenueRolling12" width="175" height="70"/></td>
    <td style="width:20%"><apex:outputLabel style="vertical-align:top; text-align:center;font-family:calibri;font-size:35px;color:{!IF(Group_Relationship__c.Group_Name__r.Motors_co_uk_Accounts_Group_Form__c >0, '#3BB97C', '#d9d9d9')};"><apex:outputField label="AccNAme" value="{!Group_Relationship__c.Group_Name__r.Motors_co_uk_Revenue_Group_Form__c}" /></apex:outputLabel></td>
  </tr>
  <tr>
    <td style="width:10%"><apex:image id="Modix" value="{!If(Group_Relationship__c.Group_Name__r.Modix_Accounts_Group_Form__c >0, $Resource.ModixImage, $Resource.ModixImageBW)}" width="200" height="80"/></td>
    <td style="width:10%"><apex:image url="https://c.eu10.visual.force.com/resource/1513853893000/RevenueRolling12" width="175" height="70"/></td>
    <td style="width:20%"><apex:outputLabel style="vertical-align:top; text-align:center;font-family:calibri;font-size:35px;color:{!IF(Group_Relationship__c.Group_Name__r.Modix_Accounts_Group_Form__c >0, '#FD4F00 ', '#d9d9d9')};"><apex:outputField label="AccNAme" value="{!Group_Relationship__c.Group_Name__r.Modix_Revenue_Group_Form__c}" /></apex:outputLabel></td>
    
    <td style="width:10%"><apex:image id="NextGear" value="{!If(Group_Relationship__c.Group_Name__r.Next_Gear_Accounts_Group_Form__c = 'Live', $Resource.NextGearImage, $Resource.NextGearImageBW)}" width="200" height="80"/></td>
    <td style="width:10%"><apex:image url="https://c.eu10.visual.force.com/resource/1513853383000/StatusPaint" width="175" height="70"/></td>
    <td style="width:20%"><apex:outputLabel style="vertical-align:top; text-align:center;font-family:calibri;font-size:35px;color:{!IF(Group_Relationship__c.Group_Name__r.Next_Gear_Accounts_Group_Form__c = 'Live', '#25488e', '#d9d9d9')};"><apex:outputField label="AccNAme" value="{!Group_Relationship__c.Group_Name__r.Next_Gear_Accounts_Group_Form__c}" /></apex:outputLabel></td>
  </tr>
  <tr>
    <td style="width:10%"><apex:image id="Closit" value="{!If(Group_Relationship__c.Group_Name__r.Lead_Management_Accounts_Group_Form__c >0, $Resource.IncadeaSalesColour, $Resource.IncadeaSalesBW)}" width="200" height="80"/></td>
    <td style="width:10%"><apex:image url="https://c.eu10.visual.force.com/resource/1513853893000/RevenueRolling12" width="175" height="70"/></td>
    <td style="width:20%"><apex:outputLabel style="vertical-align:top; text-align:center;font-family:calibri;font-size:35px;color:{!IF(Group_Relationship__c.Group_Name__r.Lead_Management_Accounts_Group_Form__c >0, '#FFA000', '#d9d9d9')};"><apex:outputField label="AccNAme" value="{!Group_Relationship__c.Group_Name__r.Lead_Management_Revenue_Group_Form__c}" /></apex:outputLabel></td>
    
    <td style="width:10%"><apex:image id="RMS" value="{!If(Group_Relationship__c.Group_Name__r.RMS_Accounts_Group_Form__c = 'Live', $Resource.RMSImage, $Resource.RMSImageBW)}" width="200" height="80"/></td>
    <td style="width:10%"><apex:image url="https://c.eu10.visual.force.com/resource/1513853196000/VolumeSoldYTDPrevYear2" width="175" height="70"/></td>
    <td style="width:20%"><apex:outputLabel style="vertical-align:top; text-align:center;font-family:calibri;font-size:35px;color:{!IF(Group_Relationship__c.Group_Name__r.RMS_Accounts_Group_Form__c = 'Live', '#205EAA', '#d9d9d9')};"><apex:outputField label="AccNAme" value="{!Group_Relationship__c.Group_Name__r.RMS_Volume_Sold_Group_Join__c}" /></apex:outputLabel></td>
  </tr>
  <tr>
    <td style="width:10%"><apex:image id="Xtime" value="{!If(Group_Relationship__c.Group_Name__r.XTime_Accounts_Group_Form__c >0, $Resource.IncadeaServiceColour, $Resource.IncadeaServiceBW)}" width="200" height="80"/></td>
    <td style="width:10%"><apex:image url="https://c.eu10.visual.force.com/resource/1513853893000/RevenueRolling12" width="175" height="70"/></td>
    <td style="width:20%"><apex:outputLabel style="vertical-align:top; text-align:center;font-family:calibri;font-size:35px;color:{!IF(Group_Relationship__c.Group_Name__r.XTime_Accounts_Group_Form__c >0, '#FFA000', '#d9d9d9')};"><apex:outputField label="AccNAme" value="{!Group_Relationship__c.Group_Name__r.XTime_Revenue_Group_Form__c}" /></apex:outputLabel></td>
    
    <td style="width:10%"><apex:image id="Movex" value="{!If(Group_Relationship__c.Group_Name__r.Movex_Accounts_Group_Form__c = 'Live', $Resource.Movex_Colour, $Resource.Movex_BW)}" width="200" height="80"/></td>
    <td style="width:10%"><apex:image url="https://c.eu10.visual.force.com/resource/1513853383000/StatusPaint" width="175" height="70"/></td>
    <td style="width:20%"><apex:outputLabel style="vertical-align:top; text-align:center;font-family:calibri;font-size:35px;color:{!IF(Group_Relationship__c.Group_Name__r.Movex_Accounts_Group_Form__c = 'Live', '#0076A6', '#d9d9d9')};"><apex:outputField label="AccNAme" value="{!Group_Relationship__c.Group_Name__r.Movex_Accounts_Group_Form__c}" /></apex:outputLabel></td>
  </tr>
</table>






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

 
Hi

I am having trouble with my apex trigger. I have written SOQL inside FOR loop which causes Exception : "System.LimitException: Too many SOQL queries: 101". Can someone help me 'bulkify' this trigger as I can't seem to do so. Many Thanks, Triger below: 
 
trigger MnCopyPrimaryContact on Opportunity (before update) {
   for (Opportunity o : Trigger.new) {
       OpportunityContactRole[] contactRoleArray =
       [select ContactID, isPrimary from OpportunityContactRole where OpportunityId = :o.id ORDER BY isPrimary DESC, createdDate];
       if (contactRoleArray.size() > 0) {
           o.Opportunity_contact__c = contactRoleArray[0].ContactID;           
       }else{
           o.Opportunity_contact__c = null;
       }
   }
 }

 
We need to create a storage location for a userguide(in any format pdf,excel etc) in salesforce and for that we have to give read only permissions to all users and Editable access to admin and selected users.

We have tried these two ways but couldn't find exact solution:

1- We have tried it using by creating a Folder in documents and giving readable access to all users and to give editable access to admin or some selected users we have created a permission set in which under System Permissions we just ticked the Manage public Documents checkbox.So by this all the users which are assigned in the permission set are able to manage all the folders but we want to manage only a particular folder.

2- We have also tried using content libraries.In that we created a library and added the content file in it.Gave permissions of viewing,editing to particular users but in this we are not able to add Chatter Only users so this solutions got breaked,adding to it some more profiles are asked to generate a case to salesforce support to get Salesforce CRM Content User License by this license only they can view or edit content.

Solutions for this is highly appreciable.And if any one can suggest how to modify any of above two ways to get required solution this will be a great help. I have also posted this question on salesforce community and Stack Exchage.

Thanks
Hi All,

I have one doubt that how can i use includes with the set in soql query.

List<LD_Category_Group_Association__c> allLdCatGrpAsslist = [SELECT Id,User_Groups__c FROM LD_Category_Group_Association__c Where User_Groups__c includes (: set_of_LD_User_Groups) ];

Here , User_Groups__c  is a multiple picklist field
I am using MS Outlook email from a long time. I use pst password for protecting my all email data.  But after some time, MS Outlook shows the wrong password. I do not understand right now how to unlock my pst password
when i change picklist it has to display
   accounts of type picklist selected.
 
I need to know how to lock and unlock a record in sfdc

Please let me know frrom real time perspective what other different techniques in what scenarios it will work.

which is the best preferred?

sheila
 
I have this code:
                <tr > 
                        <th>Rate Factor</th>
                        <th>Term</th>
                        <th>Purchase Option</th>
                        
                    </tr>
                    <apex:repeat var="cx" value="{!relatedTo.Terms__r}">
                    <tr>
                        <td>{!cx.Current_Rate_Options__c}</td>
                        <td>{!cx.Term__c}</td>
                        <td>{!cx.FMV__c}</td>
                    </tr>
                    </apex:repeat>
                </table>

Current_Rate_Options__c is a number with 5 decimal places. If the number is 0.02700, the output shows as 0.027. This is in a VF email template. How do I get all 5 decimal places all the time?
I have a form where people can enter a value between zero and one.  I am using the following element to capture their input
<lightning:input name="example" label="example" type="number" min="0.0" max="1.0" step="0.01"/>
Negative values, being less than the minimum, should not be valid.  Entering "-0.01" is correctly identified as an invalid value.
Negative value "-0.01" is correctly identified as invalid
However, if I instead enter that value as "-.01" (without the zero to the left of the decimal point), the input element does NOT identify it as an invalid value. 
Negative value "-.01" is incorrectly identified as valid
I had to write extra code to check the value before the form gets submitted to compensate for this.

Is this a bug, or is there a configuration that I am missing?
 
Put a button named “Search”, that will be used to search accounts, when accounts found display. If not found show messaging saying no 
      accounts found. Put a Create button on page as well if no records found to create new account.
 
trigger
trigger MyTrigger on Lead (before insert,before update) {
    
leadhandlerclass handler =new leadhandlerclass();
    
    if(Trigger.isInsert && Trigger.isbefore)
    {
        handler.UpdateLeadStatus(Trigger.new); 
    }

    if(Trigger.isupdate && Trigger.isbefore)
    {
        handler.UpdateLeadStatus(Trigger.new); 
    }
    
}

Testlead
@istest 
private class Testlead {
    
static testmethod void addressOverride(){

      Lead s = new Lead();  
      s.stages__c = 'Booked';
      leadhandlerclass handler =new leadhandlerclass();
      Lead  acc = new  Lead (stages__c = 'Booked');
      insert acc;
      system.debug('----->>> stages__c: ' + acc.stages__c);
    
      Test.startTest(); 
      system.debug('----->>> status__c: ' + acc.status__c);
      Test.stopTest();
  
    }

}
Hello,
I need help for the following trigger scenario:

There is one field in Account and one field in Opportunity 
Consider the field in Account is FieldA and the Field in the Opportunity is FieldB (consider both fields are check-box)
when i Update the fieldA in Account, the fieldB in Opportunity should get updated and
when i Update the fieldB in Opportunity, the fieldA in account should get Updated.

Thank you 
I have a requirement where i need to delete few Account records from my Production and do backup for them in seperate sandbox.Backup of Accounts should also include all its related lists data including ATTACHMENTS.Am unable to export& backup attachments on those specific records that are to be deleted.

I did "Data Export" and also i exported through Data Loader using "Attachments" Object but i couldn't get any files except their Id's.

Can Someone help with your valuable suggestions?
I have started using Salesforce in my new company but for now the use is very basic- feeding/pulling out customer database. I want to learn full-fledged Saelsfroce and excel in it, I am from non-developer/non-coding background. I have started learning the Salesforce Admin modules viaTrail Head.
It will be great if somebody can guide me since Salesforce is huge and I want to go step-by-step and learn each and every component of Salesforce applications. What could be the best way? What should I follow excatly?
Thank you
  • January 25, 2017
  • Like
  • 3

how to create user through apex code.

Hi Expert,

I am new to the programming world. I have a custom controller which insert a contact created on VF page. Now I am not able to write test class for this. I could only cover 56% code.
 
public class TestPopup {
    
    public list<Account> acc{get;set;} 
    public Account acc1 {get;set;} 
    public Contact contact {get;set;}
    public List<Contact> conlist;
    public Boolean displayPopup {get;set;}
    public String accid {get;set;}
       

    public TestPopup(){
        acc = [select ID, Name, AccountNumber,Type from Account];
	    acc1 = new Account();
        conlist = new List<Contact>();
        contact = new Contact();
        	
    }
   
    public list<Account> getacc(){
        return acc;
    }
    
    public void showPopup()
    { 
    	displayPopup = true;
        acc1 = [SELECT Id, Name, Phone, (SELECT lastName FROM Contacts) FROM Account WHERE Id = :accid];
    }
       
    public void closePopup() {
        displayPopup = false;
        
    }

    public PageReference save(){
        contact.AccountId= acc1.Id;
        insert contact;
        ID contactId = contact.Id;
        PageReference pr = new PageReference('/' + contactId);
   		return pr;
    }  
        
}
 
@isTest
public class TestCustomController {
     static testMethod void testMethod1() 
     {
         Account testAccount = new Account();
         testAccount.Name='Test Account';
         insert testAccount;
         
         Contact cont = new Contact();
         cont.LastName = 'Test';
         cont.FirstName = 'Contact';
         cont.AccountId = testAccount.Id;
          // insert cont;
         
         Account testAccount1 = new Account();
         testAccount1 = [SELECT Id, Name, Phone, (SELECT lastName FROM Contacts) FROM Account WHERE Id = :testAccount.Id];
       
         
         
         Test.StartTest(); 
         PageReference pageRef = Page.All_Account; // Add your VF page Name here
         pageRef.getParameters().put('id', String.valueOf(testAccount.Id));
         Test.setCurrentPage(pageRef);
         
         TestPopup testAccPlan = new TestPopup();  
         testAccPlan.getacc();
        // testAccPlan.showPopup(); 
         testAccPlan.closePopup();
         
         Test.StopTest();
         
     } 
}

 
Hi,

Cannot save the Controller, please help.

https://trailhead.salesforce.com/projects/quickstart-lightning-components/steps/quickstart-lightning-components4
Ok, been directed here by support so hoping someone can help.

Basically noticed that our case milestones were violating outside our set business hours.  After a lot of head scratching the only conclusion was that our timezone on the business hours in use by the entitlement processes were set to GMT.  I have changed this to BST (British Summer Time) to prevent more out of hours violations.

I have asked support if having it set to BST would mean that come Autumn salesforce will automatically revert back an hour in line with daylight savings.  They have said this does not occur and you have to manually change the timezone each time daylight savings occurs.

Can anyone confirm if this is true?  Seems like something so basic that I can't believe its not in the system. 
  • April 21, 2016
  • Like
  • 3

Hi, 

This Monday I tried to do the exam but I had technical issues with camera. Kryterion support tried to help me but we couldn't solve the problem. They rescheduled my exam multiple times but they can not do it to a different day.

Please, I have opened cases and called to certification support phone without getting any answer. Could you help me?

Best regards
I want to send emails in user's language dynamically. Two approaches:
1. Use visualforce email template, create labels and use them in the template. Set language attribute in the template and provide translations for the labels using translation workbench.
2. Create multiple versions of each template, each in a separate language and choose the template dynamically.

Advantage of first approach is that no additional efforts are required if a new language is to be supported but creating so many custom labels is cumbersome. 2nd approach is good in that respect but a template needs to be added everytime a new language is supported. 
Is there any other approach? If not, which one of the above should be chosen?