Skip to main content
Tweeted twitter.com/StackSharePoint/status/1032961196197076992
added 11 characters in body
Source Link
user1309226
  • 165
  • 1
  • 1
  • 5

I have a Contacts list which has a ContactType field. This field is multi-value lookup field called ContactType. The result of a CAML query will show the following value for ContactType for one of the list items:

1;#Applicant;#2;#Employee

I had a look at Fiddler whilst queryafter executing a multipleCSOM query against the multi-value lookup field with CSOM and sawnoticed that the SP.FieldLookupValue object has two properties with the values:

$1E_1 : 1
$2e_1 : "Applicant"

However when you save a value you can only set the lookupId which is 1 in this case. There is no method to set up the value as in lookup.set_lookupValue().

I am attempting to copy the contents of ContactType into a new list item of Contacts. Unfortunately I have no success when updating the ContactType field. This is what I've tried so far:

var clientContext = new SP.ClientContext.get_current(); 
var oList = clientContext.get_web().get_lists().getByTitle('Contacts');
var itemCreateInfo = new SP.ListItemCreationInformation();
var oListItem = oList.addItem(itemCreateInfo);

var contactTypes = new Array();

$.each(contact.contactTypes, function (index, contactType) {
    var lookup = new SP.FieldLookupValue();
    lookup.set_lookupId(contactType.id);
    contactTypes.push(lookup);
});

// other set_item statements skipped for brevity
oListItem.set_item('ContactType', contactTypes);

oListItem.update();

The error message is:

Invalid lookup value. A lookup field contains invalid data.

I also experimented with the following code without any success:

lookup.set_lookupId(contactType.id + ";#" + contactType.title);

In this case the error message is:

The input string is not in the correct format.

If I update a single lookup I have no problems but the issue lies in the saving of the array of lookups. For example, the following code works fine:

var lookup = new SP.FieldLookupValue();
lookup.set_lookupId(1);
contactTypes.push(lookup);
oListItem.set_item('ContactType', lookup);

but it doesn't play ball when attempting to save the array of lookups as in

oListItem.set_item('ContactType', contactTypes);

Any ideas?

I have a Contacts list which has a ContactType field. This field is multi-value lookup field. The result of a CAML query will show the following value for ContactType for one of the list items:

1;#Applicant;#2;#Employee

I had look at Fiddler whilst query a multiple lookup field with CSOM and saw that the SP.FieldLookupValue object has two properties with the values:

$1E_1 : 1
$2e_1 : "Applicant"

However when you save a value you can only set the lookupId which is 1 in this case. There is no method to set up the value as in lookup.set_lookupValue().

I am attempting to copy the contents of ContactType into a new list item of Contacts. Unfortunately I have no success when updating the ContactType field. This is what I've tried so far:

var clientContext = new SP.ClientContext.get_current(); 
var oList = clientContext.get_web().get_lists().getByTitle('Contacts');
var itemCreateInfo = new SP.ListItemCreationInformation();
var oListItem = oList.addItem(itemCreateInfo);

var contactTypes = new Array();

$.each(contact.contactTypes, function (index, contactType) {
    var lookup = new SP.FieldLookupValue();
    lookup.set_lookupId(contactType.id);
    contactTypes.push(lookup);
});

// other set_item statements skipped for brevity
oListItem.set_item('ContactType', contactTypes);

oListItem.update();

The error message is:

Invalid lookup value. A lookup field contains invalid data.

I also experimented with the following code without any success:

lookup.set_lookupId(contactType.id + ";#" + contactType.title);

In this case the error message is:

The input string is not in the correct format.

If I update a single lookup I have no problems but the issue lies in the saving of the array of lookups. For example, the following code works fine:

var lookup = new SP.FieldLookupValue();
lookup.set_lookupId(1);
contactTypes.push(lookup);
oListItem.set_item('ContactType', lookup);

Any ideas?

I have a Contacts list which has a multi-value lookup field called ContactType. The result of a CAML query will show the following value for ContactType for one of the list items:

1;#Applicant;#2;#Employee

I had a look at Fiddler after executing a CSOM query against the multi-value lookup field and noticed that the SP.FieldLookupValue object has two properties with the values:

$1E_1 : 1
$2e_1 : "Applicant"

However when you save a value you can only set the lookupId which is 1 in this case. There is no method to set up the value as in lookup.set_lookupValue().

I am attempting to copy the contents of ContactType into a new list item of Contacts. Unfortunately I have no success when updating the ContactType field. This is what I've tried so far:

var clientContext = new SP.ClientContext.get_current(); 
var oList = clientContext.get_web().get_lists().getByTitle('Contacts');
var itemCreateInfo = new SP.ListItemCreationInformation();
var oListItem = oList.addItem(itemCreateInfo);

var contactTypes = new Array();

$.each(contact.contactTypes, function (index, contactType) {
    var lookup = new SP.FieldLookupValue();
    lookup.set_lookupId(contactType.id);
    contactTypes.push(lookup);
});

// other set_item statements skipped for brevity
oListItem.set_item('ContactType', contactTypes);

