- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2020 09:18 PM
I have to pass data from server to HTML or vice versa how would i achieve that?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2020 09:25 PM
You can do it like this
HTML:
<textarea id="comments" name="comments" rows="4" cols="30" ng-model="c.data.comments">
</textarea>
Server Side:
if (input && input.op && userApprovalAccess) {
gr.comments = input.comments;
}
In var field line,
use this
var fields = $sp.getFields(gr, 'state,sys_created_on,comments');
use this below data.fields = fields;
var work = gr.comments.getJournalEntry(1);
var array = work.split(")");
data.comment = array[1];
Now,In comments we have got comment we entered
In HTML to display server side data use
Comment:<div>{{c.data.comment}}</div>
It will pass data from HTML to server side
Please mark correct and helpful if it helps you.
In case of any further help.please message me
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2020 09:44 PM
Priyanka,is it working fine?
just telling you
Till then please reply
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2020 09:50 PM
Below this line(c.action = function(state,comments) { ) use if condition
if(state =='rejected' && !c.data.comments) {
c.data.no_comments = false;
alert("demo");
return;
}
and use other part(OOB) in else condition
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2020 09:52 PM
Now please update me about your progress
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2020 09:58 PM
Hi Priyanka,
To pass data from HTML (Client side) to server script, you can use c.server.update or c.server.get methods provided by ServiceNow.
To pass data from client script to HTML, you use Angular binding using controller global object i.e. c
For eg:
Client script:
c.example = 'Hello world!';
HTML:
<span>{{c.example}}</span>
You can refer to these links for further information:
- https://docs.servicenow.com/bundle/orlando-servicenow-platform/page/build/service-portal/concept/wid...
- https://serviceportal.io/communicating-between-the-client-script-and-the-server-script-of-a-widget/
- https://serviceportal.io/docs/
Please mark this response as 'Helpful' if this answers your question or reply to me if you have any other queries.
Thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-12-2020 03:46 AM
Hi Priyanka,please mark my answer correct and helpful if it helps you.
In case of any query,please reply.