• Mayuri Nehul
  • NEWBIE
  • 15 Points
  • Member since 2020

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

Hi All,
I have used a formula for calculating no. of working days excluding weekends that is working fine but actually, I want to add half-day logic in it like when both dates are the same then show options for half-day and full-day. I am not able to add half-day logic in the formula so I have used one checkbox field, created one process when both dates are the same then the checkbox value should be true, and added that logic in Apex trigger where I have handles my overall logic. Actually, I want to handle this all logic in LWC because I need to check for a full day as well if both dates are the same for that I have used the radio button. Can anyone please help me to resolve this 
my formula:
(IF(AND((5 - (CASE(MOD( fromDate__c- DATE(1900, 1, 6), 7), 0, 0, 1, 5, 2, 5, 3, 4, 4, 3, 5, 2, 6, 1, 0)) < (CASE(MOD( toDate__c - DATE(1900, 1, 6), 7), 0, 0, 1, 0, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 0)) ),
((( toDate__c - fromDate__c) + 1) < 7)),
((CASE(MOD( toDate__c - DATE(1900, 1, 6), 7), 0, 0, 1, 0, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 0)) - (5 - (CASE(MOD( fromDate__c - DATE(1900, 1, 6), 7), 0, 0, 1, 5, 2, 5, 3, 4, 4, 3, 5, 2, 6, 1, 0)))),
(((FLOOR((( toDate__c - fromDate__c ) - (CASE(MOD( fromDate__c - DATE(1900, 1, 6), 7), 0, 0, 1, 6, 2, 5, 3, 4, 4, 3, 5, 2, 6, 1, 0))) / 7)) * 5) +
(CASE(MOD( fromDate__c - DATE(1900, 1, 6), 7), 0, 0, 1, 5, 2, 5, 3, 4, 4, 3, 5, 2, 6, 1, 0)) +
(CASE(MOD( toDate__c - DATE(1900, 1, 6), 7), 0, 0, 1, 0, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 0)))))

--lwc.js
import { LightningElement,api,track,wire } from 'lwc';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import { NavigationMixin } from 'lightning/navigation';
import Id from '@salesforce/user/Id';

export default class CreateRbtn extends NavigationMixin(LightningElement) 
{
    userId = Id;
    @track Leave_Request__c;
    @track cardTitle;
    Date1;
    Date2;
    rbValue = '';  //radio button value
    
    _wiredResult;
    handleSuccess(event) {
        console.log('onsuccess event recordEditForm',event.detail.id)
    }
    handleSubmit(event){
        var isVal = true;
        this.template.querySelectorAll('lightning-input-field').forEach(element => {
            isVal = isVal && element.reportValidity();
        });
        if (isVal) {
            this.template.querySelectorAll('lightning-record-edit-form').forEach(element => {element.submit();  });
            this.dispatchEvent(
            new ShowToastEvent({
                title: 'Success',
                message: 'Leave record successfully created',
                variant: 'success',
                }),
            );
            // Navigate to the Leave request list view
    
        this[NavigationMixin.Navigate]({
            type: 'standard__objectPage',
            attributes: {
                objectApiName: 'Leave_Request__c',
                actionName: 'list'
            },
            state: {
                
                filterName: 'Recent' 
            }
        });
        
    }
    
    
        
        else {
            this.dispatchEvent(
            new ShowToastEvent({
                title: 'Error creating record',
                message: 'Please enter all the required fields',
                variant: 'error',
                }),
            );
        }
    }
    
    showRadioBtn = false;
    
    get options() {
        return [
            { label: 'Half day', value: '0.5' },
            { label: 'Full day', value: '1' },
        ];
    }
    
    handleChange(event){
        if(event.target.dataset.id === 'Date1'){
        this.Date1 = event.target.value;
        }else if(event.target.dataset.id === 'Date2'){
        this.Date2 = event.target.value;
        }
        
        if(this.Date1 == this.Date2){
            this.showRadioBtn = true;
          }else{
            this.showRadioBtn = false;
          }
      
    //added custom validation on 27/06/21     
       if(this.Date1>this.Date2)    
       {
           alert('To date should not be less than from date');
        }  
    
    }
    handleRbtn(event){
        this.rbValue = event.target.value;
        // alert(this.rbValue);
        
    }
}

Thanks in advance

Mayuri

Hi All,

I want to add custom validation on the date when From date is greater than to date then show an alert message before creating a record. I have tried the validation rule but it is not displaying any error.
Can anyone please help me with how to achieve it.

Thanks in advance
Hi All
I am working on creating Leave Management Application.

I want to add 2 types of leaves like half-day and full-day excluding weekends.

I am able to figure out the formula for Full day leave but I am not able to understand how can I achieve half day leave requirement.

For that, I have used 2 fields from_date__c and to_date__c which is of date data type.

Do I need to change it to DateTime? Please help me to achieve this requirement.


Your help will be appreciated.

Thanks in advance
 
