Skip to content

Commit e980c59

Browse files
authored
Create Server Side.js
1 parent 9d03e04 commit e980c59

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
(function() {
2+
data.messages = [];
3+
if(input){
4+
data.messages = input.messages;
5+
if (input.action == "addMessage") {
6+
data.messages.push(input.message);
7+
if(!input.message){
8+
gs.addInfoMessage("Please enter value in text area");
9+
return;
10+
}
11+
var rec = new GlideRecord('u_sticky_notes'); // 🔹 change this to your table
12+
rec.initialize();
13+
rec.u_short_description = input.message;
14+
rec.u_color = input.newColor;
15+
// rec.setValue('u_short_description', input.inputValue); // 🔹 change 'name' to your field
16+
rec.insert();
17+
18+
19+
}
20+
if (input.action == "removeMessage") {
21+
data.messages.splice(input.i,1);
22+
console.log(input.i);
23+
var del = new GlideRecord('u_sticky_notes');
24+
if (del.get(input.i)) {
25+
del.deleteRecord();
26+
27+
}
28+
}
29+
}
30+
31+
var gr = new GlideRecord('u_sticky_notes');
32+
gr.orderByDesc('sys_created_on');
33+
gr.query();
34+
data.notes = [];
35+
while(gr.next()){
36+
data.notes.push({
37+
sys_id: gr.getUniqueValue(),
38+
text: gr.getValue("u_short_description"),
39+
color: gr.getValue("u_color"),
40+
created_on: gr.getDisplayValue("sys_created_on")
41+
});
42+
}
43+
})();

0 commit comments

Comments
 (0)