• grandak koy
  • NEWBIE
  • 20 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 9
    Questions
  • 15
    Replies

How can I check and see when a record’s created date is created today but has to be created before 5pm Today PST?

Ex. Check and see if the package that came in today was created before 5pm PST.

If so, mark the package's status "ready"
public static void checkDestination(Map<Id, order__c> newOrders, Map<Id, order__c> oldOrders){
        for(Id id : newOrders.keyset()){
            if(newOrders.get(id).Destination__c != oldOrders.get(id).Destination__c && newOrders.get(id).Destination__r.Name.contains(‘OverSeas’)){
                newOrders.get(id).Received__c =True;
            }
        }
    }
Simple class but when I use contains() in my lookup reference: destination__r.Name, it throws an error:
Unable to de-reference a null object

How can I write my class that if my destination lookup has the word “overseas” in it, it will set my orders received field to be true?
 
If I did:
Date fiveDays =date.today().Add days(-5)
Order_received_date__c ==five days
Would that bring back a date result or a date/time results since order_received_date__c is a date/time field?
If i wanted to convert the order received date to bring back a date results should i:
Date order = order_received_date__c.date();
Then do this:
Order==five days
To see if my order_received_date__c was five days ago?
I have a trigger to send an email if an order was five days ago but its not shooting out when the order received date was five days ago from today. Does the date time have to be converted to date to work?
Is it possible to combine all three states: Edit, New, and Detail page into one Visualforce Page?

I have combined the Edit/New page but can't seem to get the detail page to work nicely.

The detail page uses the standard controller while the edit/new page does not.
How can I set off a field update when a date's month changes to the previous month?

Ex. if the date is 5/1/2018, and it changes to 4/2018, i need a field to update. I currently have this:

AND(
ISCHANGED(Date__c),
date__c < (PRIORVALUE(date__c) - 30)
)
I need to remove spaces after i assign my variable:

 TeamName = FirstName + '.' + LastName + '-TeamMember';

How can I remove spaces when there is a space in the last name or first name: ex. First name: Jon James, Last name: robinson it shows up like this: Jon James.RobinsonTeamMember I want it to look like: JonJames.RobinsonTeamMember

 
 need to be able to calculate the “Due Date” of a record when a certain picklist is chosen.
I have a parent object: Shipment, the child object Orders, and the child object of orders  “packages"
If the parent object “Shipment” has a picklist chosen of “Urgent” or “Shipped”I need to set the  Due date  to Tuesday based off of the created date being on a Monday.
So if the created date is on a Tuesday, then the due date will be Thursday. The due date will be on a PACKAGE object if the package is of type “8x”
If it is of type “5x” the due date will be that following Monday, so if the created date was tues, set due date for that following Monday for packages of “5x”

How can I write an apex class for this? I can’t do it in a formula because I have exceed the character limit.
How do I write a test class for this query?

Part of my class:
public with sharing class AccountController {
    private Account account;
    private list<Requests__c> req;
    public id accountId {get;set;}
    public List<Account> act {get;set;}

    public AccountController(ApexPages.StandardController stdController) {
        this.account=(Account)stdController.getRecord();
    }
     public AccountController(){
    }

    public List<Requests__c> getOrder(){
        req = RequestQueries.RetrieveRequestsForAccount(account.id);
        return req;
    }
}

My test class so far:
  static testMethod void testMethodForAccount()
    {

         Account act = new Account();
         insert act;
         Request__c req = new Request__c();
         req.Account__c = act.id;
         insert req;

        Test.startTest();
   
  
 PageReference pageRef = Page.AccountsHomePage; 
        pageRef.getParameters().put('id', String.valueOf(act.id));
        Test.setCurrentPage(pageRef);

        ApexPages.currentPage().getParameters().put('id','act.id');

        ApexPages.StandardController sc = new ApexPages.standardController(acc1);

        AccountController a = new AccountController(sc);

         AccountController Anull = new AccountController(new ApexPages.StandardController(act));
       

   Test.stopTest();   

        }
       

    }
I have an apex class that creates a child record when a field on the parent record changes: 
public with sharing class newTable {


  public static void newTable(
  Map < Id, Team__c > oldTeam,  List<Team__c> Team) {
  list<table__c>  P = new list<table__c> ();
   for(team__c team :teams)  {
  if ((team.filled__c = TRUE ||
  team.Sent__c == 'Confirmed') && .
 (oldTeam.get(team.id).filled__c = False ||
  oldTeam.get(team.id).Sent__c != 'Confirmed')) {
  T.add(new table__c(team__c = team.id, com__c = TRUE));
 insert T;
    }
   }
 }
 }
