Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Service portal Modal

Community Alums
Not applicable

Hello Team,
I am currently trying to create a modal which is prefilled with some data coming from server side on portal.

 

when a button is clicked it fetch the data from server side and should populate the same on modal created on client side. as shown below

 

html - 

<button ng-click="c.onOpen()"> get details </button>

 

Client script-

c.onOpen = function() {
c.data.action = "getSummarydetails";
c.server.update().then(function(response){
var whatdiscussed = "<h4>What Discussed</h4>";
var nextSteps = "<h4>Next Steps</h4>";
var sum_discussed = c.data.whatdiscussed;
var sum_nextsteps = c.data.nextSteps;
//ask the user for a string
spModal.open({
title: 'Summarization',
message: whatdiscussed + "\n" + sum_discussed + "\n\n" + nextSteps + "\n" + sum_nextsteps,
buttons: [
{label:'${Close}', cancel: true}
]
}).then(function(name) {
})
})
}

 

 

Server side - 

var rec = new GlideRecord("table_name");
rec.addEncodedQuery("field1="+data.field);
rec.query();
if(rec.next()){
data.whatdiscussed = rec.getValue('u_string_1') ;
data.nextSteps = rec.getValue('u_string_1');
}

 

But I am getting undefined 

Could anyone please let me know if there is a better way to achieve this 
Thank you very much in advance

 

0 REPLIES 0