Hi all, I have created dynamic action on my custom page but it is not working as per expectation. 
I have the requirement to hide submit for approval button when the status is approved or rejected so I have created dynamic action for it by providing the following conditions:
User-added image
Whatever criteria I am providing only working for the System Administrator profile but not working for other user profiles.

I am not able to understand what step I am missing in it. Can anyone please help me to resolve this issue.

Thanks in advance

Hi All,

I am new to Salesforce. I am having one requirement where there are 2 date fields if the values of these date fields are the same then show the radio button using LWC.
For eg: if date1 field value = 19/04/2021 and date2 field value = 19/04/2021 then show radio button.

Can anyone please help me with how to achieve it?

Thanks in advance.

 

Hi All,

I am new to Salesforce.
I have a requirement to create more than the approver needs to approve one record but I don't have any entry criteria for it. I want to submit all records for approval on the initial stage only.

Can anyone please help me how can I achieve this by using the Approval process.


Thanks in advance

 
Hi All,

I am new to Salesforce. I have given a task to build a Leave Management System application declaratively. I have created 2 formula fields Number of days leave taken and total leaves per year
I want to change the total leaves per year field value when approval approves it not before that. I have tried the below formula but I am getting the below error.
Can anyone please help me to resolve it.

For e.g: Employee applied for 2 days leave excluding weekends then the Number of days leave taken field is updated to 2 and the total leaves per year field will update 26-2=24 but I don't want to change the total leaves per year field to change before approval.
I want it 26 as it is. After approval from the approver, it should change to 24. Please help me to resolve this issue

The formula which I have tried is given below:

IF(ISPICKVAL( Status__c ='Approved'), 26-  no_days__c ,  totalLeavesPerYr__c )

Error:Formula cannot use another formula field that directly or indirectly refers to itself. Leave_Request__c.totalLeavesPerYr__c -> Leave_Request__c.totalLeavesPerYr__c

Thanks in advance
Hi All,
I am new to Salesforce. I have given a task to build a Leave Management System application.
I am working on a number of days excluding the weekend formula field.
As per my requirement, I have used two date fields from_date and to_date for calculating the number of days leave taken by Employee.
I am using the below formulae but not getting the correct result for the same.
for e.g, if Employee applied for leave on 12/11/20  to 19/11/20 then it should give 6 as output but getting 5.

Can anyone please help me to resolve this issue.

