Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
console.log(this.answerValue);
console.log('this.QuestionnaireQuestionId: ' + this.QuestionnaireQuestionId);
console.log('this.QuestionnaireReturnedId: ' + this.QuestionnaireReturnedId);
console.log('this.comments: ' + this.comments);
*/
let record = {
fields: {
Id: this.questionAnswerId,
// Questionnaire_Returned__c: this.QuestionnaireReturnedId,
// QuestionnaireQuestion__c:this.QuestionnaireQuestionId,
Agree_with_Question__c:this.answerValue,
Comments__c:this.comments,
},
};
updateRecord(record)
.then(() => {
this.dispatchEvent(
new ShowToastEvent({
title: 'Success',
message: 'Answer Updated',
variant: 'success',
}),
);
})
.catch(error => {
console.log(JSON.stringify(error));
this.dispatchEvent(
new ShowToastEvent({
title: 'Error updating record',
message: error.message.body,
variant: 'error',
updateQuestionnaireReturn() {
// Multiple pages - referential integrity #2 (@kevinv11n)
console.log('updateQuestionnaireReturn CALLED!!');
const fields = {};
fields[ID_FIELD.fieldApiName] = this.questionnaireReturnedId;
fields[QUESTIONNAIRE_FIELD.fieldApiName] = this.selectedQuestionnaireId;
fields[TANDC_FIELD.fieldApiName] = this.termsConditions;
fields[SUBMITTED_FIELD.fieldApiName] = this.questionnaireSubmitted;
fields[ANSWERED_BY_FIELD.fieldApiName] = Id;
let record = {fields};
updateRecord(record)
.then(() => {
this.dispatchEvent(
new ShowToastEvent({
title: 'Success',
message: 'Questionnaire Updated',
variant: 'success',
}),
);
})
.catch(error => {
this.dispatchEvent(
new ShowToastEvent({
title: 'Error updating record',
message: error.message.body,
variant: 'error',
}),
title: 'Warning',
message: 'You must agree to terms and conditions before submitting',
variant: 'warning',
}),
);
} else {
// Multiple pages - referential integrity #2 (@kevinv11n)
const fields = {};
fields[ID_FIELD.fieldApiName] = this.questionnaireReturnedId;
fields[QUESTIONNAIRE_FIELD.fieldApiName] = this.selectedQuestionnaireId;
fields[TANDC_FIELD.fieldApiName] = this.termsConditions;
fields[SUBMITTED_FIELD.fieldApiName] = true;
fields[ANSWERED_BY_FIELD.fieldApiName] = this.answeredBy;
let record = {fields};
updateRecord(record)
.then(() => {
const updateEvent = new CustomEvent('updatequestionnairelist', {
detail: {
operation: 'Return Submitted',
newQuestionnaireReturnID: this.questionnaireReturnedId,
},
bubbles: true
});
// Dispatches the event.
this.dispatchEvent(updateEvent);
this.dispatchEvent(
new ShowToastEvent({
title: 'Success',
message: 'Questionnaire Submitted',
async clearMailingAddress(row) {
let recordObject = {
fields: {
Id: row.Id,
MailingStreet: null,
MailingCity: null,
MailingState: null,
MailingPostalCode: null,
MailingCountry: null
}
}
try {
await updateRecord(recordObject);
} catch (error) {
this.dispatchEvent(
new ShowToastEvent({
message: String(error),
variant: 'error',
})
);
} finally {
this.reloadTable();
}
}
updateQuestionnaireReturn() {
let record = {
fields: {
Id: this.questionnaireReturnedId,
Questionnaire__c: this.selectedQuestionnaireId,
Terms_and_Conditions__c:this.termsConditions,
Submitted__c:this.questionnaireSubmitted,
Answered_By__c:this.answeredBy,
},
};
updateRecord(record)
.then(() => {
this.dispatchEvent(
new ShowToastEvent({
title: 'Success',
message: 'Questionnaire Updated',
variant: 'success',
}),
);
})
.catch(error => {
this.dispatchEvent(
new ShowToastEvent({
title: 'Error updating record',
message: error.message.body,
variant: 'error',
}),
export async function ldsUpdateRecord(newRecord, originalRecord, objectInfo) {
newRecord.id = originalRecord.id;
newRecord.apiName = null;
const newRecordEdit = generateRecordInputForUpdate(
normalizeRecord(newRecord),
objectInfo
);
const recordToSave = createRecordInputFilteredByEditedFields(
newRecordEdit,
originalRecord
);
return updateRecord(recordToSave);
}