• Apuroop
  • SMARTIE
  • 610 Points
  • Member since 2018

  • Chatter
    Feed
  • 19
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 134
    Replies
I am getting this error when trying to save my test, here is my test code
 
@istest (seeAllData = True) private class requnl_class_test  {

@isTest static void requnl_class_test () {
	Patient_Details__c client = new Patient_Details__c(
		Patient_name__c='Donkey Kong',
		Email_Address__c='tom@tom.com',
		Phone_number3__c='2012012233'
		);
	insert client;
	Patient_chart__c chart= new Patient_chart__c (
		RESTORE_Client__c=client.Id,
		name='sard'
		);
	insert chart;
	 
	ApexPages.currentPage().getParameters().put('id',chart.id);
	ApexPages.StandardController stdController = new ApexPages.StandardController(chart);
	
    requnl_class consext  = new requnl_class(stdController);

	PageReference pageRef = Page.Request_Unlock;

setCurrentPage(pageRef);

}
}

And here is my class code 
public without sharing class requnl_class
{
   private ApexPages.StandardController standardController;
   public String recId {get; set;}

 
    public requnl_class(ApexPages.StandardController standardController)
    {
    recId=ApexPages.CurrentPage().getparameters().get('id');
        this.standardController = standardController;
        
    }
  

public PageReference send() {

Messaging.singleEmailmessage email = new Messaging.singleEmailmessage();

patient_chart__c PatientId = [SELECT Id FROM patient_chart__c WHERE ID =:recid Limit 1]; 

List<string>sendTo = new List<String>();

sendTo.add('support@restorehair.com'); 

email.setToAddresses(sendTo);

email.setSubject('Please unlock this patient chart.'); 

email.setHtmlBody('Please unlock cs28.salesforce.com/'+PatientId.Id);

Messaging.sendEmailResult[] r = Messaging.sendEmail(new Messaging.singleEmailmessage[] {email});

        return null;
    }
}

Any help would be appreciated :)
 

In SOQL...select id, whatid from task where WHAT.TYPE = 'Opportunity'.

Is there an alternative to WHAT.TYPE in APEX.

Hello,

I created a Date Field in custom object TiFF1040 and named the Date field, Date Director of Sales Approved TiFF. The date renders perfectly in a regular lightning page, however, when I place the following string in Visualforce, it produces this output: Mon Jul 22 00:00:00 GMT 2019

However, I need it to show as 7/22/2019.

Any help is appreciated.

Thank you!

 
{!TiFF1040__c.Date_Director_of_Sales_Approved_TiFF__c}

 
SolarBot added as an Picklist type in Opp object. Package installed Properly. Reports created with proper name. Not sure about the error.
Hey everyone, 

I'm creating a unit test for updating accounts with a total number of contacts, but I'm trying to do this from my Test Class, "TestDataFactory" (CodeSnippet below). The method that I wrote is called queryAccounts(Integer qLimit); 

When I execute the code in anonymously, it will return the expected result, but these values are not being returned to the test class when I call the TestDataFactory.queryAccounts(1); 

Any idea what the issue is? 
AccountProcessorTest() Code Snippet: 
@isTest
private class AccountProcessorTest {

    @isTest public static void singleAccountUpdate() {
      //Get test data for testing
      Test.startTest();
        Id[] acctIds = TestDataFactory.queryAccounts(1); 
        System.debug('Results = ' +TestDataFactory.queryAccounts(1)); 
      	List<Contact> cons = [SELECT Id, AccountId FROM Contact WHERE AccountId IN: acctIds];
        integer numOfContacts = cons.size();
        System.debug('acctIds = ' + acctIds.size()); 
       //test the update of the Contacts record count on Accounts.
        
        Account acctUpdate = new Account(Id = acctIds[0], Number_of_Contacts__c = numOfContacts); 
        update acctUpdate; 
        Test.StopTest(); 
    }
    
    @isTest static void multipleAccountUpdate(){
        //Test multiple accounts. 
    }
}



TestDataFactory() Code Snippet: 
 
