Create a widget on service portal page and data coming from table

aastha3
Giga Contributor

Hi ,

Service Portal is very new to me and I am facing issue finding out way to achieve functionality to create widget on top of service portal .Widget should display text ,the text is stored in a table (could be custom table), and users can maintain it to display any kind of info and notification to let portal users know it.

I know how to do it in ESS Portal but no idea about service portal.

Please provide step wise solution and screenshots as to how I can achieve this.

Thanks

Aastha Sharma

1 ACCEPTED SOLUTION

Hi,



To answer your questions.


1.In this case I didn't extend from any table. Task table is pretty normal to extend from. Just remember that extending a table or creating a new may result in that you need Platform runtime licences. So talk to you SN representative to be sure.
About when to do it, read this post here which gives an excellent overview: When to Create a New Table vs. When to Extend


2. You fetch the data with server script and then put it into "data" for the client script to handle.



3. If you want to have data from your instance, you need a server script.



recordWatch is used to dynamically update your widget with data if for example a new record is created/updated in the table.


Take a look here, this short demo also shows how to read from data from a table.


Real Time To Do App using Service Portal & Record Watchers - ServicePortal.io - Service Portal, CMS,...



Let me know if you got more questions.



//Göran


View solution in original post

5 REPLIES 5

Goran WitchDoc
ServiceNow Employee
ServiceNow Employee

Take a look here. Here I do a small custom table from where I can create records in from the portal and extra would be I show how to use google recaptcha.


Google Recaptcha in Service Portal




/Göran


goranlundqvist


Hi Goran,


Some questions I wanted to ask



1. While creating table have you used extends table:   . If yes then which table name ?


2. How to write client script to fetch values from table to widget .


3. I don't think my requirement will require server script . Correct me if I am wrong.




-> I have created u_top_widget table with 2 fields title and description.



->As I just need title and description I have written below HTML Template


<div>


<div class="form-group">


  <input class="form-control" ng-model="c.data.title">


  </div>


 


  <div class="form-group">


  <input class="form-control" ng-model="c.data.description">


  </div>



  </div>



-> But I am confused what to include in client script(read about recordwatch somewhere dont know how to apply it in my requirement)



function(spUtil, $scope) {

  /* widget controller */


  var c =this;




  spUtil.recordWatch($scope, "u_top_widget",function(title, description) {


console.log(title); //Returns information about the event that has occurred

      console.log(description); //Returns the data inserted or updated on the table


  });


}



Please provide me correct solution.


Hi,



To answer your questions.


1.In this case I didn't extend from any table. Task table is pretty normal to extend from. Just remember that extending a table or creating a new may result in that you need Platform runtime licences. So talk to you SN representative to be sure.
About when to do it, read this post here which gives an excellent overview: When to Create a New Table vs. When to Extend


2. You fetch the data with server script and then put it into "data" for the client script to handle.



3. If you want to have data from your instance, you need a server script.



recordWatch is used to dynamically update your widget with data if for example a new record is created/updated in the table.


Take a look here, this short demo also shows how to read from data from a table.


Real Time To Do App using Service Portal & Record Watchers - ServicePortal.io - Service Portal, CMS,...



Let me know if you got more questions.



//Göran


Thanks a lot for providing this link . It helped me to solve my requirement .


Regards


Aastha