How to Pass the Value from Widget Controller to On-load Script to set it to Variable field.

Jeck Manalo
Tera Guru

I am trying to create a spModal + Widget.

 

Where if I click Submit, it will pass the value from controller into on-load script to set it to the variable field.

 

HTML code:

<div>
<label>Select Mailbox Type</label>
<select ng-model="c.selected">
<option value="(On-Prem)">CUI User (On-Prem)</option>
<option value="O365">Non-CUI User (O365)</option>
</select>

 

  <br><br>
<button class="btn btn-primary" ng-click="c.submit()">Submit</button>

 

</div>

 

Controller:

api.controller = function() {

  var c = this;

 

  c.selected = '';

 

  c.submit = function() {

    if (!c.selected) {

      alert('Please select a value');

      return;

    }

    alert(c.selected);

    c.close(c.selected); // pass string back

 

 

  };

};

 

Onload:

 

function onLoad() {

 

var cui_value = g_form.getValue('cui_mailbox_location');

 

spModal.open({

            widget: 'widget_variable',

            backdrop: 'static',

            buttons: [],

        }).then(function(result) {

            alert(result);

            if (result) {

                setTimeout(function() {

                    g_form.setValue('cui_mailbox_location', result);

JeckManalo_0-1781830540497.png