CASE(MOD(  (From_Date__c)  - DATE(2020,01,01),7), 
  0 , CASE( MOD( to_Date__c  - From_Date__c,7),1,2,2,3,3,4,4,5,5,5,6,5,1), 
  1 , CASE( MOD( to_Date__c - From_Date__c,7),1,2,2,3,3,4,4,4,5,4,6,5,1), 
  2 , CASE( MOD( to_Date__c- From_Date__c,7),1,2,2,3,3,3,4,3,5,4,6,5,1), 
  3 , CASE( MOD( to_Date__c - From_Date__c,7),1,2,2,2,3,2,4,3,5,4,6,5,1), 
  4 , CASE( MOD( to_Date__c - From_Date__c,7),1,1,2,1,3,2,4,3,5,4,6,5,1), 
  5 , CASE( MOD( to_Date__c - From_Date__c,7),1,0,2,1,3,2,4,3,5,4,6,5,0), 
  6 , CASE( MOD( to_Date__c - From_Date__c,7),1,1,2,2,3,3,4,4,5,5,6,5,0), 
  999) 
  + 
  (FLOOR(((to_Date__c - From_Date__c)/7)*5)

Thanks in advance
Hi Team,
I am new to Salesforce. I have a task to create an app using LWC(Everything needs to create using coding and LWC). I have created fields using LWC but haven't created any object. Can anyone please help with it how to create objects using LWC.
I need to create a controller for the same but I don't have any object reference for it. Your help would be appreciated
Thanks in advance.
Hi All,

I want to add custom validation on the date when From date is greater than to date then show an alert message before creating a record. I have tried the validation rule but it is not displaying any error.
Can anyone please help me with how to achieve it.

Thanks in advance
Hi all, I have created dynamic action on my custom page but it is not working as per expectation. 
I have the requirement to hide submit for approval button when the status is approved or rejected so I have created dynamic action for it by providing the following conditions:
User-added image
Whatever criteria I am providing only working for the System Administrator profile but not working for other user profiles.

I am not able to understand what step I am missing in it. Can anyone please help me to resolve this issue.

Thanks in advance

Hi All,

I am new to Salesforce. I am having one requirement where there are 2 date fields if the values of these date fields are the same then show the radio button using LWC.
For eg: if date1 field value = 19/04/2021 and date2 field value = 19/04/2021 then show radio button.

Can anyone please help me with how to achieve it?

Thanks in advance.

 

Hi All,

I am new to Salesforce.
I have a requirement to create more than the approver needs to approve one record but I don't have any entry criteria for it. I want to submit all records for approval on the initial stage only.

Can anyone please help me how can I achieve this by using the Approval process.


Thanks in advance

 
Hi All,

I am new to Salesforce. I have given a task to build a Leave Management System application declaratively. I have created 2 formula fields Number of days leave taken and total leaves per year
I want to change the total leaves per year field value when approval approves it not before that. I have tried the below formula but I am getting the below error.
Can anyone please help me to resolve it.

For e.g: Employee applied for 2 days leave excluding weekends then the Number of days leave taken field is updated to 2 and the total leaves per year field will update 26-2=24 but I don't want to change the total leaves per year field to change before approval.
I want it 26 as it is. After approval from the approver, it should change to 24. Please help me to resolve this issue

The formula which I have tried is given below:

IF(ISPICKVAL( Status__c ='Approved'), 26-  no_days__c ,  totalLeavesPerYr__c )

Error:Formula cannot use another formula field that directly or indirectly refers to itself. Leave_Request__c.totalLeavesPerYr__c -> Leave_Request__c.totalLeavesPerYr__c

Thanks in advance
Hi All,
I am new to Salesforce. I have given a task to build a Leave Management System application.
I am working on a number of days excluding the weekend formula field.
As per my requirement, I have used two date fields from_date and to_date for calculating the number of days leave taken by Employee.
I am using the below formulae but not getting the correct result for the same.
for e.g, if Employee applied for leave on 12/11/20  to 19/11/20 then it should give 6 as output but getting 5.

Can anyone please help me to resolve this issue.

CASE(MOD(  (From_Date__c)  - DATE(2020,01,01),7), 
  0 , CASE( MOD( to_Date__c  - From_Date__c,7),1,2,2,3,3,4,4,5,5,5,6,5,1), 
  1 , CASE( MOD( to_Date__c - From_Date__c,7),1,2,2,3,3,4,4,4,5,4,6,5,1), 
  2 , CASE( MOD( to_Date__c- From_Date__c,7),1,2,2,3,3,3,4,3,5,4,6,5,1), 
  3 , CASE( MOD( to_Date__c - From_Date__c,7),1,2,2,2,3,2,4,3,5,4,6,5,1), 
  4 , CASE( MOD( to_Date__c - From_Date__c,7),1,1,2,1,3,2,4,3,5,4,6,5,1), 
  5 , CASE( MOD( to_Date__c - From_Date__c,7),1,0,2,1,3,2,4,3,5,4,6,5,0), 
  6 , CASE( MOD( to_Date__c - From_Date__c,7),1,1,2,2,3,3,4,4,5,5,6,5,0), 
  999) 
  + 
  (FLOOR(((to_Date__c - From_Date__c)/7)*5)

Thanks in advance
Hi Team,
I am new to Salesforce. I have a task to create an app using LWC(Everything needs to create using coding and LWC). I have created fields using LWC but haven't created any object. Can anyone please help with it how to create objects using LWC.
I need to create a controller for the same but I don't have any object reference for it. Your help would be appreciated
Thanks in advance.
The following formula will calculate the number of working days (inclusive) between 2 dates. A working day is defined as Monday to Friday. Even if the start or end dates are a weekend, these are accommodated.

IF(AND((5 - (CASE(MOD( Start_Date__c - DATE(1900, 1, 6), 7), 0, 0, 1, 5, 2, 5, 3, 4, 4, 3, 5, 2, 6, 1, 0)) < (CASE(MOD(  End_Date__c  - DATE(1900, 1, 6), 7), 0, 0, 1, 0, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 0)) ),
((( End_Date__c  -   Start_Date__c ) + 1) < 7)),
((CASE(MOD(  End_Date__c  - DATE(1900, 1, 6), 7), 0, 0, 1, 0, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 0)) - (5 - (CASE(MOD(  Start_Date__c  - DATE(1900, 1, 6), 7), 0, 0, 1, 5, 2, 5, 3, 4, 4, 3, 5, 2, 6, 1, 0)))),
(((FLOOR((( End_Date__c  -  Start_Date__c ) - (CASE(MOD(  Start_Date__c  - DATE(1900, 1, 6), 7), 0, 0, 1, 6, 2, 5, 3, 4, 4, 3, 5, 2, 6, 1, 0))) / 7)) * 5) +
(CASE(MOD(  Start_Date__c  - DATE(1900, 1, 6), 7), 0, 0, 1, 5, 2, 5, 3, 4, 4, 3, 5, 2, 6, 1, 0)) +
(CASE(MOD(  End_Date__c  - DATE(1900, 1, 6), 7), 0, 0, 1, 0, 2, 1, 3, 2, 4, 3, 5, 4, 6, 5, 0))))


The Start Date and End Date fields are custom in the above example and can be replaced as required. If use of a DateTime field is required then the DATEVALUE function will be required.

I also recommend a simple field validation rule is added to check that the End Date is after the Start Date.
  • January 05, 2009
  • Like
  • 9