It inserts a record but shouldn't I be using newMap instead of New? Since I just want to review that the parent record changes (compare the old to the new) instead of comparing a list of records? What would be the correct way to write an apex class to insert a child record when a field on the parent changes that doesn't match the previous and fits filled__c ="True"?

I have created this class to be called from my triggerhandler, so I would prefer not to write a trigger for it.


 

How can I check and see when a record’s created date is created today but has to be created before 5pm Today PST?

Ex. Check and see if the package that came in today was created before 5pm PST.

If so, mark the package's status "ready"
If I did:
Date fiveDays =date.today().Add days(-5)
Order_received_date__c ==five days
Would that bring back a date result or a date/time results since order_received_date__c is a date/time field?
If i wanted to convert the order received date to bring back a date results should i:
Date order = order_received_date__c.date();
Then do this:
Order==five days
To see if my order_received_date__c was five days ago?
I have a trigger to send an email if an order was five days ago but its not shooting out when the order received date was five days ago from today. Does the date time have to be converted to date to work?
How can I set off a field update when a date's month changes to the previous month?

Ex. if the date is 5/1/2018, and it changes to 4/2018, i need a field to update. I currently have this:

AND(
ISCHANGED(Date__c),
date__c < (PRIORVALUE(date__c) - 30)
)
I need to remove spaces after i assign my variable:

 TeamName = FirstName + '.' + LastName + '-TeamMember';

How can I remove spaces when there is a space in the last name or first name: ex. First name: Jon James, Last name: robinson it shows up like this: Jon James.RobinsonTeamMember I want it to look like: JonJames.RobinsonTeamMember

 
 need to be able to calculate the “Due Date” of a record when a certain picklist is chosen.
I have a parent object: Shipment, the child object Orders, and the child object of orders  “packages"
If the parent object “Shipment” has a picklist chosen of “Urgent” or “Shipped”I need to set the  Due date  to Tuesday based off of the created date being on a Monday.
So if the created date is on a Tuesday, then the due date will be Thursday. The due date will be on a PACKAGE object if the package is of type “8x”
If it is of type “5x” the due date will be that following Monday, so if the created date was tues, set due date for that following Monday for packages of “5x”

How can I write an apex class for this? I can’t do it in a formula because I have exceed the character limit.
How do I write a test class for this query?

Part of my class:
public with sharing class AccountController {
    private Account account;
    private list<Requests__c> req;
    public id accountId {get;set;}
    public List<Account> act {get;set;}

    public AccountController(ApexPages.StandardController stdController) {
        this.account=(Account)stdController.getRecord();
    }
     public AccountController(){
    }

    public List<Requests__c> getOrder(){
        req = RequestQueries.RetrieveRequestsForAccount(account.id);
        return req;
    }
}

My test class so far:
  static testMethod void testMethodForAccount()
    {

         Account act = new Account();
         insert act;
         Request__c req = new Request__c();
         req.Account__c = act.id;
         insert req;

        Test.startTest();
   
  
 PageReference pageRef = Page.AccountsHomePage; 
        pageRef.getParameters().put('id', String.valueOf(act.id));
        Test.setCurrentPage(pageRef);

        ApexPages.currentPage().getParameters().put('id','act.id');

        ApexPages.StandardController sc = new ApexPages.standardController(acc1);

        AccountController a = new AccountController(sc);

         AccountController Anull = new AccountController(new ApexPages.StandardController(act));
       

   Test.stopTest();   

        }
       

    }
I have an apex class that creates a child record when a field on the parent record changes: 
public with sharing class newTable {


  public static void newTable(
  Map < Id, Team__c > oldTeam,  List<Team__c> Team) {
  list<table__c>  P = new list<table__c> ();
   for(team__c team :teams)  {
  if ((team.filled__c = TRUE ||
  team.Sent__c == 'Confirmed') && .
 (oldTeam.get(team.id).filled__c = False ||
  oldTeam.get(team.id).Sent__c != 'Confirmed')) {
  T.add(new table__c(team__c = team.id, com__c = TRUE));
 insert T;
    }
   }
 }
 }
It inserts a record but shouldn't I be using newMap instead of New? Since I just want to review that the parent record changes (compare the old to the new) instead of comparing a list of records? What would be the correct way to write an apex class to insert a child record when a field on the parent changes that doesn't match the previous and fits filled__c ="True"?

I have created this class to be called from my triggerhandler, so I would prefer not to write a trigger for it.