Crow Canyon Software Forum
Script action error
Quote from Jay on December 15, 2024, 8:08 pmI have a few calcs to make on a form.
Some sub totals and a grant total. Rather than using many on change events to do the job I thought I would put it all in a script action and have the user press the script action to generate the totals.
I started off with a single calculation to see if it would work but it is failing straight away.
I get an error in the browser saying: Cannot read properties of null (reading 'get_item')My script is
function(spContext, formContext, listColumnsInfo, currentItem, functionCallback) {var TotalHours = 0var HourlyRate = 0HourlyRate = currentItem.get_item("Child_x0020_Care_x0020_costs_x00");TotalHours = currentItem.get_item("Number_x0020_of_x0020_Child_x002")var sumChildCare = TotalHours + HourlyRateCurrentItem.set_item(TotalChildCareAmount, sumChildCare)}
I have a few calcs to make on a form.
Some sub totals and a grant total. Rather than using many on change events to do the job I thought I would put it all in a script action and have the user press the script action to generate the totals.
I started off with a single calculation to see if it would work but it is failing straight away.
I get an error in the browser saying: Cannot read properties of null (reading 'get_item')My script is
function(spContext, formContext, listColumnsInfo, currentItem, functionCallback) {var TotalHours = 0var HourlyRate = 0HourlyRate = currentItem.get_item("Child_x0020_Care_x0020_costs_x00");TotalHours = currentItem.get_item("Number_x0020_of_x0020_Child_x002")var sumChildCare = TotalHours + HourlyRateCurrentItem.set_item(TotalChildCareAmount, sumChildCare)}
Quote from supportTeam on December 31, 2024, 6:26 amThanks for sharing the script and requirement details above.
We believe you are using the script in the form event action. If so, please use below syntax to read the column value. Please refer sample article on this from https://www.crowcanyon.help/article/469/.
Read column value: var HourlyRate = _ccs_FormUI.fetchColumnValueUI("Child_x0020_Care_x0020_costs_x00");
To set the required value to the column, we can use return statement as shown below.
return sumChildCare;
Thanks for sharing the script and requirement details above.
We believe you are using the script in the form event action. If so, please use below syntax to read the column value. Please refer sample article on this from https://www.crowcanyon.help/article/469/.
Read column value: var HourlyRate = _ccs_FormUI.fetchColumnValueUI("Child_x0020_Care_x0020_costs_x00");
To set the required value to the column, we can use return statement as shown below.
return sumChildCare;