• Sagar Dumbre
  • NEWBIE
  • 0 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 3
    Replies
I am trying to dispatch an error event in the lighting record edit form through javascript. Below is my code sample. I would like to highlight the error field with the error message. I am able to get a response in the handleError method however my fields are not getting highlighted with the error message.
Any idea what I am missing? Thanks.
<lightning-record-edit-form object-api-name="Loan_Application__c" onerror={handleError} record-id={recordId} >
	<lightning-messages> </lightning-messages>                
	<lightning-input-field field-name="Legal_Entity__c"></lightning-input-field>
</lightning-record-edit-form>

JS:

onButtonClick(event){
	event.preventDefault();        
    const forms = this.template.querySelector('lightning-record-edit-form');
    if (forms) {      
      forms.dispatchEvent(
        new CustomEvent('error', {
          detail: {
            output: {
              errors: [],
              fieldErrors: {                
                Legal_Entity__c: [
                  {
                    constituentField: null,
                    duplicateRecordError: null,
                    errorCode: 'FIELD_CUSTOM_VALIDATION_EXCEPTION',
                    field: 'Legal_Entity__c',
                    fieldLabel: 'Legal Entity',
                    message: 'Please provide your legal entity type.',
                  },
                ],
              },
            },
          },
        })
      );
    }
}

handleError(event) {    
	console.log('OUTPUT => ', JSON.stringify(event.detail));
}

 
Hi,
I am trying to apply an XSLT transformation to an XML file and display the output in div element. Below code works in the local development server. However, if I add this component in any page layout in salesforce, it failed with below error.

TypeError: XSLTProcessor constructor: 'new' is required
import { LightningElement } from 'lwc';
import testXml from '@salesforce/resourceUrl/testXml';
import testXslt from '@salesforce/resourceUrl/testXslt';

export default class MyComponent extends LightningElement {

    renderedCallback() {
        const xsltProcessor = new XSLTProcessor();
        xsltProcessor.importStylesheet(testXslt);
        const result = xsltProcessor.transformToFragment(testXml, document);

        this.template.querySelector('.container').appendChild(result);
    }
}
Any suggestion to make it work in salesforce page/record layout.
 
I am trying to dispatch an error event in the lighting record edit form through javascript. Below is my code sample. I would like to highlight the error field with the error message. I am able to get a response in the handleError method however my fields are not getting highlighted with the error message.
Any idea what I am missing? Thanks.
<lightning-record-edit-form object-api-name="Loan_Application__c" onerror={handleError} record-id={recordId} >
	<lightning-messages> </lightning-messages>                
	<lightning-input-field field-name="Legal_Entity__c"></lightning-input-field>
</lightning-record-edit-form>

JS:

onButtonClick(event){
	event.preventDefault();        
    const forms = this.template.querySelector('lightning-record-edit-form');
    if (forms) {      
      forms.dispatchEvent(
        new CustomEvent('error', {
          detail: {
            output: {
              errors: [],
              fieldErrors: {                
                Legal_Entity__c: [
                  {
                    constituentField: null,
                    duplicateRecordError: null,
                    errorCode: 'FIELD_CUSTOM_VALIDATION_EXCEPTION',
                    field: 'Legal_Entity__c',
                    fieldLabel: 'Legal Entity',
                    message: 'Please provide your legal entity type.',
                  },
                ],
              },
            },
          },
        })
      );
    }
}

handleError(event) {    
	console.log('OUTPUT => ', JSON.stringify(event.detail));
}

 
Hi,
I am trying to apply an XSLT transformation to an XML file and display the output in div element. Below code works in the local development server. However, if I add this component in any page layout in salesforce, it failed with below error.

TypeError: XSLTProcessor constructor: 'new' is required
import { LightningElement } from 'lwc';
import testXml from '@salesforce/resourceUrl/testXml';
import testXslt from '@salesforce/resourceUrl/testXslt';

export default class MyComponent extends LightningElement {

    renderedCallback() {
        const xsltProcessor = new XSLTProcessor();
        xsltProcessor.importStylesheet(testXslt);
        const result = xsltProcessor.transformToFragment(testXml, document);

        this.template.querySelector('.container').appendChild(result);
    }
}
Any suggestion to make it work in salesforce page/record layout.