0

I am using vuejs with SharePoint. I get the following error in the function below.

"The property 'columnName' does not exist on type 'SP.Data.RegisterListItem'. Make sure to only use property names that are defined by the type."

Here's my internal name:

enter image description here

I am passing in 'RiskRegister' as an argument to updateField. How will I use the parameter columnName, which represents 'RiskRegister', in my function?

HTML Side <input type="text" v-on:change="updateField((risk, 'RiskRegister', risk.RiskRegister))" v-bind:data-id="risk.id" :readonly="!risk.editable" v-model="risk.RiskRegister">

JavaScript (Excerpt)

 function updateField(risk, columnName, columnValue){

        var item = {
          "__metadata": { "type": 'SP.Data.RegisterListItem' },
          columnName : columnValue
        };

       $.ajax({
          url:  _spPageContextInfo.webAbsoluteUrl  + "/_api/web/lists/getbytitle('Register')/items(" + risk.Id + ")", ///_api/web/lists/getbytitle('register')/listitementitytypefullname
          type: "POST",
          contentType: "application/json;odata=verbose",
          data: JSON.stringify(item),
          headers: {
              "Accept": "application/json;odata=verbose",
              "X-RequestDigest": $("#__REQUESTDIGEST").val(),
              "IF-MATCH": "*",
              "X-HTTP-Method":"MERGE",
           },
          success: function (data) {
               alert("success");
          },
          error: function (data) {
               alert("failed");
          }
        });

}

Any help would be much appreciated.

Thanks!

0

Check the entity name of your column using below API and make sure that you are passing the same in metadata.

/_api/lists/getbytitle('Register')

If the entity name is the same then make sure you are passing the Internal Name of the column.

References:

Check the entity name of the Column

Use the Internal Name of Column

0

This is not related to metadata. This is something related to your field "columnName".

SharePoint REST API uses Internal Name of column in AJAX calls.

So, in your item body you need to pass the internal name of your column and not the display name.

You can get the internal name of your column from column settings URL (Check below references) then pass that name in your item body.

Reference:

  1. How to check Column Internal Name for a SharePoint List.
  2. How to get Internal names of columns in sharepoint lists?

You can also let us know the data type of your field so that we can tell you the format you need to pass your data in.

0

Do a call to "/_api/web/lists/getbytitle('Register')/items", to see if the column internal name is valid in your side, it will have all column's internal name listed as below:

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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