• sg
  • NEWBIE
  • 10 Points
  • Member since 2022

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 7
    Replies
I have a custom button in a custom object and
on clicking the button,
It (Screen Flow) purchases reports from vendor portal based on information available in the record and creates another record in the related object.
Now, I have to display a text message( Reports already been purchased, Do you really want to continue?) to user when they try to click on this button even though there is a report which already has been purchased, Just to prevent unnecessary purchases.
But if they continue on purpose, it should be working as usual and purchase a report.
If that particular related object has more than 0 records, this popup should be displayed. Any ideas on how i can accommodate this in the existing flow? Any help or insights would be appreciated.
  • October 31, 2023
  • Like
  • 0
I have this batch class which included Busines hours check boolean method. I am having hard time including business hours check in test records and can't find a correct reference too. Can someone help me with a piece of code to include Business hours check logic in Test class? 

Below is the batch class
global class BatchCounter implements Database.Batchable<sObject>
{
static final String businessHoursId;
global Database.QueryLocator start(Database.BatchableContext bc)
{
String query = 'SELECT Id, numberField__c,statusField__c,Submitteddate__c FROM objectName__c WHERE Submitteddate__c !=null '+' AND statusField__c IN (\'Assigned\', \'Submitted\', \'InProgress\')'; return Database.getQueryLocator(query);
}
global void execute(Database.BatchableContext bc, List<TMA__c> tmas)
{
for (TMA__c tma : tmas)
{
if (isBusinessHours(businessHoursId))
{
tma.numberField__c+=1;
}
}
update tmas;
}
global void finish(Database.BatchableContext bc)
{ }
private static Boolean isBusinessHours(Id businessHoursId)
{
BusinessHours businessHours = [SELECT Id FROM BusinessHours WHERE Id = :businessHoursId];
if (businessHours != null)
{
Datetime currentDatetime = Datetime.now();
return BusinessHours.isWithin(businessHoursId, currentDatetime);
}
return false;
} }
  • May 16, 2023
  • Like
  • 0
Hi
I have a custom DATETIME field Submitted date__c in the custom object and it captures the date and time when the status is changed to Submitted. The issue here is I am seeing GMT-4 time (14:00 ) in UI and in the Developer console and apex logs, its showing GMT time (18:00). I have a number field which gets increased everday based on this submitted datetime if is its greater than 14:00 on the UI. Since I am seeing different times, I cannot come to a conclusion. Help needed.
  • April 18, 2023
  • Like
  • 0
This is the sample batch class that I am working on. This class is working fine but I need to add one more condition like, If status is set to submitted after 2PM TODAY, The number field should not be increased by Today Batch Job which runs everyday at 3PM, So that record should be increased in next day run. How to achieve that? Any help would be appreciated. TIA.

global class BatchCounter implements Database.Batchable<sObject> {
static final String businessHoursId;
global Database.QueryLocator start(Database.BatchableContext bc) {
String query = 'SELECT Id, numberField__c,statusField__c,Submitteddate__c FROM objectName__c WHERE Submitteddate__c !=null '+' AND statusField__c IN (\'Assigned\', \'Submitted\', \'InProgress\')'; return Database.getQueryLocator(query);
} global void execute(Database.BatchableContext bc, List<TMA__c> tmas)
{
for (TMA__c tma : tmas) {
if (isBusinessHours(businessHoursId))
{ tma.numberField__c+=1;
}}
update tmas;
}
global void finish(Database.BatchableContext bc) { }
private static Boolean isBusinessHours(Id businessHoursId) { BusinessHours businessHours = [SELECT Id FROM BusinessHours WHERE Id = :businessHoursId];
if (businessHours != null)
{ Datetime currentDatetime = Datetime.now();
return BusinessHours.isWithin(businessHoursId, currentDatetime);
}
return false;
} }
  • April 10, 2023
  • Like
  • 0
Hi,

I need to write a flow to calculate Working days between Service completed date and assigned date. Also, It should not calculate the days/stop calculation when  Service Status =Denied, Duplicated, Hold, Reassigned, Returned back, Waiting. It should resume counting after moving out of these Statuses to In Progress.  Please assist on this. Thanks in advance.
  • January 05, 2023
  • Like
  • 0