@isTest
public class TestDataFactory {
    public static List<Account> createAccountsWithOpps (Integer numAccts, Integer numOppsPerAcct){
        List<Account> accts = new List<Account>(); 
        for(Integer i=0; i<numAccts;i++){
            
            Account a = new Account(Name = 'TestAccount' + i); //assigning incremental name
            accts.add(a); //Adds accounts to accts list. 
        }
        
        insert accts; 
        
        List<Opportunity> opps = new List<Opportunity>(); 
        for(Integer j = 0; j<numAccts; j++){
            Account acct = accts[j]; 
            for (Integer k=0; k<numOppsPerAcct; k++){
            opps.add(new Opportunity(Name = acct.Name + 'Opportunity ' + k, 
                                           StageName = 'Prospecting',
                                           CloseDate=System.today().addMonths(1),
                                           AccountId=acct.Id));
            }
            
           }
        insert opps; 
        return accts; 
    } 
    public static List<Id> queryAccounts(Integer qLimit){
     List<Id> acctIds = new List<Id>(); 
     List<Account> accts = ([SELECT Id FROM Account LIMIT: qLimit]);   
        for(Account a : accts ){
            system.Debug('The ID is added  '+ a.Id );
            acctIds.add(a.Id);
        }
        system.debug('qLimit = ' + qLimit); 
        return acctIds;
    }
}

 
I need to nail down this invocable method (or even convert to a trigger?). Not sure. I am an Admin, not a Developer, so I need help! A kind developer wrote this method for me and I am trying to trigger it via PB, but the contact owner does not update.
The PB is:
Account object (created or edited) >>
Criteria node = Account.Demand_Gen_Owner__c IS CHANGED || Account.OwnerId IS CHANGED >>
Immediate action = Apex Class
global class UpdateContactsFromAccount {
    
    @InvocableMethod(label='save info' description='Update Contact Owners')
    global static void saveInformation (List<Id> accountIds) {
    	List<Account> listAccount = [Select Id, Demand_Gen_Owner__c, OwnerId FROM Account WHERE Id In :accountIds];
        List<Contact> listContact = [Select Id, AccountId, OwnerId FROM Contact WHERE AccountId In :accountIds];
        
        Map<Id, Account> mapIdToAccount = new Map<Id, Account>();
        mapIdToAccount.putAll(listAccount);
        System.debug('Accounts for which Contacts to be updated:: mapIdToAccount : ' + mapIdToAccount);
        for(Contact con: listContact){
            if(con.AccountId != null){
                Account acc = mapIdToAccount.get(con.AccountId);
                if(acc.Demand_Gen_Owner__c != 'Unassigned' || acc.Type != 'Current Customer'){
                	con.OwnerId = acc.Demand_Gen_Owner__c;
                }
                else {
                    con.OwnerId = acc.OwnerId;
                }
            }
        }
        update listContact;
    }
}
Currently this is just a PB in production and it is causing errors intermittently (usually accounts that have a ton of contacts) or also during bulk uploads. I think it's too many contact records that it's trying to update. Also have an issue with an unrelated managed package triggering the process and causing insert/update errors on the package fields (none of these fields are part of my process). I came here with this originally and it was recommended to use an invocable method/apex class to better control the updates. Please help so I can get this into prod! As always, thanks so much!
 
Hi all, I have had some trouble trying to create a trigger that updates a field on related event records whenever a specific contact field is updated. I tried using a map of lists, but have found that a can't add an Event type as the value of the list. I wanted to make this map to link all updating contacts to their related events. Then, I would have to find a way to loop through the map, updating the event field. Here is my code:

Trigger IncrementValue on Contact (before update) {

    //Create a list of all updating contact IDs
    List<Id> contactIds = new List<Id>();
    for(Contact con : Trigger.new) {
        contactIds.add(con.Id);
    }
    
    //Create a map of all updating contact IDs and their related event IDs
    Map<Id, List<Event>> contactEvents = new Map<Id, List<Event>>();
    
    for(Event ev : [SELECT WhoId FROM Event WHERE WhoId IN :contactIds]) {
        if(contactEvents.containsKey(ev.WhoId)) {
            List<Event> eventId = contactEvents.get(ev.WhoId);
            eventId.add(ev.Activity_ID__c);
            contactEvents.put(ev.WhoId, eventId);
        }
        else {
            contactEvents.put(ev.WhoId, new List<Event> {ev.Activity_ID__c});
        }
    }
    
    List<Id> eventUpdate = new List<Id>();
    
    for(Contact con : Trigger.new) {
        if(contactEvents.containsKey(con.Id)) {
            return; //increment sales (Need help looping through map)
        }
    }
}