oListItem.update();

The error message is:

Invalid lookup value. A lookup field contains invalid data.

I also experimented with the following code without any success:

lookup.set_lookupId(contactType.id + ";#" + contactType.title);

In this case the error message is:

The input string is not in the correct format.

If I update a single lookup I have no problems but the issue lies in the saving of the array of lookups. For example, the following code works fine:

var lookup = new SP.FieldLookupValue();
lookup.set_lookupId(1);
contactTypes.push(lookup);
oListItem.set_item('ContactType', lookup);

but it doesn't play ball when attempting to save the array of lookups as in

oListItem.set_item('ContactType', contactTypes);

Any ideas?

added 306 characters in body
Source Link
user1309226
  • 165
  • 1
  • 1
  • 5

I have a Contacts list which has a ContactType field. This field is multi-value lookup field. The result of a CAML query will show the following value for ContactType for one of the list items:

1;#Applicant;#2;#Employee

I had look at Fiddler whilst query a multiple lookup field with CSOM and saw that the SP.FieldLookupValue object has two properties with the values:

$1E_1 : 1
$2e_1 : "Applicant"

However when you save a value you can only set the lookupId which is 1 in this case. There is no method to set up the value as in lookup.set_lookupValue().

I am attempting to copy the contents of ContactType into a new list item of Contacts. Unfortunately I have no success when updating the ContactType field. This is what I've tried so far:

var clientContext = new SP.ClientContext.get_current(); 
var oList = clientContext.get_web().get_lists().getByTitle('Contacts');
var itemCreateInfo = new SP.ListItemCreationInformation();
var oListItem = oList.addItem(itemCreateInfo);

var contactTypes = new Array();

$.each(contact.contactTypes, function (index, contactType) {
    var lookup = new SP.FieldLookupValue();
    lookup.set_lookupId(contactType.id);
    contactTypes.push(lookup);
});

// other set_item statements skipped for brevity
oListItem.set_item('ContactType', contactTypes);

oListItem.update();

The error message is:

Invalid lookup value. A lookup field contains invalid data.

I also experimented with the following code without any success:

lookup.set_lookupId(contactType.id + ";#" + contactType.title);

In this case the error message is:

The input string is not in the correct format.

If I update a single lookup I have no problems but the issue lies in the saving of the array of lookups. For example, the following code works fine:

var lookup = new SP.FieldLookupValue();
lookup.set_lookupId(1);
contactTypes.push(lookup);
oListItem.set_item('ContactType', lookup);

Any ideas?

I have a Contacts list which has a ContactType field. This field is multi-value lookup field. The result of a CAML query will show the following value for ContactType for one of the list items:

1;#Applicant;#2;#Employee

I had look at Fiddler whilst query a multiple lookup field with CSOM and saw that the SP.FieldLookupValue object has two properties with the values:

$1E_1 : 1
$2e_1 : "Applicant"

However when you save a value you can only set the lookupId which is 1 in this case. There is no method to set up the value as in lookup.set_lookupValue().

I am attempting to copy the contents of ContactType into a new list item of Contacts. Unfortunately I have no success when updating the ContactType field. This is what I've tried so far:

var clientContext = new SP.ClientContext.get_current(); 
var oList = clientContext.get_web().get_lists().getByTitle('Contacts');
var itemCreateInfo = new SP.ListItemCreationInformation();
var oListItem = oList.addItem(itemCreateInfo);

var contactTypes = new Array();

$.each(contact.contactTypes, function (index, contactType) {
    var lookup = new SP.FieldLookupValue();
    lookup.set_lookupId(contactType.id);
    contactTypes.push(lookup);
});

// other set_item statements skipped for brevity
oListItem.set_item('ContactType', contactTypes);

oListItem.update();

The error message is:

Invalid lookup value. A lookup field contains invalid data.

I also experimented with the following code without any success:

lookup.set_lookupId(contactType.id + ";#" + contactType.title);

In this case the error message is:

The input string is not in the correct format.

Any ideas?

I have a Contacts list which has a ContactType field. This field is multi-value lookup field. The result of a CAML query will show the following value for ContactType for one of the list items:

1;#Applicant;#2;#Employee

I had look at Fiddler whilst query a multiple lookup field with CSOM and saw that the SP.FieldLookupValue object has two properties with the values:

$1E_1 : 1
$2e_1 : "Applicant"

However when you save a value you can only set the lookupId which is 1 in this case. There is no method to set up the value as in lookup.set_lookupValue().

I am attempting to copy the contents of ContactType into a new list item of Contacts. Unfortunately I have no success when updating the ContactType field. This is what I've tried so far:

var clientContext = new SP.ClientContext.get_current(); 
var oList = clientContext.get_web().get_lists().getByTitle('Contacts');
var itemCreateInfo = new SP.ListItemCreationInformation();
var oListItem = oList.addItem(itemCreateInfo);

var contactTypes = new Array();