I have a custom button in a custom object and
on clicking the button,
It (Screen Flow) purchases reports from vendor portal based on information available in the record and creates another record in the related object.
Now, I have to display a text message( Reports already been purchased, Do you really want to continue?) to user when they try to click on this button even though there is a report which already has been purchased, Just to prevent unnecessary purchases.
But if they continue on purpose, it should be working as usual and purchase a report.
If that particular related object has more than 0 records, this popup should be displayed. Any ideas on how i can accommodate this in the existing flow? Any help or insights would be appreciated.
  • October 31, 2023
  • Like
  • 0
I have this batch class which included Busines hours check boolean method. I am having hard time including business hours check in test records and can't find a correct reference too. Can someone help me with a piece of code to include Business hours check logic in Test class? 

Below is the batch class
global class BatchCounter implements Database.Batchable<sObject>
{
static final String businessHoursId;
global Database.QueryLocator start(Database.BatchableContext bc)
{
String query = 'SELECT Id, numberField__c,statusField__c,Submitteddate__c FROM objectName__c WHERE Submitteddate__c !=null '+' AND statusField__c IN (\'Assigned\', \'Submitted\', \'InProgress\')'; return Database.getQueryLocator(query);
}
global void execute(Database.BatchableContext bc, List<TMA__c> tmas)
{
for (TMA__c tma : tmas)
{
if (isBusinessHours(businessHoursId))
{
tma.numberField__c+=1;
}
}
update tmas;
}
global void finish(Database.BatchableContext bc)
{ }
private static Boolean isBusinessHours(Id businessHoursId)
{
BusinessHours businessHours = [SELECT Id FROM BusinessHours WHERE Id = :businessHoursId];
if (businessHours != null)
{
Datetime currentDatetime = Datetime.now();
return BusinessHours.isWithin(businessHoursId, currentDatetime);
}
return false;
} }
  • May 16, 2023
  • Like
  • 0
Hi
I have a custom DATETIME field Submitted date__c in the custom object and it captures the date and time when the status is changed to Submitted. The issue here is I am seeing GMT-4 time (14:00 ) in UI and in the Developer console and apex logs, its showing GMT time (18:00). I have a number field which gets increased everday based on this submitted datetime if is its greater than 14:00 on the UI. Since I am seeing different times, I cannot come to a conclusion. Help needed.
  • April 18, 2023
  • Like
  • 0
This is the sample batch class that I am working on. This class is working fine but I need to add one more condition like, If status is set to submitted after 2PM TODAY, The number field should not be increased by Today Batch Job which runs everyday at 3PM, So that record should be increased in next day run. How to achieve that? Any help would be appreciated. TIA.

global class BatchCounter implements Database.Batchable<sObject> {
static final String businessHoursId;
global Database.QueryLocator start(Database.BatchableContext bc) {
String query = 'SELECT Id, numberField__c,statusField__c,Submitteddate__c FROM objectName__c WHERE Submitteddate__c !=null '+' AND statusField__c IN (\'Assigned\', \'Submitted\', \'InProgress\')'; return Database.getQueryLocator(query);
} global void execute(Database.BatchableContext bc, List<TMA__c> tmas)
{
for (TMA__c tma : tmas) {
if (isBusinessHours(businessHoursId))
{ tma.numberField__c+=1;
}}
update tmas;
}
global void finish(Database.BatchableContext bc) { }
private static Boolean isBusinessHours(Id businessHoursId) { BusinessHours businessHours = [SELECT Id FROM BusinessHours WHERE Id = :businessHoursId];
if (businessHours != null)
{ Datetime currentDatetime = Datetime.now();
return BusinessHours.isWithin(businessHoursId, currentDatetime);
}
return false;
} }
  • April 10, 2023
  • Like
  • 0
Hi,

I need to write a flow to calculate Working days between Service completed date and assigned date. Also, It should not calculate the days/stop calculation when  Service Status =Denied, Duplicated, Hold, Reassigned, Returned back, Waiting. It should resume counting after moving out of these Statuses to In Progress.  Please assist on this. Thanks in advance.
  • January 05, 2023
  • Like
  • 0