Here are my errors:

eventId.add(ev.Activity_ID__c); - Method does not exist or incorrect signature: void add(String) from the type List<Event>

contactEvents.put(ev.WhoId, new List<Event> {ev.Activity_ID__c}); - 
Initial expression is of incorrect type, expected: Event but was: String

Thank you for any help and will obviously answer any questions if my explanation was confusing!
I have a custom object called University/Company. On the custom object is a lookup field to an account object called Company. I'd like to write a SOQL query that pulls the task information from this Company object via the University/Company object. Is this possible? I'm relatively new to SOQL, so any help would be greatly appreciated. Thanks!
Hi,

I need help with a formula that will display the dates between a start and end date. ie, if start date is June 28, 2019 and end date is July 2, 2019; then the dates in between are June 29, 2019, June 30, 2019 and July 1, 2019.
Hi,
I have written batch to send emails to users not logged in more than 20 days. it is working when I use schedular  with batch limit 10.
But when I am trying to write test class I am getting below error:
"System.UnexpectedException: No more than one executeBatch can be called from within a test method.  Please make sure the iterable returned from your start method matches the batch size, resulting in one executeBatch invocation."

--- my batch -- 
global class SendEmailtoNonActiveUsersBatch implements database.Batchable<sObject> {
    Exception[] errors = new Exception[0];
    global String query;
    global Database.QueryLocator start(Database.BatchableContext bc) {
        
        string query = 'SELECT id,Firstname,Lastname,Profile.name, email,Isactive, LastLoginDate, category__c,IsEmailSendToNonActive__c FROM User where IsActive=True and Category__c= \'Employee\' and IsEmailSendToNonActive__c != true and LastLoginDate < LAST_N_DAYS:20 order by Firstname ASC ';
        return database.getQueryLocator(query);
    }
    
    global void execute(Database.BatchableContext bc, List<User> scope){
        system.debug('Scope size' +scope.size());
        try{ 
            String currentUserLink = URL.getSalesforceBaseUrl().toExternalForm() + '/';
            if(scope.size() >0){ 
                for(user u: scope){
                    if(u.IsEmailSendToNonActive__c != true){
                        u.IsEmailSendToNonActive__c = true;
                        string[] toAddress = new string[] {u.Email};
                        string subject = 'Notification Of User Deactivation';
                        
                        string plainBody = 'TEST'
                        
                        SendEmail(toAddress,subject, plainBody, null, null );
                        update u;
                    }
                }
            }
        }
        catch(exception e){
            errors.add(e);
        }
    }
    
    global void finish(Database.BatchableContext bc){
        //Admins email addresses
        List<string> emailAdd = new List<string>();
        for(AdminsEmailList__c emad : AdminsEmailList__c.getAll().values())
        {
            system.debug('emad.Email__c:'+emad.Email__c);   
            emailAdd.add(emad.Email__c);
        }
        
        List<AggregateResult> numberOfRows = [Select count(id) from user where IsEmailSendToNonActive__c=True and lastmodifieddate = today];
        integer numRow = (integer)numberOfRows[0].get('expr0');
        
        AsyncApexJob a = [SELECT Id,Status,JobType,NumberOfErrors,JobItemsProcessed,TotalJobItems,CompletedDate,ExtendedStatus
                          FROM AsyncApexJob WHERE Id =:BC.getJobId()];
        
        
        
        //check for errors if no error then proceed
        string errorString;
        for(Exception s: errors)
        {
            errorString = errorString + s.getMessage();  
        }
        if(!errors.isEmpty()) {
            string errSub = 'Error(s) occurred during sending emails to Non Active user batch process.';
            string errBody = 'below is the error details: \n\n'+errorString;
            SendEmail(emailAdd, errSub, errBody, null, null);
        } 
    }
    public void SendEmail(List<string> toEmailAdd, string subject, string body, string attchmentName, string attachment){
        system.debug('toEmailAdd::'+toEmailAdd);
        if(toEmailAdd != null && !toEmailAdd.isEmpty()){
            Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();

            mail.setToAddresses(toEmailAdd);
            mail.setSubject(subject);
            mail.setSaveAsActivity(false);
            mail.setPlainTextBody(body);
 
            
            Messaging.sendEmail(new Messaging.Email[] { mail });
        }
    }
}
--- Schedular --
global class ScheduleSendEmailToNonActiveUsers implements Schedulable{
    
    global void execute(SchedulableContext sc){
        SendEmailtoNonActiveUsersBatch s = new SendEmailtoNonActiveUsersBatch();
        database.executeBatch(s, 10);
    }
    
}

