In UI page code doesn't work different instance environments

Anish9515
Tera Contributor

UI Page code works on my PDI, but doesn't work in my company instance and I don't receive expected output. Can anyone help me?

@Amit Gujarathi @Ankur Bawiskar

9 REPLIES 9

Danish Bhairag2
Tera Sage
Tera Sage

Hi @Anish9515 ,

 

Can u share the code? Without looking at it bit difficult to comment.

 

Thanks,

Danish

 

function onSubmit() {
    var startDateInput = document.getElementById("date");
    var endDateInput = document.getElementById("date1");
    var errorElement = document.getElementById("error-message");

    var startDateStr = startDateInput.value;
    alert("The startdate is " +startDateStr);
    if (startDateStr === '') {
        errorElement.textContent = "Please select the planned start date";
        errorElement.style.display = "block";
        return false;
    }

    var endDateStr = endDateInput.value;
    alert ("The endate is " +endDateStr);
    if (endDateStr === '') {
        errorElement.textContent = "Please select the planned end date";
        errorElement.style.display = "block";
        return false;
    }

    var comments = document.getElementById("info").value.trim();
    if (comments === "") {
        errorElement.textContent = "Reason to set the date in the past";
        errorElement.style.display = "block";
        return false;
    }

    // Assuming g_user_date_format includes both date and time
    var currentDateUsr = formatDate(new Date(),g_user_date_time_format);

    alert ("The current date is " +currentDateUsr);

   
    if(startDateStr >currentDateUsr ){
        errorElement.textContent = "The Planned start date can not be in future";
        errorElement.style.display = "block";
        return false;
    }
    if(endDateStr < startDateStr){
        errorElement.textContent = "Planned end date must be after planned start date";
        errorElement.style.display = "block";
        return false;
    }
    return true;
}
@Danish Bhairag2  could please check once 
These  two conditions doesn't work as expected
1. if(startDateStr >currentDateUsr )
2. if(endDateStr < startDateStr)

Hi @Anish9515 ,

 

This is an onSubmit Client script. Plus what are you trying to achieve? As in what is the thing that you trying to check. By looking at the code what I understand is u want to check when the form is submitted whether the planned start n planned end date is filled or not plus if they have selected any past date 

 

Is my understanding correct?

 

Thanks,

Danish

 

@Anish9515 ,

 

If that's the case then I think most of ur checks can be achieved by using UI policy itself u don't need to code for it.

 

Thanks,

Danish