$.each(contact.contactTypes, function (index, contactType) {
    var lookup = new SP.FieldLookupValue();
    lookup.set_lookupId(contactType.id);
    contactTypes.push(lookup);
});

// other set_item statements skipped for brevity
oListItem.set_item('ContactType', contactTypes);

oListItem.update();

The error message is:

Invalid lookup value. A lookup field contains invalid data.

I also experimented with the following code without any success:

lookup.set_lookupId(contactType.id + ";#" + contactType.title);

In this case the error message is:

The input string is not in the correct format.

If I update a single lookup I have no problems but the issue lies in the saving of the array of lookups. For example, the following code works fine:

var lookup = new SP.FieldLookupValue();
lookup.set_lookupId(1);
contactTypes.push(lookup);
oListItem.set_item('ContactType', lookup);

Any ideas?

added 352 characters in body
Source Link
user1309226
  • 165
  • 1
  • 1
  • 5

I have a Contacts list which has a ContactType field. This field is multi-value lookup field. The result of a CAML query will show the following value for ContactType for one of the list items:

1;#Applicant;#2;#Employee

I had look at Fiddler whilst query a multiple lookup field with CSOM and saw that the SP.FieldLookupValue object has two properties with the values:

$1E_1 : 1
$2e_1 : "Applicant"

However when you save a value you can only set the lookupId which is 1 in this case. There is no method to set up the value as in lookup.set_lookupValue().

I am attempting to copy the contents of ContactType into a new list item of Contacts. Unfortunately I have no success when updating the ContactType field. This is what I've tried so far:

var clientContext = new SP.ClientContext.get_current(); 
var oList = clientContext.get_web().get_lists().getByTitle('Contacts');
var itemCreateInfo = new SP.ListItemCreationInformation();
var oListItem = oList.addItem(itemCreateInfo);

var contactTypes = new Array();

$.each(contact.contactTypes, function (index, contactType) {
    var lookup = new SP.FieldLookupValue();
    lookup.set_lookupId(contactType.id);
    contactTypes.push(lookup);
});

// other set_item statements skipped for brevity
oListItem.set_item('ContactType', contactTypes);

oListItem.update();

The error message is:

Invalid lookup value. A lookup field contains invalid data.

I also experimented with the following code without any success:

lookup.set_lookupId(contactType.id + ";#" + contactType.title);

In this case the error message is:

The input string is not in the correct format.

Any ideas?

I have a Contacts list which has a ContactType field. This field is multi-value lookup field. The result of a CAML query will show the following value for ContactType for one of the list items:

1;#Applicant;#2;#Employee

I am attempting to copy the contents of ContactType into a new list item of Contacts. Unfortunately I have no success when updating the ContactType field. This is what I've tried so far:

var clientContext = new SP.ClientContext.get_current(); 
var oList = clientContext.get_web().get_lists().getByTitle('Contacts');
var itemCreateInfo = new SP.ListItemCreationInformation();
var oListItem = oList.addItem(itemCreateInfo);

var contactTypes = new Array();

$.each(contact.contactTypes, function (index, contactType) {
    var lookup = new SP.FieldLookupValue();
    lookup.set_lookupId(contactType.id);
    contactTypes.push(lookup);
});

// other set_item statements skipped for brevity
oListItem.set_item('ContactType', contactTypes);

oListItem.update();

The error message is:

Invalid lookup value. A lookup field contains invalid data.

I also experimented with the following code without any success:

lookup.set_lookupId(contactType.id + ";#" + contactType.title);

In this case the error message is:

The input string is not in the correct format.

Any ideas?

I have a Contacts list which has a ContactType field. This field is multi-value lookup field. The result of a CAML query will show the following value for ContactType for one of the list items:

1;#Applicant;#2;#Employee

I had look at Fiddler whilst query a multiple lookup field with CSOM and saw that the SP.FieldLookupValue object has two properties with the values:

$1E_1 : 1
$2e_1 : "Applicant"

However when you save a value you can only set the lookupId which is 1 in this case. There is no method to set up the value as in lookup.set_lookupValue().

I am attempting to copy the contents of ContactType into a new list item of Contacts. Unfortunately I have no success when updating the ContactType field. This is what I've tried so far:

var clientContext = new SP.ClientContext.get_current(); 
var oList = clientContext.get_web().get_lists().getByTitle('Contacts');
var itemCreateInfo = new SP.ListItemCreationInformation();
var oListItem = oList.addItem(itemCreateInfo);

var contactTypes = new Array();

$.each(contact.contactTypes, function (index, contactType) {
    var lookup = new SP.FieldLookupValue();
    lookup.set_lookupId(contactType.id);
    contactTypes.push(lookup);
});

// other set_item statements skipped for brevity
oListItem.set_item('ContactType', contactTypes);

oListItem.update();

The error message is:

Invalid lookup value. A lookup field contains invalid data.

I also experimented with the following code without any success:

lookup.set_lookupId(contactType.id + ";#" + contactType.title);

In this case the error message is:

The input string is not in the correct format.

Any ideas?

Source Link
user1309226
  • 165
  • 1
  • 1
  • 5
Loading