--- TEST CLASS -----
@isTest
public class SendEmailtoNonActiveUsersBatch_Test {
        
    @IsTest(seeAllData=true)
    public static void SendEmailTest_positive()
    {
          User us = [Select id from User where Id = :UserInfo.getUserId()];
        
        System.runAs(us)
        { 
           List<user> uu = [SELECT id,Firstname,Lastname,Profile.name, email,Isactive, LastLoginDate, category__c,IsEmailSendToNonActive__c FROM User where IsActive=True and Category__c= 'Employee' and IsEmailSendToNonActive__c != true and LastLoginDate < LAST_N_DAYS:20 order by Firstname ASC Limit 10];
        Test.startTest();
        SendEmailtoNonActiveUsersBatch s = new SendEmailtoNonActiveUsersBatch();
     
        database.executeBatch(s);
         Test.stopTest();
        }
    }
}

Another observation: test class should execute DML query menstioned in test class(resulte records 10). But when I run the test class it take query mentioned in batch apex(result records 162). 
 
Hello, 

Validation Rule to stop record from saving when a picklist value is blank fires, but not on the correct stage selection.

Use case:

Opportunity Object, has 6 record types (Group, Branch, Vendor, Client, Guest, Ti In Progress)

If the Opportunity RecordTypeId is “0122E000000iFFKQA2”
and the StageName Picklist is “Ti In Progress", a value from the picklist named, Resolution Type, must have a value selected prior to saving the record. If the Resolution Type picklist is left blank, the validation rule should error out the save attempt.

The VR I created is firing but not when the stage = Ti In Progress. I can select a different stage, prior to reaching Ti In Progress and the record errors out. . 

I created this VR, tested it, and found not syntax errors. I was able to save the record even when the Resolution Type picklist was left blank. It should have prompted me to select a value from the picklist. 

Any help on this would be appreciated!
Thanks

 
1AND( 
2ISPICKVAL( StageName, 'Ti In Progress'), 
3RecordTypeId="0122E000000iFFKQA2", 
4ISBLANK(TEXT( Resolution_Type__c)) 
5)

 
  • June 27, 2019
  • Like
  • 0
How do you create a SOQL query using a filed name from a List of custom objects. I tried this but it doesn't work:
 
List<Payment__c> payments = [SELECT Id,Name,Order__c,Settled_Date__c,Success_Date__c FROM Payment__c WHERE Order__c IN :orders.customerOrderCode];

'orders' is a List<CustomApexObject> where CustomApexObject is just what it says, and it has a field called customerOrderCode, which contains a valid 'Order' Id,

The code above fails because customerOrderCode is a field on the CustomApexObject, not on the List<CustomApexObject>

Thanks!

Hi ,
How to write the trigger handler for my below code,

trigger DerexSortTrigger on DerexSoft__c (before insert, before update) {

 for( DerexSoft__c  aps:trigger.new){

Boolean valArr;
String uforted;        
String ArrPat;        
ArrPat = '^\\d?[1-9][,\\;\\.]\\d?[1-9][,\\;\\.]\\d?[1-9][,\\;\\.]\\d?[1-9][,\\;\\.]\\d?[1-9]$';

uforted = aps.Uforted__c;
valArr = Pattern.matches(ArrPat,uforted);

if(aps.Uforted__c != null && valArr!= true ){
    aps.Uforted__c.addError();                   

                }
        }
}
I'm doing the Transaction Security Module on Trailhead. and at the final stage "Explore Custom Transaction Security Policies" the test class below is provided. I get the following error when I attempt to sace it.

Error: Compile Error: Invalid type: MyDataLoaderLeadExportCondition at line 18 column 5

