Avatar

How to Sum text setting.

吉田

Dear dev team,

i have a 2 text setting and have a value below:

 *text setting1:  5

 *text setting2:  4

and i want SUM 2 field above.

please me.

 

Follow 2 followers
0

2 comments

Avatar
Yuzo Arai 2 votes

Hello Yoshida-san,

The following is an example code of when you want to add values in two text fields and input the sum of them into the third text field.

Field Code:
Text 1 = A
Text 2 = B
Text 3 = SUM

(function () {
"use strict";
kintone.events.on(['app.record.create.submit', 'app.record.edit.submit'], function (event){
var record = event.record;
var Text1 = Number(record['A'].value);
var Text2 = Number(record['B'].value);
var subTotal = Text1 + Text2;

record['SUM'].value = subTotal;

return event;
});})();

I think the key here is to add Number() on the text field value that you want to add,
so the value inside the text field will be treated as number.

I hope this helps.

2
Comment actions Permalink
Avatar
吉田 0 votes

thanks you, Because i think a char cannot Sum together. i need two create a code to check content, thanks you.

0
Comment actions Permalink