• Saravanan Gengan 9
  • NEWBIE
  • 85 Points
  • Member since 2016

  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 14
    Replies

All,
Our developer is no longer with us, and I need to modify this Case, Field formula.  I want the field to be set to a Y if it was created Monday - Friday, between the hours of 6:00 PM EST and 11:59 PM EST.  I can't figure out which part of this formula needs to be updated.
I believe this code was originally set for Sunday to Friday.
I appreciate your assistance.
IF(
AND(
VALUE(LEFT(RIGHT(TEXT( CreatedDate ),9),2))>= 0,VALUE(LEFT(RIGHT(TEXT( CreatedDate ),9),2))<=11,CASE(MOD(DateValue(CreatedDate)-DATE(1900, 1, 7 ), 7 ), 1, 1, 2, 1, 3, 1, 4, 1, 0)=1), "Y",
IF(
AND(VALUE(LEFT(RIGHT(TEXT( CreatedDate ),9),2))<=4,VALUE(LEFT(RIGHT(TEXT( CreatedDate ),9),2))>=1,CASE(MOD(DateValue(CreatedDate)-DATE(1900, 1, 7 ), 7 ), 0, 1, 0)=1),"Y",
IF(
AND(VALUE(LEFT(RIGHT(TEXT( CreatedDate ),9),2))>=5,VALUE(LEFT(RIGHT(TEXT( CreatedDate ),9),2))<=12,CASE(MOD(DateValue(CreatedDate)-DATE(1900, 1, 7 ), 7 ), 5, 1, 0)=1),
"Y","N")
)
)

 
Hello All,
I have the follwoing code and I want to return the count of records.
trigger Pupdate on Procedure__c (before update, before insert) {

Map<Id,AggregateResult> cprCnt = new Map<id,AggregateResult>([SELECT Count(id) maxRates
 		FROM Center_Procedure_Rate__c group by CPT_Code__c, Center__c]);
		
		if (Trigger.isInsert || (Trigger.isUpdate && proc.Amount_To_Pay__c == NULL && proc.Procedure_Cost__c == NULL) || 
					(Trigger.isUpdate && (proc.Procedure_Status__c != 'OK to Pay' && proc.Procedure_Status__c != 'Paid' &&
					   (proc.Amount_To_Pay__c != NULL && proc.Procedure_Cost__c != NULL)))) {
					// get count of Center Procedure Rates that match current procedure
					//centerRateCount = 
					//	[SELECT COUNT(Id) maxRates FROM Center_Procedure_Rate__c 
					//	 WHERE CPT_Code__c = :proc.CPT_Code__c AND Center__c = :proc.Center__c];
						 
					//maxCtrRates = centerRateCount[0].get('maxRates') == null ? 0 : (Integer)centerRateCount[0].get('maxRates');
					
					maxCtrRates = cprCnt.get(proc.Center__c, proc.CPT_Code__c);
					system.debug(maxCtrRates);
		}
}
In the code you can see I am doing it through Soql, but I need to have this bulkified.
we are not hiting our soql limtis.
Thansk,
K
 
When should i use data loader batch size 1? 
When should i use data loader batch size 1? 

All,
Our developer is no longer with us, and I need to modify this Case, Field formula.  I want the field to be set to a Y if it was created Monday - Friday, between the hours of 6:00 PM EST and 11:59 PM EST.  I can't figure out which part of this formula needs to be updated.
I believe this code was originally set for Sunday to Friday.
I appreciate your assistance.
IF(
AND(
VALUE(LEFT(RIGHT(TEXT( CreatedDate ),9),2))>= 0,VALUE(LEFT(RIGHT(TEXT( CreatedDate ),9),2))<=11,CASE(MOD(DateValue(CreatedDate)-DATE(1900, 1, 7 ), 7 ), 1, 1, 2, 1, 3, 1, 4, 1, 0)=1), "Y",
IF(
AND(VALUE(LEFT(RIGHT(TEXT( CreatedDate ),9),2))<=4,VALUE(LEFT(RIGHT(TEXT( CreatedDate ),9),2))>=1,CASE(MOD(DateValue(CreatedDate)-DATE(1900, 1, 7 ), 7 ), 0, 1, 0)=1),"Y",
IF(
AND(VALUE(LEFT(RIGHT(TEXT( CreatedDate ),9),2))>=5,VALUE(LEFT(RIGHT(TEXT( CreatedDate ),9),2))<=12,CASE(MOD(DateValue(CreatedDate)-DATE(1900, 1, 7 ), 7 ), 5, 1, 0)=1),
"Y","N")
)
)

 
I am getting 2 Errors that I am unclear how to fix them.  Any guidance would be great.  

