How to use lightning - 10 common examples

To help you get started, we’ve selected a few lightning examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github barryhughes1 / pluralSightQuestionnaires_LWCs / force-app / main / questionnaires / lwc / questionnaireAnswer / questionnaireAnswer.js View on Github external
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',
github barryhughes1 / pluralSightQuestionnaires_LWCs / 04. Completed Solution / main / questionnaires / lwc / questionnaireLwc / questionnaireLwc.js View on Github external
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',
                    }),
github barryhughes1 / pluralSightQuestionnaires_LWCs / 04. Completed Solution / main / questionnaires / lwc / questionnaireAnswer / questionnaireAnswer.js View on Github external
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');
github barryhughes1 / pluralSightQuestionnaires_LWCs / force-app / main / questionnaires / lwc / questionnaireAnswer / questionnaireAnswer.js View on Github external
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
                  },
github barryhughes1 / pluralSightQuestionnaires_LWCs / force-app / main / questionnaires / lwc / questionnaireLwc / questionnaireLwc.js View on Github external
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,
github barryhughes1 / pluralSightQuestionnaires_LWCs / 04. Completed Solution / main / questionnaires / lwc / questionnaireLwc / questionnaireLwc.js View on Github external
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
github Gurenax / sfdx-lwc-fullcalendarjs / force-app / main / default / lwc / fullCalendarJs / fullCalendarJs.js View on Github external
renderedCallback() {

    // Performs this operation only on first render
    if (this.fullCalendarJsInitialised) {
      return;
    }
    this.fullCalendarJsInitialised = true;

    // Executes all loadScript and loadStyle promises
    // and only resolves them once all promises are done
    Promise.all([
      loadScript(this, FullCalendarJS + '/jquery.min.js'),
      loadScript(this, FullCalendarJS + '/moment.min.js'),
      loadScript(this, FullCalendarJS + '/fullcalendar.min.js'),
      loadStyle(this, FullCalendarJS + '/fullcalendar.min.css'),
      // loadStyle(this, FullCalendarJS + '/fullcalendar.print.min.css')
    ])
    .then(() => {
      // Initialise the calendar configuration
      this.initialiseFullCalendarJs();
    })
    .catch(error => {
      // eslint-disable-next-line no-console
      console.error({
        message: 'Error occured on FullCalendarJS',
        error
      });
    })
  }
github barryhughes1 / pluralSightQuestionnaires_LWCs / 04. Completed Solution / main / questionnaires / lwc / questionnaireLwc / questionnaireLwc.js View on Github external
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',
github salesforce / base-components-recipes / force-app / main / default / lwc / internationalizationLibrary / localizationService.js View on Github external
export function syncWallTimeToUTC(date, timeZone) {
    let converted = null;

    // eslint-disable-next-line new-cap
    getLocalizationService().WallTimeToUTC(date, timeZone, result => {
        converted = result;
    });
    return converted;
}
github tsalb / lwc-utils / force-app / main / default / lwc / lwcContactAddressForm / lwcContactAddressForm.js View on Github external
handleSuccess() {
    this.dispatchEvent(new ShowToastEvent({
      title: null,
      message: 'Updated Mailing Address Successfully.',
      variant: 'success'
    }));
    fireEvent(this.pageRef, 'forceRefreshView'); // actually targets the datatable for the refresh.
    this.template.querySelector('c-message-broker').notifyClose(); // consistent to use the @api in case implementation changes. do not fire event directly.
  }
}