- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2023 05:47 AM
Hi All,
I have a requirement to calculate the Liability Violation Hours where Liability Violation Hours = Violation hours * Multiplier.
I have written a onChange Client script for above cal.
Everything is working fine except i cannot make the Liability Violation Hours(decimal type field) field as empty when the violation hours as empty.
Please help to correct my code
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var vh = g_form.getValue("violation_hour");
var mul = g_form.getValue("multi");
var lvh;
if((mul!='' && vh != 0)){
lvh= vh*mul;
g_form.setValue("liability_violation_hours", lvh);
}
else if((mul==''|| mul!='')&& vh===0){
var ll=vh*mul*0;
g_form.setValue("liability_violation_hours", ll);
}
else if((mul==''|| mul!='')&& vh===''){
g_form.setValue("liability_violation_hours", '');
}
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2023 05:43 AM
Hi @ST9
You can try the replace method below.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading) {
return;
}
if (newValue === '') {
g_form.clearValue("liability_violation_hours");
return;
}
var violationHours = g_form.getIntValue('violation_hour') * g_form.getIntValue('multi');
g_form.setValue("liability_violation_hours", violationHours.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
}
Cheers,
Tai Vu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2023 08:22 AM
This can be controlled using Attributes on the field. You need to create a format attribute and set it to none as shown below. Open the fields dictionary entry and click on the Attributes Related list and add it there.
Please Accept the solution if it works for you