How to retain the input data in html of Service Portal ?

Community Alums
Not applicable

Hi All,

I have a service portal widget where I want to maintain the data which user has inserted in html . Is there any way like local storage in service portal.

Thanks,

Prachi

3 REPLIES 3

Logan Poynter
Mega Sage
Mega Sage

Hello Prachi,

Can you elaborate on your requirement? It's not quite clear what you're asking for; what is happening vs. your expected outcome? Screenshots, code, etc. are all helpful. 


Please mark my answer as correct/helpful if it has helped you.

Thanks,
Logan

JC Icaro1
Kilo Guru

This might be similar to your requirement.

https://community.servicenow.com/community?id=community_question&sys_id=62d1ab881b2c1410a59033f2cd4bcbfd

shloke04
Kilo Patron

Hi, @Prachi Shahare 

In your HTML widget you need to use ng-model to store the date which can be used in other widget component like client controller or Server portion as well.

For example:

In my HTML on a page I have a Text box as shown below in my code:

HTML:

<div>
<div>${UserName:} <input type="text" class="form-control" ng-model="data.loggedUser"/></div>
</div>

Now I can use the model, to hold the value which need to be displayed and is getting fetched from Server component.

Server Side:

(function() {
  /* populate the 'data' object */
  /* e.g., data.table = $sp.getValue('table'); */

	data.loggedUser = gs.getUserName();

})();

Similarly you can do the reverse, define a ng-model as shown above and what ever user fills it in that field you can use ng -model to play around with the data either in client or Server as you want.

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke