Hello @Tony_Duke,
The trick is to set the value in the new item. The syntax should be as following.
ChoiceField: {
results: [ 'Choice #2', 'Choice #3' ]
}
So your code will be as below.
// Function to Raise Renewal for the Contract
function raiseRenewalContract () {
if (confirm('Are you sure you wish to raise a Renewal for this Contract?')) {
doNotRedirect = true;
//fd.save();
var refParts = fd.field('Title').value.split('-');
var newVersion = parseFloat(refParts[2]) + 1;
var newReference = refParts[0] + '-' + refParts[1] + '-' + newVersion;
var correspondenceCompanyNameId = fd.field('Correspondence_x0020_Company_x00').value.LookupId;
var correspondenceAddressNameId = fd.field('Correspondence_x0020_Address_x00').value.LookupId;
var correspondenceContactNameId = fd.field('Correspondence_x0020_Contact_x00').value.LookupId;
var siteCompanyNameId = fd.field('Company_x0020_Name').value.LookupId;
var siteAddressNameId = fd.field('Address_x0020_Name').value.LookupId;
var siteContactNameId = fd.field('Contact_x0020_Name').value.LookupId;
var wrsCompanyId = fd.field('WRS_x0020_Company').value.LookupId;
var wrsCompanyName = fd.field('WRS_x0020_Company').value.LookupValue;
var responsibility = retrieveResponisibilityPersonOrGroupFieldByFilter(correspondenceCompanyNameId,wrsCompanyName);
var customerAccountManagerId = responsibility.UserId;
var dateRaised = new Date();
var quotedContractLength = parseFloat(fd.field('Quoted_x0020_Contract_x0020_Leng').value);
var parts = fd.field('Renewal_x0020_Due_x0020_Date').value.split('/');
var string = parts[1] + '/' + parts[0] + '/' + parts[2];
var proposedStartDate = new Date(string);
var renewalDate = new Date(string);
renewalDate.setMonth(renewalDate.getMonth() + quotedContractLength);
var endDate = new Date(string);
endDate.setMonth(endDate.getMonth() + quotedContractLength);
endDate.setDate(endDate.getDate() - 1);
debugger;
var contractOption = fd.field('Contract_x0020_Option').value;
var contractSystems = fd.field('Contract_x0020_Systems').value;
var cctvDetails = fd.field('CCTV_x0020__x002d__x0020_Detail').value;
var list = pnp.sp.web.lists.getByTitle("Solutions%20Maintenance%20Contracts");
list.items.add({
Title: newReference,
Correspondence_x0020_Company_x00Id: correspondenceCompanyNameId,
Correspondence_x0020_Address_x00Id: correspondenceAddressNameId,
Correspondence_x0020_Contact_x00Id: correspondenceContactNameId,
Company_x0020_NameId: siteCompanyNameId,
Address_x0020_NameId: siteAddressNameId,
Contact_x0020_NameId: siteContactNameId,
WRS_x0020_CompanyId: wrsCompanyId,
Customer_x0020_Account_x0020_ManId: customerAccountManagerId,
Date_x0020_Raised: dateRaised,
Contract_x0020_Issue_x0020_Type: 'Renewal',
Quoted_x0020_Contract_x0020_Leng: quotedContractLength,
Contract_x0020_Start_x0020_Date: proposedStartDate,
Contract_x0020_End_x0020_Date: endDate,
Renewal_x0020_Due_x0020_Date: renewalDate,
Forecast_x0020_Date: proposedStartDate,
Forecast_x0020_Probability: '3 - Ongoing',
Contract_x0020_Option: contractOption,
Contract_x0020_Systems:{
results: contractSystems
},
CCTV_x0020__x002d__x0020_Detail: cctvDetails
}).then(function(){
console.log("Created!");
});
}
}