modal dialog - ServiceNow angularjs: how to pass server script values to client script -
i working in servicenow , creating widget pulls modal window form embedded in it. want pre-populate of fields in modal form, unsure how this.
here html of button opens modal window:
<div> <input class="btn btn-support" ng-click="c.onbsupport()" type="button" value="ask question"> </div> my client script looks this:
function($scope,spmodal) { /* widget controller */ var c = this; c.onbsupport = function(){ spmodal.open({ title: 'submit question', widget: 'form-new', widgetinput: {table: 'support_tickets'}, buttons: [] }).then(function(){ }) } } and finally, here server script:
var usr = gs.getuserid(); var gr = new gliderecord('info'); gr.addquery('opened_for', usr); gr.query(); if(gr.next()) { data.parent = gr.getvalue('number'); data.short_description = gr.getvalue('short_description'); } in modal form, have 2 fields (parent_case , category) pre-populated data.parent , data.short_description respectively. pass server script value html, know can {{data.parent}}. however, how values client script generates modal form?
you need pass values client script , "catch".
i assuming trying pass multiple values, need array keep values , pass client script side.
server script:
var records=[]; //define array first var usr = gs.getuserid(); var gr = new gliderecord('info'); gr.addquery('opened_for', usr); gr.query(); if(gr.next()) { var rec={} //define record rec.parent = gr.getvalue('number'); rec.short_description = gr.getvalue('short_description'); records.push(rec); //populate array records } data.records=records; // need assign array data client script:
function($scope,spmodal) { /* widget controller */ var c = this; var infos=c.data.records;//this "catch" part } note:i haven't tested code.
Comments
Post a Comment