Line 18 has this code: 
MyDataLoaderLeadExportCondition dataLoaderLeadExportCondition = new MyDataLoaderLeadExportCondition();

Are you able to assist me with correcting the error?
/**
 * Test for default MyDataLoaderLeadExportCondition provided by Salesforce
 * 
*/
@isTest
public class MyDataLoaderLeadExportConditionTest {
    /*
     * Test to check if policy gets triggered when user exports 750 Leads
    */
  public static testMethod void testLeadExportTriggered() {
    Map<String, String> eventMap = getEventMap(String.valueOf(750));
    Organization org = getOrganization();
    User user = createUser();
      
    TxnSecurity.Event e = createTransactionSecurityEvent(org, user, eventMap) ;
    /* We are unit testing a PolicyCondition that triggers
       when an event is generated due to high NumberOfRecords */
    MyDataLoaderLeadExportCondition dataLoaderLeadExportCondition = new MyDataLoaderLeadExportCondition();
    /* Assert that the condition is triggered */
    System.assertEquals(true, dataLoaderLeadExportCondition.evaluate(e));
   }
    /*
     * Test to check if policy doesn't get triggered when user exports 200 Leads
    */
  public static testMethod void testLeadExportNotTriggered() {
    Map<String, String> eventMap = getEventMap(String.valueOf(200));
    Organization org = getOrganization();
    User user = createUser();
       
    TxnSecurity.Event e = createTransactionSecurityEvent(org, user, eventMap) ;
    /* We are unit testing a PolicyCondition that does not trigger
       an event due to low NumberOfRecords  */
    MyDataLoaderLeadExportCondition dataLoaderLeadExportCondition = new MyDataLoaderLeadExportCondition();
      
    /* Assert that the condition is NOT triggered */
    System.assertEquals(false, dataLoaderLeadExportCondition.evaluate(e));
  }
    /*
     * Create an example user
     */
    private static User createUser(){
        Profile p = [select id from profile where name='System Administrator'];
        String ourSysAdminString = p.Id; 
        
        User u = new User(alias = 'test', email='user@salesforce.com',
            emailencodingkey='UTF-8', lastname='TestLastname', languagelocalekey='en_US',
            localesidkey='en_US', profileid = p.Id, country='United States',
            timezonesidkey='America/Los_Angeles', username=generateRandomUsername(7));
        insert u;
        return u;
    }
    /**
     * Generates a random username of the form “[random]@[random].com”, where the 
     * length of the random string is the given Integer argument. For example, with 
     * an argument of 3, the following random username may be produced: 
     * “ajZ@ajZ.com”.
     */ 
    private static String generateRandomUsername(Integer len) {
        final String chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
        String randStr = '';
        while (randStr.length() < len) {
           Integer idx = Math.mod(Math.abs(Crypto.getRandomInteger()), chars.length());
           randStr += chars.substring(idx, idx+1);
        }
        return randStr + '@' + randStr + '.com'; 
    }

    /*
     * Returns current organization
     */
    private static Organization getOrganization(){
        return [SELECT id, Name FROM Organization];
    }
      
    /*
     * Adds NumberOfRecords and example ExecutionTime
     */ 
    private static Map<String, String> getEventMap(String numberOfRecords){
        Map<String, String> eventMap = new Map<String, String>();
        eventMap.put('NumberOfRecords', numberOfRecords);
        eventMap.put('ExecutionTime', '30');
        eventMap.put('EntityName', 'Lead');
        return eventMap;
    }
    
    /*
     * Create a TxnSecurity.Event instance
     */ 
    private static TxnSecurity.Event createTransactionSecurityEvent(Organization org, User user, Map<String, String> eventMap){
        TxnSecurity.Event e = new TxnSecurity.Event(
             org.Id /* organizationId */,
             user.Id /* userId */,
             'Lead' /* entityName */ ,
             'DataExport' /* action */,
             'Lead' /* resourceType */,
             '000000000000000' /* entityId */,
              Datetime.newInstance(2016, 9, 22) /* timeStamp */,
              eventMap /* data - Map containing information about the event */ );
        return e;
    }
}

 
Hey there,

I have a quick question regarding the usage of isLeapYear for a Date. 

