pass variables from Server Script to html template in Widget

Swathi P
Tera Guru

Hi ,

I am trying to build widget in service portal . I created a variable with Type as Custom in Record Producer. I am trying to push server side script data to html template. Its blank in html template. attached screenshot in question .Please check and let me know where i am doing wrong

this is the Widget which is created:

html template ::

<div>
  <table class="table">
  <thead>   
    <tr>
      <th>Name</th>
      <th>Code</th>        
    </tr>
  </thead>
  <tbody> 
    <td> {{data.Name}}</td>
    <td>  {{data.Code }}</td>       
  </tbody>
</table>
</div>

Client Controller : 

    var c = this;
    c.data.multiple_po = $scope.page.g_form.getValue('po');
    
    c.updateNote = function() {
        c.server.get({

            multiple_po:  c.data.multiple_po

        }).then(function(r) {});
    };
    c.updateNote();

Server Side SCript :

   if (input) {
       
        var vendorName, companyCode;
        var poTable = new GlideRecord('purchase_order');
        poTable.addEncodedQuery('sys_idIN' + input.po);
        poTable.setLimit(1);
        poTable.query();
        if (poTable.next()) {
            Name = poTable.getDisplayValue('id');
            Code = poTable.getDisplayValue('code');
        }
        data.Name = Name;
        data.Code = Code;
    }

4 REPLIES 4

MrMuhammad
Giga Sage

Hi,

Update below as

   <td> {{c.data.Name}}</td>
    <td>  {{c.data.Code }}</td>       

Regards,

Muhammad

Regards,
Muhammad

Como eu posso fazer o contrário?
Pegar por exemplo, uma data que o usuário escolheu no Html e trabalhar com esse valor no Server script?

Anurag15
Giga Expert

Can you try this in server script:

 

  if (input) {
       
        var vendorName, companyCode;
        var poTable = new GlideRecord('purchase_order');
        poTable.addEncodedQuery('sys_idIN' + input.multiple_po);
        poTable.setLimit(1);
        poTable.query();
        if (poTable.next()) {
            Name = poTable.getDisplayValue('id');
            Code = poTable.getDisplayValue('code');
        }
        data.Name = Name;
        data.Code = Code;
    }

Swathi P
Tera Guru

Its not working .. I tried