0

I am at a loss here...I had everything working without issues, then I deleted a column and added a new one in that is a Person or Group column instead of a string and now it won't work anymore.

I made the appropriate changes to the data to make sure it has the right information for the person/group column(their Id number), and it posts successfully but the data.d returns as null for everything even though the model contains data.

   myModel.statusList = {
         "__metadata":{ "type": "SP.Data.StatusListListItem" },
         ProjectID: row.ProjectID,
         EngListID: row.ID,
         AssignedTo: { 'results': myModel.formData.model.modalAssign },
         AssignedBy: loggedUser.value,
         ProjStatus: 'Assigned',
         AssignedBackup: { 'results': myModel.formData.model.modalAssignBackup },
         AssignedOn: new Date(),
         BackupExpDate: myModel.formData.model.modalBackupExp
  };

These all contain data, the post call is:

 this.postDealItem = function (list, model, successMsg, errorMsg) {
        return $.ajax({
            method: 'POST',
            beforeSend: function () {
                isLoading = true;
                $('.spinner').show();
                $('.spinner').fadeIn(500);

            },
            complete: function () {
                $('.spinner').fadeOut(500);
                $('.spinner').hide();
                isLoading = false;
            },
            url: SPUrl + "/_api/web/lists/getByTitle('" + list + "')/items",
            contentType: "application/json;odata=verbose",
            headers: {
                "accept": "application/json;odata=verbose",
                "X-RequestDigest": $("#__REQUESTDIGEST").val()
            },
            data: JSON.stringify(model)
        }).then(function (data, request) {
            successMsg !== undefined && successMsg !== null ? alertify.success(successMsg) : null;
            return data.d;
        }, function (error) {
            errorMsg != undefined && errorMsg !== null ? alertify.error(errorMsg + error.status) : null;
            //alertify.error('There was an error creating an item in the ' + list + '! Error: ' + error.status);
        });
    };

Can someone please point me as to what is going on and why this isn't working anymore?

1
  • can you please use console.log(data) in ajax before return Commented Nov 2, 2017 at 11:13

1 Answer 1

0

I figured out the issues when I closely stepped through it.

The issue is I have some multi-user person columns and a few single person user columns.

For the multi-user columns you pass in an array of results with their ID(s).

For the single user columns you append Id to the column name and pass in the ID. It now works as expected.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.