Can we use c.server.update().then(function(){} twice in client script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-19-2018 03:40 AM
Hi All,
Can we use "c.server.update().then(function(){}" twice in client script of a widget in service portal.
Requirement is to pass the values from html to server, so am taking the changed input value from html and passing it to server script via client script. At first when I call c.server.update().then(function(){}, it works fine. But second time it is not.
Please help me in understanding.
Thanks & Regards,
Swathi.
- Labels:
-
Service Portal Development
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2018 02:48 AM
Hi,
We can call c.server.update() multiple times.
If you want to save multiple input values from html you can bundle it in array and pass it across to server with c.server.update()
Please do mark this answer helpful , if it answered you question.
Regards,
Swathi

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-27-2018 03:24 AM
Hi,
If your requirement is to send multiple values at the same time then sent it as Object.
or setting this to data object separely.
c.data.firstVal = "one";
c.data.secondVal = "two";
then on server side you can access it as input.firstVal and input.secondVal
OR if you want to make sequential call to server then do below.
c.data.firstVal = "one";
c.server.update().then(function(resp){
c.data.firstVal = resp.firstVal; //will get you value "one"
c.data.secondVal = "two";
c.server.update();
})
On Server script you need to persist value of firsVal. like below
after you use input.firstVal , write last line like
data.firstVal = input.firstVal;
Hope all this makes sense.
Mark my ANSWER as CORRECT / HELPFUL if it served your purpose.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2018 01:53 PM
Hi,
I have an issue with widget server script. I am adding comments in RITM. Everyting is working fine but comments are adding multiple times.
https://community.servicenow.com/community?id=community_question&sys_id=3cccc8e4db5c6b84fff8a345ca96191c
please suggest