Domanda

I have developed Sharepoint Hosted Addin with a List called Projects. And It has a Lookup for another List called Users to get the Team Lead for that project. When I trying to add new List Item to the Logs list using CRUD APIs and Sharepoint Hosted Addin, It gives this error.

The property 'Lead' does not exist on type 'SP.Data.ProjectsListListItem'. 
Make sure to only use property names that are defined by the type when using 
lookups

I searched lot in there documentations and haven't found a solution. Can anyone help me to go through this error. Thank you.

This is the AJAX call I use to send the data to list,

function addLog(data, formDigest) {
    var url = appUrl + listUrl + "/Items";
    url = GoodT.Repositories.targetUrl(url, hostUrl);

    var call = jQuery.ajax({
        url: url,
        type: "POST",
        data: data,
        headers: {
            Accept: "application/json;odata=verbose",
            "Content-Type": "application/json;odata=verbose",
            "X-RequestDigest": formDigest
        }
    });

    return call;
}
È stato utile?

Soluzione

If the "Lead" is the single lookup/user field, the data structure like this.

var data = {
    '__metadata': { "type": "SP.Data.ProjectsListItem" },
    "Title": 'Test',
    'LeadId': 12  //single-valued User field value 
};

If the "Lead" is the multiple lookup/user field, the data structure like this.

var data = {
    '__metadata': { "type": "SP.Data.ProjectsListItem" },
    "Title": 'Test',
    'LeadId': {"results": [12] }  //multi-valued User field value 
};
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a sharepoint.stackexchange
scroll top