Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
createQuestionnaireAnswer() {
const fields = {};
console.log('create answer');
console.log('this.QuestionnaireReturnedId: ' + this.QuestionnaireReturnedId);
fields[QUESTIONNAIRE_RETURNED_FIELD.fieldApiName] = this.QuestionnaireReturnedId;
fields[QUESTIONNAIRE_QUESTION_FIELD.fieldApiName] = this.QuestionnaireQuestionId;
fields[AGREE_WITH_QUESTION_FIELD.fieldApiName] = this.answerValue;
fields[COMMENTS_FIELD.fieldApiName] = this.comments;
const recordInput = { apiName: QUESTIONNAIRE_ANSWER_OBJECT.objectApiName, fields };
createRecord(recordInput)
.then(QuestionnaireAns => {
this.questionAnswerId = QuestionnaireAns.id;
this.Questionnaire_Answer__c = QuestionnaireAns;
// sending an update event to the parent questionnaireList component
console.log('Creating Answer ==> updating list 1');
const updateEvent = new CustomEvent('updatequestionnairelist', {
detail: {
operation: 'New Answer',
questionID : this.QuestionnaireQuestionId,
newQuestionnaireAnswerID: this.questionAnswerId
},
bubbles: true
});
console.log('Creating Answer ==> updating list 2');
fields[QUESTIONNAIRE_RETURNED_FIELD.fieldApiName] = this.QuestionnaireReturnedId;
fields[QUESTIONNAIRE_QUESTION_FIELD.fieldApiName] = this.QuestionnaireQuestionId;
fields[AGREE_WITH_QUESTION_FIELD.fieldApiName] = this.answerValue;
fields[COMMENTS_FIELD.fieldApiName] = this.comments;
/*
console.log('======= createQuestionnaireAnswer ======');
console.log(this.answerValue);
console.log('this.QuestionnaireQuestionId: ' + this.QuestionnaireQuestionId);
console.log('this.QuestionnaireReturnedId: ' + this.QuestionnaireReturnedId);
console.log('this.comments: ' + this.comments);
console.log(JSON.stringify(fields));
*/
const recordInput = { apiName: QUESTIONNAIRE_ANSWER_OBJECT.objectApiName, fields };
createRecord(recordInput)
.then(QuestionnaireAns => {
this.questionAnswerId = QuestionnaireAns.id;
this.Questionnaire_Answer__c = QuestionnaireAns;
// LAST PIECE TO EXPLAIN - Updating the initial JSON
// Creates the event with the new questionnaire Return ID
// sending an update event to the parent questionnaireList component
console.log('Creating Answr ==> updating list');
console.log('this.QuestionnaireQuestionId: ' + this.QuestionnaireQuestionId);
console.log('this.questionAnswerId: ' + this.questionAnswerId);
const updateEvent = new CustomEvent('updatequestionnaire', {
detail: {
operation: 'New Answer',
questionID : this.QuestionnaireQuestionId,
newQuestionnaireAnswerID: this.questionAnswerId
},
createQuestionnaireReturn() {
const fields = {};
if(!this.termsConditions) this.termsConditions = false;
fields[QUESTIONNAIRE_FIELD.fieldApiName] = this.selectedQuestionnaireId;
fields[TANDC_FIELD.fieldApiName] = this.termsConditions;
fields[SUBMITTED_FIELD.fieldApiName] = this.questionnaireSubmitted;
fields[ANSWERED_BY_FIELD.fieldApiName] = this.answeredBy;
const recordInput = { apiName: QUESTIONNAIRE_RETURNED_OBJECT.objectApiName, fields };
createRecord(recordInput)
.then(questionnaireReturned => {
console.log('QUESTIONNAIRE RETURN RECORD CREATED');
// The following line is a bad idea - selectedQuestionnaireObj controlled by parent.
// this.selectedQuestionnaireObj.questionnaireReturnedId = questionnaireReturned.id;
this.questionnaireReturnedId = questionnaireReturned.id;
this.questionnaireReturned = questionnaireReturned;
// LAST PIECE TO EXPLAIN - Updating the initial JSON
// Creates the event with the new questionnaire Return ID
// sending an update event to the parent questionnaireList component
const updateEvent = new CustomEvent('updatequestionnaire', {
detail: {
operation: 'New Return',
newQuestionnaireReturnID: this.questionnaireReturnedId,
createQuestionnaireReturn() {
const fields = {};
if(!this.termsConditions) this.termsConditions = false;
fields[QUESTIONNAIRE_FIELD.fieldApiName] = this.selectedQuestionnaireId;
fields[TANDC_FIELD.fieldApiName] = this.termsConditions;
fields[SUBMITTED_FIELD.fieldApiName] = this.questionnaireSubmitted;
fields[ANSWERED_BY_FIELD.fieldApiName] = Id; // from import
const recordInput = { apiName: QUESTIONNAIRE_RETURNED_OBJECT.objectApiName, fields };
createRecord(recordInput)
.then(questionnaireReturned => {
console.log('QUESTIONNAIRE RETURN RECORD CREATED');
// The following line is a bad idea - selectedQuestionnaireObj controlled by parent.
// this.selectedQuestionnaireObj.questionnaireReturnedId = questionnaireReturned.id;
this.questionnaireReturnedId = questionnaireReturned.id;
this.questionnaireReturned = questionnaireReturned;
// sending an update event to the parent questionnaireList component
const updateEvent = new CustomEvent('updatequestionnairelist', {
detail: {
operation: 'New Return',
newQuestionnaireReturnID: this.questionnaireReturnedId,
},
bubbles: true
export async function ldsCreateRecord(newRecord, objectInfo) {
const normalizedRecord = normalizeRecord(newRecord);
const recordToSave = generateRecordInputForCreate(
normalizedRecord,
objectInfo
);
return createRecord(recordToSave);
}