g_form.setValue() is not Working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-05-2023 06:41 AM
I am trying to run a simple script but it is not working as it is not setting the values in the field.
SCRIPT=>
function onSubmit() {
//Type appropriate comment here, and begin script below
var checkIn = g_form.getValue('check_in_date_and_time');
var checkOut = g_form.getValue('check_out_date_and_time');
var isGovernmentEmployee = g_form.getValue('government_employee');
var roomPrice = 0;
var discount = 0, tax = 0;
var roomType = g_form.getValue('room_type');
var isGuestIdTypeGovernmentId = g_form.getValue('guest_id_type') == 'Government Employee Id';
if(checkOut < checkIn) {
g_form.addErrorMessage("Please enter correct check out date and time");
return false;
}
if(!(isGovernmentEmployee && isGuestIdTypeGovernmentId)) {
g_form.addErrorMessage("Please enter Government Employee Id");
return false;
}
if (roomType == 'Single Room') {
roomPrice = 2000;
}
if(roomType == 'Duplex Room'){
roomPrice = 3000;
}
if(roomType == 'Suite'){
roomPrice = 5000;
}
if(roomType == 'Presidential Suite'){
roomPrice = 8000;
}
discount = (roomPrice * 30) / 100;
if(isGovernmentEmployee){
g_form.setValue('discount', discount);
}
g_form.setValue('room_charge', roomPrice);
tax = (roomPrice*18)/100;
g_form.setValue('tax', tax);
return true;
}
All the setValue() functions are not working but we are getting the correct values and other condition is working properly as i print the values of roomType and roomPrice variables and they are correct
----------------------------------------------------------------------
-------------------------------------------------------------------------
--------------------------------------------------------
But it is not working
I want to set totalCharge, discount and tax
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-06-2023 08:31 PM
Hello @anuragsingh1 Please check the field type and backend names of the field you are trying to set the value.