Does isLeapYear always require a parameter within the brackets? This code apparently works...
Date myDate = Date.newInstance(2041, 11, 19);
Boolean dateIsLeapYear = Date.isLeapYear(myDate.year());
System.debug(dateIsLeapYear);
... but what about next one? I guess it's not possible to place first the variable and leave the brackets empty:
Date myDate = Date.newInstance(2041, 11, 19);
Boolean dateIsLeapYear = myDate.isLeapYear();
System.debug(dateIsLeapYear);
Just wanna make sure.

Thanks for your help!
Hi everyone, I'm trying to do this superbadge, but I'm receiving this message "The 'Sign Me Up' button is not automatically assigning the logged in user's name to the new Volunteer Shift Worker record."
I'm stuck since 2 days ago, I have checked the process builder, approval process and quick action
I created a trigger that  display an error message if the owner of a opportunity tries to enter the same number in a field that is already on another record. My trigger below is working mostly. The message shows at the field level when there is another opportunity with the same number, but if i create an  opportunity and do not enter a number ( so the field is null/blank). Then go back into the record
and try to add a number it gives me the error message no matter what number I enter into the field. I'm not sure how to get the trigger to allow a user to enter a number in the field after it's been created without getting the error. Any help would be greatly appreciated.
 
trigger TR_RejectDupPriority on Opportunity (before insert, before update) {
    
    //Display error message if another opportunity has the same number in Quting_Priority__c field

 Set<decimal> oppSet = new Set<decimal>();

 for(Opportunity o : trigger.new){

     oppSet.add(o.Quting_Priority__c);
       
}

 //query all existing record for quoteprioritynum__c
 List<Opportunity> oppsList = [SELECT id,Owner.Profile.Name, Owner.Id,
 Quting_Priority__c, LastModifiedBy.Id, quoteprioritynum__c 
      FROM Opportunity 
      WHERE Quting_Priority__c in :oppSet AND 
 Owner.Id = :userinfo.getuserid()];
   
    //ignore system admins
    Profile pr = [select id from Profile where name='System Administrator'];
  
  if(UserInfo.getProfileId()!=pr.id)
for(Opportunity o:trigger.new) 
    
{
    //Check Update for dupe numbers
    if(Trigger.isUpdate && 
    Trigger.oldmap.get(o.id).Quting_Priority__c!=o.Quting_Priority__c
     && o.LastModifiedBy.Id == o.Owner.Id)
       
    {
       o.Quting_Priority__c.adderror('Another quote has the same priority number, please enter a new number!');
    }

    //Only check for priority size
    if(Trigger.isInsert && o.Quting_Priority__c==o.Quting_Priority__c
         && oppsList.size()>0 && o.LastModifiedBy.Id == o.Owner.Id)
       
    {
       o.Quting_Priority__c.adderror('Another quote has the same priority number, please enter a new number!');

    }
} 

}



 

Hello, I try to finish the Trailhead challlenge Create a Unique Account List View but I have ne error like this : 

There was an unexpected error while verifying this challenge. Usually this is due to some pre-existing configuration or code in the challenge Org. We recommend using a new Developer Edition (DE) to check this challenge. If you're using a new DE and seeing this error, please post to the developer forums and reference error id: MPIWTUII

I use different Developer Edition playground. But each time it is the same and my list view seems to be OK.User-added image
User-added image
I don't know what to do with this issue.

Thanks for you help.

Hi,

does anyone know where to change, in the code, the width of the thank you message box (survey force)?

I tried a few things but it didn't work.

User-added image
I can see the Knowledge and Article Management tabs in Classic but once I switch to Lightning, I can't find the Article Management tab.
I have the Knowledge User checked on the User object and enabled the Lighting Knowledge in the Knowledge Settings, I believe that's the reason am able to see the Knowledge tab in lightning. 
Couldn't find anything related to Article Management tab. Any help would be appreciated. Thank you.
It's not a huge problem but something that needed attention. I tried creating new fields on both Standard and Custom objects in Lightning Experience on both Chrome and Firefox browsers, once the Save and New button is clicked, it just goes blank.

Is it just me or the latest '19 update?!
I am getting this error when trying to save my test, here is my test code
 
