• Harsh P.
  • NEWBIE
  • 135 Points
  • Member since 2018

  • Chatter
    Feed
  • 3
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 12
    Questions
  • 55
    Replies
I have a object product I want to update a task field value such as 
Order price is 100 then in task price should be automatically update as 100 I want to do this by workflow 
 
Hi,

I have a short, general question regarding collection types for sObjects when it comes to inline SOQL queries. 

As we all know there are three collection types: Lists, Sets and Maps. I recently stumbled upon a Trailhead Project (https://trailhead.salesforce.com/content/learn/projects/quickstart-apex/quickstart-apex-2) where neither of these types where used in a method to retrieve a list of records using an SOQL query:
Account[] oldAccounts = [SELECT Id, Description FROM Account ORDER BY CreatedDate ASC LIMIT 5];
I'm talking about the Account[] part of the code. Can someone explain to me what makes the [] type  different from the List type? How does it behave and what are the particular use cases? When to use Account[] and when to use List<Account>?

I guess one could have also go for this option:
List<Account> oldAccounts = [SELECT Id, Description FROM Account ORDER BY CreatedDate ASC LIMIT 5];
Any help appreciated! 

Best,
David
global with sharing class DebtCollection implements Schedulable 
{
    /
    global void execute(SchedulableContext sc)
    {
        createDebtCollectionCases();
        updateAccounts();
        updateCasesToDemand();
        //sendReminderEmails(AccountsRequiringReminder());
    }
    private static void createDebtCollectionCases(){
        try{
           insert casesToCreate(AccountsRequiringDebtCase());
        }catch(Exception e){
            
        }
    }
    
   private static void updateAccounts()
    {
        List<Account> accsToUpdate = AccountsRequiringDebtCase();
        for(Account acc : accsToUpdate){
            acc.Has_Open_Debt_Case__c = TRUE;
        }
        try {
            update accsToUpdate;
        }catch(Exception e){
            
        }
    }
      
    private static void updateCasesToDemand()
    {
        try {
            update casesToUpdate(CasesRequiringDemand());
        }catch(Exception e){
            
        }
    }
    
    
    public static List<Account> AccountsRequiringDebtCase()
    {   
        //Accounts with credit term of 30 have their 60 day balance checked on the 2nd of each month
        Integer creditTermDate30 = 2;
        //Accounts with credit term of 35 have their 60 day balance checked on the 7th of each month
        Integer creditTermDate35 = 7;
        //Accounts with credit term of 45 have their 60 day balance checked on the 17th of each month
        Integer creditTermDate45 = 17;
        List<Account> accList = new List<Account>();
        if(Date.today().Day()==creditTermDate30){
            accList.add([
                select Id, Has_Open_Debt_Case__c, Most_Recent_Statement_Date__c 
                from Account where
                Has_Open_Debt_Case__c = FALSE and
                Day_60_Balance__c > 0 and Credit_Terms__c = 30
                ]);  
            system.debug('accList' +accList);
        }
        if(Date.today().Day()==creditTermDate35){
            accList.add([
                select Id, Has_Open_Debt_Case__c, Most_Recent_Statement_Date__c 
                from Account where
                Has_Open_Debt_Case__c = FALSE and
                Day_60_Balance__c > 0 and Credit_Terms__c = 35
            ]);  
        }
        if(Date.today().Day()==creditTermDate45){
            accList.add([
                select Id, Has_Open_Debt_Case__c, Most_Recent_Statement_Date__c 
                from Account where
                Has_Open_Debt_Case__c = FALSE and
                Day_60_Balance__c > 0 and Credit_Terms__c = 45
             ]);  
        }
         accList.add([
            select Id, Has_Open_Debt_Case__c, Most_Recent_Statement_Date__c 
            from Account where
            Has_Open_Debt_Case__c = FALSE and
            credit_hold_date__c != null and (Day_60_Balance__c >0 OR Day_90_Balance__c>0)
                
       ]); 
        
        

     return  accList;
        
    }
    
    
    public static List<Case> CasesRequiringDemand()
    {   
        
        Date demandDay = Date.today().addDays(-30);
        Id DebtRecordType = Schema.SObjectType.Case.getRecordTypeInfosByName().get('Debt Collection').getRecordTypeId();
        
        List<Case> caseList = [
            select Id, Status 
            from Case where
            Status != 'Closed' AND recordTypeId = :DebtRecordType AND createddate  = :demandDay
         ];
        
        return  caseList;
        
    }
    
    
    private static List<Case> casesToCreate(list<Account> accounts)
   {
         List<Case> returnList = new list<Case>();
         Id devRecordTypeId = Schema.SObjectType.Case.getRecordTypeInfosByName().get('Debt Collection').getRecordTypeId();
         List<Group> queueId = [select Id from Group where Name = 'Finance Queue' and Type = 'Queue'  ];
        
        
        
         if(!accounts.isEmpty())
         {
             for(Account acc: accounts)
             {
                 Case newCase = new Case();
                 newCase.AccountId = acc.id;
                 newCase.RecordTypeId = devRecordTypeId;
                 newCase.ownerId = queueId[0].id;
                 returnList.add(newCase);
             }
         }
        
         return returnList;
    }
    
    
   private static List<Case> casesToUpdate(list<Case> cases)
    {
        if(!cases.isEmpty())
        {
            for(Case c: cases)
            {
                c.Status = 'Demand';
            }
       }
        
        return cases;
    }
i am getting List has more than 1 row for assignment to SObject error when schduling the job.

please some one help me on this.
Hi Team,

I have requirement to to revent/restrict the user from Non Ascii Characters in one of field. User should not enter the Non Ascii Character in the field.
Hi Team,

I the screen flow I am using lookup and it is working on button, When I click on button screen is opening. I am searching some name in lookup ex. ty... and when I press enter or clicked on seach then we should get standard popup for matching result. We can say search layout. 
This layout not opening in my case, getting std component failing error:
failing error

configuration are below for lookup:
field api name - my_account__c(this is the lookup field on Book__c which is account)
object api name(source) - Book__c
Same configuration I am doining in personal org it is working. Is I made something wrong? Is it related to any permissions?
Hi Guyes,

I have one requirement of custom calender. Here functionality should be as we can add custom holidays as per org and below logic :
Once we select particular date for oppointment, next 4 days shoud be disable.
No one (any user) can select that 4 days for oppointment.

Thanks in Advance !
Hi Guy's,

I need your help.
I have requirement of integration(Salesforce to Oracle Integration Cloud).
As we know OIC is the configuration tool. Trying to do but data get's failed.


Thanks,
Harsh. P.
Hi All,

I want to compare createdDate with todays Date.
I have tried this one: 
 
List<contact> con = [Select Id,LastName,Owner.Email,OwnerId,CreatedDate,Email from Contact];
for(contact c : con) {
    if(c.CreatedDate == system.now()){
        system.debug('if');
    }else{
        system.debug('else');
    }
}


It is printed else .I want to get IF part.
Help to get the way...............
Thanks in Advance..............! 

Hello Guys,

I know the some points to keep in mind before the deployment using change set,but I want to know more details about this points.
And also want to know common issues facing at the time of deployment.

Thanks in Advance .....!
Hello,

I have custom obj Order__c with some records and each records having some attachments.Order__c having field Order_No__c
For lightning cmp I have to show Order_No__c and It's related attachments like below table : 
Sr.No      Order No        AttachmentName
1              12xx               MyAttachment.jpg


Now,I need an help to write controller specially Query ?

I have one que.
In approval process, approver 1 is X and approver 2 is Y. I have submited the record for approval and it is pending with the approver 1 X. After this I changed approver 2 as Z.

Then my Que is If approver 1 is approve the record then it will goes to Y or Z ?

while I am trying to proceed button getting the Following error:
 "Error occurred while loading a Visualforce page."
I have search on google but not getting exact solution on this.
Please help me to out from this issue.
Please help for following VF page:
I want Output like this :
-----------------------------------------------
AccountName1         Contact 1
                                   Contact 2

AccountName2         Contact 1
                                   Contact 2
                                   Contact 3

-------------------------------------------------
How to Test System.today().day() in test class.
I have written test class for following Batch:

My Batch Is::

global class ASGPaymentFailedBatch implements Database.Batchable<sObject>,Database.stateful{
    
    global Database.QueryLocator start(Database.BatchableContext BC){ 
        String type ='Monthly';
        String status = 'Hold';
        String transStatus = 'failed';
        string query = 'SELECT id,Transaction_Status__c,Payment__r.Monthly_Parker__r.Email__c FROM Transaction__c WHERE Transaction_Status__c=:transStatus AND Payment__r.Monthly_Parker__r.Revenue_Type__c=:type AND Payment__r.Monthly_Parker__r.Status__c=:status ORDER BY CreatedDate DESC';  
        
        return Database.getQueryLocator(query);
    }

    global void execute(Database.BatchableContext BC, List<Transaction__c> scope){
        
        Set<String> friendlyEmailIdSet = new Set<String>();
        Set<String> suspendEmailIdSet = new Set<String>();
        Set<String> mParkerIdSet = new Set<String>();

        for(Transaction__c eachTransaction : scope){
            if(eachTransaction.CreatedDate.day()== 01 || eachTransaction.CreatedDate.day()== 1){
                if(System.today().day() == 02 || System.today().day() == 2 || System.today().day() == 03 || System.today().day() == 3){
                    friendlyEmailIdSet.add(eachTransaction.Payment__r.Monthly_Parker__r.Email__c);
                }
                else if(System.today().day() == 04 || System.today().day() == 4 ){
                    suspendEmailIdSet.add(eachTransaction.Payment__r.Monthly_Parker__r.Email__c);
                }
                mParkerIdSet.add(eachTransaction.Payment__r.Monthly_Parker__c);
            }
        }
        
        
        List<Messaging.SingleEmailMessage> lstMsgs = new List<Messaging.SingleEmailMessage>();

        String friendlyID = [select id from EmailTemplate where DeveloperName='Friendly_Notice'].id;
        String suspendID = [select id from EmailTemplate where DeveloperName='Suspended'].id;
        
                
        for(M_Parker__c mParker : [SELECT ID,Email__c FROM M_Parker__c WHERE ID IN : mParkerIdSet]){
            Messaging.SingleEmailMessage msg = new Messaging.SingleEmailMessage();
            if(friendlyEmailIdSet.size()>0)
                msg.setTemplateId( friendlyID );
            else if(suspendEmailIdSet.size()>0){
                msg.setTemplateId( suspendID );
            }       
            msg.setTargetObjectId(mParker.id);
            msg.setToAddresses(new String[] {mParker.Email__c});
            lstMsgs.add(msg);           
        }   

        Messaging.sendEmail(lstMsgs);      
    }

    global void finish(Database.BatchableContext BC){
        
    }
}


My Test Class is::

@isTest
public class ASGPaymentFailedBatchTest {
    static testMethod void InsertPayibleTransaction(){
        
        Account accountObj = new Account();
        accountObj.Name = 'TestAccount';
        insert accountObj;
        
        Contact contactObj = new Contact();
        contactObj.LastName = 'Patil';
        contactObj.AccountId =accountObj.Id;
        contactObj.FirstName = 'Sachin';
        contactObj.Email ='sachin@gmail.com'; 
        contactObj.Phone = '9988767856';    
        insert contactObj;
        
        Location__c objLocation = new Location__c();
        objLocation.Name = 'WashingtonDC';
        objLocation.Loc__c = 0;
        objLocation.Location_Number__c = '22';
        objLocation.Address__c = '5454 Wisconsin Ave.';
        objLocation.City__c = 'Chevy Chase';
        objLocation.State__c = 'AK';
        insert objLocation;
        
        M_Parker__c objParker = new M_Parker__c();
        objParker.Account__c = contactObj.AccountId;
        objParker.Auto_color__c = 'Teal';
        objParker.Auto_Make__c = 'Audi';
        objParker.Auto_Model__c = 'audi 005';
        objParker.Auto_Year__c = '2018';
        objParker.Lic_Plate_State__c ='MH127788';
        objParker.Tenant__c = 'No';
        objParker.FacID__c = objLocation.Id;
        objParker.MonthlyParkerName__c = contactObj.Id;
        objParker.Revenue_Type__c = 'Monthly';
        objParker.Status__c = 'Hold';
        //objParker.Email__c = 'test@gmail.com';
        insert objParker;
         
        M_Parker__c pak = [Select Email__c from M_Parker__c where Id =: objParker.Id ];
        system.debug('pak-->'+pak);
        
        Payment__c ObjPayiblePayment = new Payment__c();
        //ObjPayiblePayment.Subscription_Product_Id__c = 'prod_EGzTyy8IEX2mAP';
        ObjPayiblePayment.Subscription_Customer_Id__c = 'cus_EGzTK9y1W2jYc6'; 
        //ObjPayiblePayment.Customer_Id__c = contactObj.Id;
        ObjPayiblePayment.Subscription_Id__c = 'sub_EGzT63XNdP1O6y';
        ObjPayiblePayment.Phone__c = '9968694934';  
        ObjPayiblePayment.Card_Type__c = 'visa';
        ObjPayiblePayment.Monthly_Parker__c = objParker.Id;
        ObjPayiblePayment.Customer_Name__c =  'Test Community';
        //ObjPayiblePayment.Payment_Gateway__c = ObjPaymentGateway.Id;    
        ObjPayiblePayment.Payment_Description__c = 'Test--28 - Barlow Building 2019-01-03 00:00:00';
        ObjPayiblePayment.Subscription_Name__c = 'TestSubscription';
        ObjPayiblePayment.Billing_ZIP_Postal_Code__c ='411028'; 
        ObjPayiblePayment.Billing_State_Province__c = 'Ny'; 
        ObjPayiblePayment.Billing_City__c ='TestCity'; 
        ObjPayiblePayment.Billing_Street__c = 'TestStreet';
        ObjPayiblePayment.Customer_Email__c = 'test@gmail.com';
        ObjPayiblePayment.Last_Name__c = 'TestThis';
        ObjPayiblePayment.First_Name__c = 'MyTest';
        ObjPayiblePayment.Amount__c = 100;
        ObjPayiblePayment.Exp_Year__c = '2026';
        ObjPayiblePayment.Exp_Month__c = '05';
        ObjPayiblePayment.Name_on_the_Card__c ='TestTest';
        ObjPayiblePayment.Billing_Country__c = 'US';
        ObjPayiblePayment.Currency_Type__c = 'USD';
        //ObjPayiblePayment.CVV__c = '233';
        ObjPayiblePayment.Card_Number__c = '1111222233334444';
        Insert ObjPayiblePayment;
        
        Transaction__c ObjTransaction = new Transaction__c();
        ObjTransaction.Transaction_Status__c = 'failed';
        ObjTransaction.Payment__c = ObjPayiblePayment.Id; 
        Insert ObjTransaction;
        
        DateTime fixDate = DateTime.newInstance(2012, 7, 01, 3, 3, 3);
        Test.setCreatedDate(ObjTransaction.Id, fixDate);

        
        system.debug('ObjTransaction-->'+ObjTransaction);
        
        Test.startTest();
        ASGPaymentFailedBatch objASGPaymentFailed = new ASGPaymentFailedBatch();
        DataBase.executeBatch(objASGPaymentFailed);
        Test.stopTest();
    }

}
 

I am new in Test class.I am not getting Logic for this test class ....Help.
public with sharing class MonthlyParkerHistoryCntl {
    public List<M_Parker__c> mnthlyParkerList{get;set;}
    public String urlAmount{get;set;}
    public String locationID{get;set;}
    public String amnt{get;set;}
    public String mParkerID{get;set;}
    public Map<ID,M_Parker__c> mparkerMap;
    //public Map<ID,M_Parker__c> mparkerMap;
    public boolean tableData{get;set;}
    public Contact objCon{get;set;}
    
    
    public String successError{get;set;}
    public String msg{get;set;}
    public boolean isError{get;set;}
    
    public MonthlyParkerHistoryCntl(){
        
        User objUser = new User();
        objUser = [SELECT ID,ContactID FROM User WHERE ID=: UserInfo.getUserId() LIMIT 1];
        
        objCon = new Contact();
        if(objUser.ContactID != null )
            objCon = [SELECT ID,AccountID,FirstName,LastName,Email,Phone,MailingStreet,MailingCity,MailingState,MailingPostalCode,MailingCountry,Tenant__c,Auto_Make__c,Auto_Model__c,Auto_Color__c,Auto_Year__c,Lic_Plate_State__c FROM Contact WHERE ID=: objUser.ContactID];
        
        if(objCon.AccountID != null){
            mparkerMap = new Map<ID,M_Parker__c>();
            mnthlyParkerList = new List<M_Parker__c>();
            for(M_Parker__c parker: [SELECT ID,Name,FacID__r.Name,FacID__c,Start_Date__c,End_Date__c,FacID__r.Revenue_Type__c, FacID__r.Location_Phone__c,FacID__r.Monthly_Rate__c FROM M_Parker__c WHERE Account__c =: objCon.AccountID ORDER By Name DESC]){
                mnthlyParkerList.add(parker);
                mparkerMap.put(parker.ID,parker);
            }
        }
        tableData = true;
        isError = false;
    }
    
    public pagereference displaymParkerInfo(){
        System.debug('Inside -displaymParkerInfo '+mParkerID );
        if(mparkerMap.containsKey(mParkerID)){
            tableData = false;          
            M_Parker__c parker = mparkerMap.get(mParkerID);
            
            System.debug('parker -> '+parker);
        }
        return null;
    }
    
    public void backtoParkerHistory(){
        tableData = true;
        isError = false;
    }
     
    public pagereference renewParking(){
        
        if(locationID != null && amnt!=null){
            return new PageReference('https://techiladev-atlanticparking.cs77.force.com/s/parkagreementclone?locID='+locationID+'&amount='+amnt);   
        }       
        return null;
    } 
    
    public Pagereference cancelParking(){
        if(mParkerID != null && mParkerID != ''){
            if(mparkerMap.containsKey(mParkerID)){
                M_Parker__c parker = mparkerMap.get(mParkerID);
                parker.End_Date__c = System.today();
                update parker;
            }
            
        }
        return null;
    } 

    public void saveUserInfo(){
        if(objCon != null){
            update objCon;
            
            isError = true;
            successError = 'success';
            msg = '"Details Saved Successfully"';
        }
        
    }
    
}
Hi Team,

I have requirement to to revent/restrict the user from Non Ascii Characters in one of field. User should not enter the Non Ascii Character in the field.
Hi Team,

I the screen flow I am using lookup and it is working on button, When I click on button screen is opening. I am searching some name in lookup ex. ty... and when I press enter or clicked on seach then we should get standard popup for matching result. We can say search layout. 
This layout not opening in my case, getting std component failing error:
failing error

configuration are below for lookup:
field api name - my_account__c(this is the lookup field on Book__c which is account)
object api name(source) - Book__c
Same configuration I am doining in personal org it is working. Is I made something wrong? Is it related to any permissions?
I'm sending emails generated in Apex from Lightning.  The emails are sending but they're coming through without an email body, despite a classic email template being set.
 
EmailTemplate template = [Select id, subject from EmailTemplate where name = 'My Template' limit 1];
...
Messaging.SingleEmailMessage msg = new Messaging.SingleEmailMessage();
msg.setTemplateId(template.Id);   // <<--- look
...
system.debug(Messaging.sendEmail(emails,false) );

The SendEmailResult generated by the system.debug shows...
15:34:51:342 USER_DEBUG [35]|DEBUG|Messaging.SingleEmailMessage[
getBccAddresses=null;
getCcAddresses=null;
getCharset=null;
getEntityAttachments=null;
getFileAttachments=null;
getHtmlBody=null;
getInReplyTo=null;
getOptOutPolicy=SEND;
getOrgWideEmailAddressId=0D20U0000008P2cSAE;
getPlainTextBody=null;
getReferences=null;
getTargetObjectId=0030U00000eXdLNQA0;
getTemplateId=00Xf4000000h8eaEAA;    // <<--- look
getToAddresses=null;
getWhatId=null;
isTreatBodiesAsTemplate=false;
isTreatTargetObjectAsRecipient=true;
isUserMail=false;
]

getTemplateId is showing the correct id for the Classic Email Template.

So -- all is perfect, except the template isn't coming through in the email.

What am I missing?

Thanks,

Steve 
 
Hi,

 I want to send a email notification to customer as payment reminder. if customers credit term is 30, so he should be notified 5th each month and if the customers credit term is 35, he should be notified 7th each month.
how can i achieve this using apex.

please help me on this.
I have a object product I want to update a task field value such as 
Order price is 100 then in task price should be automatically update as 100 I want to do this by workflow 
 
Hi Guys!
I want to show on my component a Checkbox Group. The values are already defined by the Record. My code, for now, is this one with all the picklists that work perfectly -
How I can add those 4 checkboxes?


<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
   <lightning:card>
       
           <lightning:layout multipleRows="true">
          <lightning:layoutItem size="6">
       <lightning:recordForm recordId="{!v.recordId}" objectApiName="Lead" fields="My_Commodity_Interests_include__c" />
       </lightning:layoutItem>
           <lightning:layoutItem size="6">     
               <lightning:recordForm recordId="{!v.recordId}" objectApiName="Lead" fields="Non_Ferrous_Metals__c"/>
</lightning:layoutItem>
       <lightning:layoutItem size="6">
           <lightning:recordForm recordId="{!v.recordId}" objectApiName="Lead" fields="Ferrous_Steel__c"/>
               </lightning:layoutItem>
           <lightning:layoutItem size="6">
               <lightning:recordForm recordId="{!v.recordId}" objectApiName="Lead" fields="Fertilizers__c"/>
               </lightning:layoutItem>
       <lightning:layoutItem size="6">
                          <lightning:recordForm recordId="{!v.recordId}" objectApiName="Lead" fields="I_am_interested_in_hearing_about__c"/>
</lightning:layoutItem>
       <lightning:layoutItem size="6">
                          <lightning:recordForm recordId="{!v.recordId}" objectApiName="Lead" fields="Light_Metals__c"/>
               </lightning:layoutItem>
       
                 
               
             
      <aura:attribute name="options" type="List" default="[
    {'label': 'Ross', 'value': 'option1'},
    {'label': 'Rachel', 'value': 'option2'}
    ]"/>
    <aura:attribute name="value" type="List" default="option1"/>

    <lightning:checkboxGroup name="Checkbox Group"
                             label="Checkbox Group"
                             options="{! v.options }"
                             value="{! v.value }"
                             onchange="{! c.handleChange }"/>        
       
            
           </lightning:layout>
  
          
     
   </lightning:card>
    
Hi Team,
I have  a custom field Contact_Self_relationship__c on contact object which is a self lookup to contact itslef.
I have 2 contacts Alen and Josh. In both contact, Contact_Self_relationship__c  field have value as Ana (which is also a contact). Means Ana is parent contact for both Alen and Josh.
Now I am tryning to fetch the Alen and Josh contact record based on the Ana. I tried parent to child and child to parent combinations but I am not getting the list of child contacts. can anyone help me here?
Hi,

I need to get the lookup icon in Lightning input field. Can anyone please help .

Currently , I am getting a free text area . I have to lookup to user object