Dropped Document - Multi Select Lookup Field
Good Morning,
I am using the update Dropped Documents function on a related Document control and want to update a Multi-Select Lookup Field with 2 (or More) values, my code is below.
The two fields I want to use are Company Name ('Company_x0020_Name') & Correspondence Company Name ('Correspondence_x0020_Company_x000'), I need these to go into the Muli-Select Lookup field called Company Name ('Company_x0020_Name'), currently on the first one is going into the field, could you advise please.
Thanks
Tony
I am using the update Dropped Documents function on a related Document control and want to update a Multi-Select Lookup Field with 2 (or More) values, my code is below.
The two fields I want to use are Company Name ('Company_x0020_Name') & Correspondence Company Name ('Correspondence_x0020_Company_x000'), I need these to go into the Muli-Select Lookup field called Company Name ('Company_x0020_Name'), currently on the first one is going into the field, could you advise please.
Thanks
Tony
Code: Select all
// Add Parent ID to uploaded Document for retrieval
fd.updateDroppedDocuments($('.documentUploadRICssClass'), {
Solutions_x0020_Quote_x0020_Reference: '{CurrentItem}'
});
// Update Uploaded Document for Relevant fields
fd.updateDroppedDocuments($('.documentUploadRICssClass'), function(listItem) {
debugger;
//get the values from the Form fields:
var companyName = fd.field('Company_x0020_Name').value();
var correspondenceCompanyName = fd.field('Correspondence_x0020_Company_x000').value();
var companyNames = (companyName+","+correspondenceCompanyName);
var addressName = fd.field('Address_x0020_Name').value();
var contactName = fd.field('Contact_x0020_Name').value();
var correspondenceAddressName = fd.field('Correspondence_x0020_Address_x000').value();
var correspondenceContactName = fd.field('Correspondence_x0020_Contact_x000').value();
var currentName = listItem.get_fieldValues().FileLeafRef;
var prefix = Date.now() / 1000 | 0;
var newName = prefix + '-' + currentName;
var documentCategory = fd.field('Document_x0020_Category').value();
var newFileName = listItem.get_item('FileDirRef') + '/' + newName;
//set the values on uploaded document:
listItem.set_item('Company_x0020_Name', companyNames);
listItem.set_item('Address_x0020_Name', addressName);
listItem.set_item('Contact_x0020_Name', contactName);
listItem.set_item('Title', currentName);
listItem.set_item('Document_x0020_Category', documentCategory);
listItem.update();
listItem.get_file().moveTo(newFileName);
});
- Nikita Kurguzov
- Posts: 889
- Joined: Mon Jul 03, 2017
Dear Tony,
Try it like this, it should work:
Try it like this, it should work:
Code: Select all
fd.updateDroppedDocuments($('.related-docs'), function(listItem) {
//array to hold value
var lookupVals = [];
//set 1st Lookup value
var lookupVal1 = new SP.FieldLookupValue();
lookupVal1.set_lookupId(fd.field("Lookup1").value());
lookupVals.push(lookupVal1);
//set 2nd Lookup value
var lookupVal2 = new SP.FieldLookupValue();
lookupVal2.set_lookupId(fd.field("Lookup2").value());
lookupVals.push(lookupVal2);
//set the values on uploaded document:
listItem.set_item('MultiLookup', lookupVals);
listItem.update();
});
Cheers
-
- Information
-
Who is online
Users browsing this forum: No registered users and 19 guests