@istest (seeAllData = True) private class requnl_class_test  {

@isTest static void requnl_class_test () {
	Patient_Details__c client = new Patient_Details__c(
		Patient_name__c='Donkey Kong',
		Email_Address__c='tom@tom.com',
		Phone_number3__c='2012012233'
		);
	insert client;
	Patient_chart__c chart= new Patient_chart__c (
		RESTORE_Client__c=client.Id,
		name='sard'
		);
	insert chart;
	 
	ApexPages.currentPage().getParameters().put('id',chart.id);
	ApexPages.StandardController stdController = new ApexPages.StandardController(chart);
	
    requnl_class consext  = new requnl_class(stdController);

	PageReference pageRef = Page.Request_Unlock;

setCurrentPage(pageRef);

}
}

And here is my class code 
public without sharing class requnl_class
{
   private ApexPages.StandardController standardController;
   public String recId {get; set;}

 
    public requnl_class(ApexPages.StandardController standardController)
    {
    recId=ApexPages.CurrentPage().getparameters().get('id');
        this.standardController = standardController;
        
    }
  

public PageReference send() {

Messaging.singleEmailmessage email = new Messaging.singleEmailmessage();

patient_chart__c PatientId = [SELECT Id FROM patient_chart__c WHERE ID =:recid Limit 1]; 

List<string>sendTo = new List<String>();

sendTo.add('support@restorehair.com'); 

email.setToAddresses(sendTo);

email.setSubject('Please unlock this patient chart.'); 

email.setHtmlBody('Please unlock cs28.salesforce.com/'+PatientId.Id);

Messaging.sendEmailResult[] r = Messaging.sendEmail(new Messaging.singleEmailmessage[] {email});

        return null;
    }
}

Any help would be appreciated :)
 
Hi,

I have created a app and object belonging to the app but the object tab doesnt appear in the app

In SOQL...select id, whatid from task where WHAT.TYPE = 'Opportunity'.

Is there an alternative to WHAT.TYPE in APEX.

Hey all,

I am facing problem in authorization of my org through visual code for using lightening web component. I am using window 10. I have followed all the steps mentioned in trailhead. I have installed the salesforce CLI, latest version of visual studio. salesforce extension pack and salesforce CLI. I have created project using sfdx command create project. Now using ctrl+shift+p  when i select "Authorize an org". It shows error as mentioned in screnshot. Please help for the same as it is very urgent.User-added image

Hey, so every time I create the tab for Battle Station it saves as Battle Stations and I don't know why. To get the points it has to be Battle Station but I don't know how if I can't change the tab label. Please help and thank you! 
I have a unique situation,
I have a 500k records in one table and 100k records in another table, What is the best way to compare the data . I am not sure it is possible using APEX.
  • August 05, 2019
  • Like
  • 0
Hi Everyone,

I have created a "lead age" formula field in Salesforce to calculate the age from the time its created. When I query few records from developer
console it's giving me a different value than what I see on salesforce UI. 
Ex: For certain records, the lead age on UI is showing as 1 and when I query the same record from console then it is giving me the result as 2. 

I know it is a timeZone issue but I don't know how to fix this issue.

Can someone help me resolve this issue?. Your help on this is really appreciated  Lead Age formula
Hello,

I created a Date Field in custom object TiFF1040 and named the Date field, Date Director of Sales Approved TiFF. The date renders perfectly in a regular lightning page, however, when I place the following string in Visualforce, it produces this output: Mon Jul 22 00:00:00 GMT 2019

However, I need it to show as 7/22/2019.

Any help is appreciated.

Thank you!

 
{!TiFF1040__c.Date_Director_of_Sales_Approved_TiFF__c}

 
Hi,

I have a requirement to run report where "Customer Comments" field(Long Text Area) not equals to null records need to show on reports.
Any thoughts how to add long text area field on report filter.

Note: I have try on report filter to add "Customer Comments" field but is not showing on list.

Thanks in Advance.
I am attempting to write a validation rule to fulfill a customer request. Essentially, we have a custom field on the contact record called "Division". The short version is, I would like a validation rule that restricts a record from being created/saved if "Division" is blank when the related account = 0013200001FTkYh (ID of the account in question). Any help would be appreciated!

Hi Gurus,
I followed the below link to create a Picklist field in the component.

https://naveendhanaraj.wordpress.com/2018/06/19/lightning-picklist-component/

