How to Access Elements in Form's Embedded List with JavaScript?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-22-2015 07:43 AM
Hello All!
I'm new to using ServiceNow and trying to brush up on my JavaScript. I'm encountering a small issue with not knowing how to access certain elements on my form. Basically, as you can see from the screencap, I have a variety of fields that are of data type "Decimal" in my Product Table Embedded List. I'd like to have it so that the summation of all those fields is put into the "Total Dealer Cost" field. Below is a screencap of both my form and my current Client Script for just when the Admin field is edited. For the script, it alerts that onCellEdit has been entered and that findTotalDealerCost has been entered, so fails when I try to access the Admin field. Could someone point me in the right direction?
Rep Support Form:
Client Script:
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-22-2015 09:03 AM
in the calculation block of the total dealer cost you will need to write something like this
current.include_overfunds + current.insurance
be careful with the types
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-22-2015 09:04 AM
you can add the datatype conversion there itself
parseInt(current.include_overfunds) + parseInt(current.insurance)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-23-2015 06:56 AM
How do I access the calculation block?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-29-2015 02:47 AM
On the dictionary entry, as soon as you click on the 'calculated' checkbox, 'calculation' box will appear
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-30-2015 11:06 AM
So, in the calculation block I have the following, but nothing occurs:
var admin = current.admin;
var insurance = current.insurance;
var reserves = current.reserves;
var overfunds = current.overfunds;
var thirdPartyFees = current.thirdPartyFees;
var associationFee = current.associationFee;
var fakePack = current.fakePack;
var other = current.other;
var totalDealerCost = admin + insurance + reserves + overfunds + thirdPartyFees + associationFee + fakePack + other;
current.total_dealer_cost = totalDealerCost;