Illegal assignment from List<OpportunityLineItem> to List<Quota__c> Line 11
Constructor not defined: [QuotaProductQueueable].<Constructor>(List<Quota__c>, Map<Id,OpportunityLineItem>) Line 15

trigger OpportunityProductTrigger on OpportunityLineItem (after insert, after update, after delete) {
    CustomTriggerSwitch__c cts = CustomTriggerSwitch__c.getValues('OpportunityProduct');
    CustomTriggerSwitch__c ct = CustomTriggerSwitch__c.getValues('Quota__c');
    
    if(cts == null || 
       cts.Active__c || 
       opportunityLineItem.Opportunity.business_plan__c <> null || 
       opportunityLineItem.Quota__c.ID <> null){ 
           
        List<OpportunityLineItem> olis = (Trigger.isDelete ? Trigger.old : Trigger.new);
        List<Quota__c> qta = (Trigger.isDelete ? Trigger.old : Trigger.new);
        
        
       // System.enqueueJob(new OpportunityProductQueueable(olis,Trigger.oldMap));
        System.enqueueJob(new QuotaProductQueueable(qta,Trigger.oldMap));
    }
}
Hey everyone,
I need some help converting my Apex trigger into a class. I am just unsure about the syntax differences between the trigger and class and I'm aware that I can't use trigger.new in the class. Do I need to create a new list to be able to use trigger.new? Any help or direction would be greatly appreciated!

Trigger:
trigger TotalAumUpdate on Account (after update) {
    for(Account acc : Trigger.new){
        Account oldAcc = Trigger.oldMap.get(acc.Id);
        if(oldAcc.Total_AUM__c != acc.Total_AUM__c){
            List<Opportunity> opps = [SELECT Id, AccountId, Current_Balance__c from Opportunity where AccountId = :acc.Id];                              
            List<Opportunity> newids = new List <Opportunity>();
            	for(Opportunity opp: opps){
                    if(opp.Current_Balance__c != acc.Total_AUM__c){
                        opp.Current_Balance__c = acc.Total_AUM__c;
                        newids.add(opp);
                    }
            }
            if(newids.isEmpty()== false){
                update newids;
            }
        }
    }

}

 
I want to be able to say If tempc.Status is not equal to 'Active' OR 'Intake', how would that statement look?  I've tried a bunch of different ways and nothing is working.

 // make sure the case is active or in intake status
        if(tempc.Status__c != 'Active') {
            ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'The case you selected is not in Intake or Active. Please only select Intake/Active Cases or create a new one.'));
            return null;
            }
Get this fatal error when run VFpage due to problem with extension:
14:16:49.0 (69545363)|FATAL_ERROR|System.SObjectException: SObject row was retrieved via SOQL without querying the requested field: Training_Class__c.Sign_up_Deadline__c Class.IAC_Lobby_Day_Extension.<init>: line 142, column 1

Line 142    isinPast=(course.Sign_up_Deadline__c < date.today()? true:false);

When run VF page get authorization request for Guest User - although no such authorization is indicated in code.
 
Hello All,
I have the follwoing code and I want to return the count of records.
trigger Pupdate on Procedure__c (before update, before insert) {

Map<Id,AggregateResult> cprCnt = new Map<id,AggregateResult>([SELECT Count(id) maxRates
 		FROM Center_Procedure_Rate__c group by CPT_Code__c, Center__c]);
		
		if (Trigger.isInsert || (Trigger.isUpdate && proc.Amount_To_Pay__c == NULL && proc.Procedure_Cost__c == NULL) || 
					(Trigger.isUpdate && (proc.Procedure_Status__c != 'OK to Pay' && proc.Procedure_Status__c != 'Paid' &&
					   (proc.Amount_To_Pay__c != NULL && proc.Procedure_Cost__c != NULL)))) {
					// get count of Center Procedure Rates that match current procedure
					//centerRateCount = 
					//	[SELECT COUNT(Id) maxRates FROM Center_Procedure_Rate__c 
					//	 WHERE CPT_Code__c = :proc.CPT_Code__c AND Center__c = :proc.Center__c];
						 
					//maxCtrRates = centerRateCount[0].get('maxRates') == null ? 0 : (Integer)centerRateCount[0].get('maxRates');
					
					maxCtrRates = cprCnt.get(proc.Center__c, proc.CPT_Code__c);
					system.debug(maxCtrRates);
		}
}
In the code you can see I am doing it through Soql, but I need to have this bulkified.
we are not hiting our soql limtis.
Thansk,
K
 
I am calling a server side action from a Lightning Component. When an error occurs I am trying to log them in a custom object using an @future method and then throwing an AuraHandledException so the component can display the message. It seems like this won't work with AuraHandledException since it causes a Script-thrown execption in the logs which causes the @future method not to execute. Am I doing something wrong or is there another way to accomplish it?

