Passing data from a modal in SP

-Andrew-
Kilo Sage

Hi all,

I'm struggling with passing data from a modal to the server in a SP list widget.

Within this modal, I am passing the selected date through an id of "newExpiryDate"

Andrew_0-1678358712750.png

Here is the client script:

c.Expiry = function () {
  swal({
    position: 'top-end',
    type: 'success',
    title: 'iManage Share Extended',
    showConfirmButton: true
  });

  // Set the action and new expiry date in the data object
  c.data.action = 'Expiry';
  c.data.newExpiryDate = c.newExpiryDate;

  // Send the data to the server-side script
  c.server.update().then(function () {
    c.data.action = undefined;
    spUtil.addInfoMessage("Share Extended", 3000);
    c.modalInstance.close();
  });
};

 

The action is being called in the server script:

if (input && input.action === 'Expiry') {
  data.newExpiryDate = input.newExpiry;
  gr.u_share_expiry = input.newExpiryDate;
  gr.update();
}

 

But the field remains blank, I've tried a few approaches to this and just can't get it to work. If a date is present in the field, the field is cleared when you submit.

 

Many thanks for the help!

1 ACCEPTED SOLUTION

-Andrew-
Kilo Sage

I've managed to figure it out - we just need to reference ng-model in the modal, e.g. ng-model="data.newExpiry"

View solution in original post

3 REPLIES 3

Sankar N
Kilo Guru

more details please

Thanks Sankar,

 

I also managed to get the exact same response from ChatGPT although this doesn't work. 

-Andrew-
Kilo Sage

I've managed to figure it out - we just need to reference ng-model in the modal, e.g. ng-model="data.newExpiry"