I have question pertaining to calculating tax formula in ITSM/CMDB
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2024 03:20 AM
Hi Everyone,
I have one requirement:
I have 3 fields: 1) Cost , 2) Tax and 3) Total Cost
1. Whenever I enter a number in the cost field, it should automatically update in the Tax field after multiplying by 0.50.
The formula is (Cost x0.50) = Tax.
2. The Total Cost field should be updated with the addition of cost and tax values.
formula would be (Cost + Tax) = Total Cost
It should be noted that the formula must function while altering the cost value at the form level.
Kindly suggest or help me what are the ways to achieve this requirement and please share related scripts
Regards,
Vishnu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2024 07:43 PM
Hello @Vishnu533
Please check if the currency symbol is set correctly(eg £,$,€,¥). Also please check if the field names are set correctly. These could be the possible reasons for the data not getting populated.
"If you found my answer helpful, please give it a like and mark it as the accepted solution. It helps others find the solution more easily and supports the community!"
Thank you
Juhi Poddar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2024 09:52 AM
Hi @Juhi Poddar ,
Everything looks good, please see the attached script screenshot.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2024 12:07 AM
Hello @Vishnu533
In this case please try to debug the script by adding info messages or alert.
Here is the updated onchange client script:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//set the tax and total cost value
var price = parseFloat(newValue.replace(/[^\d.-]/g , ''));//eliminating currency symbol and converting string to number
alert("Price: " + price + " & Tax : " + price*0.5 + " & Total cost : " + price*1.5 );
g_form.setValue('u_taxx', price*0.5);
g_form.setValue('u_total_cost', price*1.5);
}
If incase the price value doesn't populate, Please create a new onchange client script with cost as a field name. This is working well in my PDI.
The preview of alert:
"If you found my answer helpful, please give it a like and mark it as the accepted solution. It helps others find the solution more easily and supports the community!"
Thank You
Juhi Poddar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2024 07:08 AM
Hi Eshwar,
Yes, I tried onChange Client script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-15-2024 07:22 AM
@Vishnu533
Could you please share the code snippet?