Page 1 of 1
Reload Calculated Field
Posted: 10 Jan 2019
by Mapleleaf
Hello!
I have a form with field x and field y. Third field is a calculated sharepoint-field z which is (x+y).
Is it possible to refresh value of z after x or y has changed?
Re: Reload Calculated Field
Posted: 10 Jan 2019
by AlexZver
Hi!
This is only possible with JavaScript. You need to subscribe to change events on these fields and run a calculation function when the value changes. More on this for various fields here -
https://spform.com/javascript-framework ... eld-values
You can change the value of the calculated field by using jQuery:
1) Add a CSS class to the field in Forms Designer, e.g. "calc_field"
- Screenshot_128.png (2.96 KiB) Viewed 2551 times
2) Add a code:
Code: Select all
$(".calc_field").find(".ms-formbody").html(newValue);
Where "newValue" is a recalculated value.
If you have any questions - let me know!
Re: Reload Calculated Field
Posted: 11 Jan 2019
by Mapleleaf
Works!
Thank you
Re: Reload Calculated Field
Posted: 27 Mar 2019
by crolle
Where should I write the code
Re: Reload Calculated Field
Posted: 28 Mar 2019
by Nikita Kurguzov
Dear crolle,
This code is executed from JS editor:
- JS editor.png (8.6 KiB) Viewed 2496 times
For example, you want to combine
Title and
Status field. It should look something like this:
Code: Select all
function updateCalcField(){
var newValue = fd.field('Title').value() + " " + fd.field('Status').value();
$(".calc_field").find(".ms-formbody").html(newValue);
}
fd.field('Title').change(function(){
updateCalcField();
});
fd.field('Status').change(function(){
updateCalcField();
});