It works fine, the selected value is saved correctly.. But I am not able to display the selected value. It shows the first value in list.
Can you please guide me ..

Thanks,

Raghu

I have a custom object called University/Company. On the custom object is a lookup field to an account object called Company. I'd like to write a SOQL query that pulls the task information from this Company object via the University/Company object. Is this possible? I'm relatively new to SOQL, so any help would be greatly appreciated. Thanks!
    

I am trying to write a REST service which will send SF objects between Orgs. Right now, as a test, I am sending data to the same Org that it is coming from. I wrote a GET request which worked so I know the communcation part is working. But I am now trying to send an Account using POST. My JSON looks like this

    
{
    "acct": {
        "attributes": {
            "type": "Account",
            "url": "/services/data/v34.0/sobjects/Account/0018A000002ryhSQAQ"
        },
        "Id": "0018A000002ryhSQAQ",
        "IsDeleted": false,
        "Name": "Test",
        "RecordTypeId": "012C0000000QakwIAC",
        "BillingAddress": null,
        "ShippingAddress": null,
        "OwnerId": "0058A000000I5WbQAK",
        "CreatedDate": "2015-08-25T16:07:17.000+0000",
        "CreatedById": "0058A000000I5WbQAK",
        "LastModifiedDate": "2015-08-25T16:07:17.000+0000",
        "LastModifiedById": "0058A000000I5WbQAK",
        "SystemModstamp": "2015-08-25T16:07:17.000+0000",
        "LastViewedDate": "2015-08-28T13:54:38.000+0000",
        "LastReferencedDate": "2015-08-28T21:54:40.000+0000",
        "IsPartner": false,
        "IsCustomerPortal": false,
        "Advocacy__c": false,
        "Background_check_required__c": "Criminal",
        "External_Content_Approval_Required__c": false,
        "Indicative_Data_Options__c": "Name",
        "Internal_Content_Approval_Required__c": false
    }
}






**This is the service**
@RestResource(urlMapping='/ClientMigration')
global with sharing class ClientMigrationService {
    static Account clientMigrated;
    @HttpPost
    global static string Migrate(Account Client) {
        //Account a = JSON.deserialize(client);
        /*Map<String, SObject> mapJsonObjects = (Map<String, SObject>)
            JSON.deserialize(Client, Map<String, SObject>.class);
        Account a= (Account) mapJsonObjects.get('Account');   
        
        insert a;
        clientMigrated = a;
        */
        system.debug (client);
        return 'Success';
    }
    
     public class RequestWrapper{
        Account acct;
        public RequestWrapper(){}
    }        
        
 }


    

This is the code calling the service


    
public PageReference Migrate() {

        Account myAct = accountInfo ;

        system.debug('myAct = ' + myAct);

        RequestWrapper rw = new RequestWrapper();

        rw.acct = myAct;

        string myActJSON = JSON.serialize(rw);
        system.debug('myActJSON = ' + myActJSON );
        
        sendAccountDetails(myActJSON );
        return null;
    }
    
    private string sendAccountDetails(string actDetails) {
        HttpRequest req = new HttpRequest();

        req.setMethod('POST');
       
        string endpoint = oauth.instance_url +'/services/apexrest/ClientMigration';
        system.debug('endpoint = ' + endpoint);
        req.setEndpoint(endpoint);
       

        req.setBody(actDetails);
        req.setCompressed(true); 
        req.setHeader('Authorization', 'OAuth '+ oauth.access_token);
        req.setHeader('content-type', 'application/json');

        Http http = new Http();

        HTTPResponse res = http.send(req);

        System.debug('BODY: '+res.getBody());

        System.debug('STATUS:'+res.getStatus());

        System.debug('STATUS_CODE:'+res.getStatusCode());

        return res.getBody();

    }

 public class RequestWrapper{
        Account acct;
        public RequestWrapper(){}
    }





This is the error I keep seeing
Unexpected parameter encountered during deserialization: acct at [line:1, column:10]","errorCode":"JSON_PARSER_ERROR"}]

It seems that no matter what I do it complains at the location in the JSON where it get just past the very first object and gets into the inner objects. I tried doing this without the RequestWrapper and just serializing the account directly but had the same problem. I think I must be doing something wrong with the serialization process.

Does anyone have some suggestions?
Thanks,
Chris