How to Access Elements in Form's Embedded List with JavaScript?

lmcmanamon
Giga Contributor

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:

Rep Support Form.PNG

Client Script:

Client Script.PNG

11 REPLIES 11

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


-Anurag

you can add the datatype conversion there itself



parseInt(current.include_overfunds) + parseInt(current.insurance)


-Anurag

How do I access the calculation block?


On the dictionary entry, as soon as you click on the 'calculated' checkbox, 'calculation' box will appear


-Anurag

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;