Here is documentation I am referencing:

Error Handling Best Practices for Lightning and Apex:
https://developer.salesforce.com/blogs/2017/09/error-handling-best-practices-lightning-apex.html

An Introduction to Exception Handling:
https://developer.salesforce.com/page/An_Introduction_to_Exception_Handling
 
@auraEnabled
public static void getSomething(){
    
    try{
        //Do Something here 
        
    }catch(exception e){
        
        //@future - log error in custom object
        futureCreateErrorLog.createErrorRecord(e.getMessage());
        
        throw new AuraHandledException('Error message to display in component');
    }
    
}

User-added image
Using SalesForce to track client visits. I have two time fields (one for the time the client meeting began and one for the ending time). How would I write a formula to ensure the "out-time" is after the "in-time?" Any help is appreciated. Thanks!
<apex:page controller="task2" >
    <apex:form>
     <apex:pageBlock>
         <apex:pageBlockSection>
             <apex:dataTable value="{!s}" var="aa" >

          <apex:column value="{!aa}" />
                 
             </apex:dataTable> 
             
             <apex:pageBlockTable value="{!sdisplay}" var="vv">
                 <apex:column >
                     <apex:outputText value="{!vv}"/>  
<! when its {!vv} it shows                                                                            a0
                                                                                                                        b1

                                                                                                                         c2

but when ipu {!sdisplay} the out put is                            a0,b1,c3
                                                                                             a0,b1,c3
                                                                                             a0,b1,c3                                                          !>

                                                                                                                        
                 </apex:column>
             </apex:pageBlockTable>
             
         </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>

***************************************************************
public class task2 {
 public list<string> s{set;get;}
 public list<string> sdisplay{set;get;}  
 public integer i{set;get;}
    
    public task2(){
            s=new list<string>();
            sdisplay = new list<string>();
            s.add('a');
            s.add('b');
            s.add('c');
            i=0;
        for(string ss:s){
            
            sdisplay.add(ss+i);
            i++;                } 
    }

}

I've gotten through the first few challenges without any real issue.  I'm stuck on this one, however.  In frustration I've used 'text.escapeSingleQuotes' combined with space replacement and whitelisting for the first 2 methods and then casting for the third since it's a Number.  I fail to see how this isn't enough to prevent SOQL injection, specifically because of the white listing.  I've tested against the whitelisting and it seems to be working correctly.  

I just wonder if this is a case of the challenge looking for a particular answer or I'm just missing something.

 


    public PageReference stringSearchOne(){
        string query = 'SELECT Id,Name,Quantity__c,Storage_Location__c,Storage_Location__r.Castle__c,Type__c FROM Supply__c';
        string whereClause = '';

        if(textOne != null && textOne!=''){
                whereClause += 'name like \'%'+string.escapeSingleQuotes(textOne.replaceAll('[^\\w]', ''))+'%\'';
                // textOne.replaceAll('[^\\w]', '')
        }
        Set<String> n = new Set<String>{'Barley','Beans','Bread','Cheese','Eels','Figs','Herrings','Horses','Malt','Oats','Raisins','Rice','Salt Beef','Salt Pork','Venison','Water','Wine'};
        if(whereClause != ''){
            if(n.contains(textOne)) {
                whereclause_records = database.query(query+' where '+whereClause+' Limit 10');        
            } else {
                whereclause_records = database.query(query+' where name = \'Venison\' Limit 10');
            }
        }

        return null;
    }


    public PageReference stringSearchTwo(){
        string query = 'SELECT Id,Name,Quantity__c,Storage_Location__c,Storage_Location__r.Castle__c,Type__c FROM Supply__c';
        string whereClause = '';

        if(textTwo != null && textTwo!=''){
                whereClause += 'Storage_Location__r.name like  \'%'+string.escapeSingleQuotes(textTwo.replaceAll('[^\\w]', ''))+'%\' ';
        }

        if(whereClause != ''){
            if(textTwo == 'Storeroom' || textTwo == 'Stables') {
                whereclause_records = database.query(query+' where '+whereClause+' Limit 10');
            }
        }

        return null;
    }


    public PageReference numberSearchOne(){
        string query = 'SELECT Id,Name,Quantity__c,Storage_Location__c,Storage_Location__r.Castle__c,Type__c FROM Supply__c';
        string whereClause = '';

        if(numberOne != null && comparator != null){
            whereClause += 'Quantity__c '+comparator+' '+string.valueOf(numberOne)+' ';
        }

        if(whereClause != ''){
            whereclause_records = database.query(query+' where '+whereClause+' Limit 10');
        }

        return null;
    }