Avatar

Updating two or more app in real time

Muhaymin Rakim

Hi Everyone,

I want to make a Sales App and Inventory App, lets say I will edit the stock on my Inventory App and want I want is that the Sales App will also update because I sell my stock.

Thank you.

Follow 3 followers
0

4 comments

Avatar
William Sayama 0 votes

Hi Muhaymin

Could you share with us what you have tried so far?

The community can help you out with any issues you run into, but please do not expect the community to write up the whole customization for you.

If you haven't started coding yet, you can utilize the Record Edit Event, which will trigger whenever a record is edited.

Thanks!

0
Comment actions Permalink
Avatar
Muhaymin Rakim 1 vote

Hi William,

I tried to update the record of my TEST INVENTORY App through my TEST SALES App, I put the javascript on my TEST SALES app. I want to put 30 on the stocks field but nothing happen.

Please see below code:

(function() {
"use strict";


kintone.events.on('app.record.index.show', function (event) {

var records = event.records;
var wRecord = {};
var wRecords = [];

var signalDate = kintone.app.getFieldElements('日付');



for (var i = 0; i < records.length; i++) {
var record = records[i];
//
var edad = "30";
//

wRecord = {

"id":1,
"record":{
"stock":{
"value": edad
}
}
};
wRecords.push(wRecord);
}

var wParm = {
//"app":kintone.app.getId(),
"app":145,
"records":wRecords
};

 


kintone.api('/k/v1/records','PUT',wParm, function(res){

},

function(err){
console.log(err);
}
);

});
}());

1
Comment actions Permalink
Avatar
Yuzo Arai 0 votes

Hello Muhaymin!

I looked over your script, and it looks fine to me.
However can you confirm the following:

-Do the "日付" field really exist in the SALES app?
-Do the "日付" field shows up on the record view?
-Do the "edad" field really exist in the SALES app?
-Which app is the app ID 145? INVENTORY or SALES?
-According to what you wrote and where you applied the script(SALES app), it seems like you're updating other app(145), but is this correct?

0
Comment actions Permalink