• Joe Markey 6
  • NEWBIE
  • 10 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 2
    Likes Given
  • 0
    Questions
  • 4
    Replies
I am trying to display custom error message in lightning:input field using setCustomValidity() and reportValidity().
Exactly as given in the documentation here :- https://developer.salesforce.com/docs/component-library/bundle/lightning:input/documentation
 
({
    validateRenewaldate : function(component, event) {
        var inputCmp = component.find("inputCmp");
        var value = inputCmp.get("v.value");

        var calcutedValue = <some calculation here>;
        

        // is input valid text?
        if (value > calcutedValue) {
            inputCmp.setCustomValidity("”);
        } else {
            inputCmp.setCustomValidity("");
        }
        inputCmp.reportValidity(); 
    })

It displays the right error message when the input is invalid . But it does not remove that error essage when a valid data is entered.
I have even used checkValidity() to confirm that its actually valid.

I have verified this in Chrome and Firefox

In the documentation it clearly says reportValidity()  clears displayed wrrors when the input is valid but its not working that way.

Is there any way around this ?

P.S we can not se anything validity object because that is read-only now.
Hi!, 

I'm populating a configuration picklist using DynamicPickList class in lightning component app builder page, but it seems that getDefaultValue() method is not working. I even copied/pasted Salesforce example and it didn`t work either! :(

This is salesforce example: (https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_class_VisualEditor_DynamicPickList.htm#apex_class_VisualEditor_DynamicPickList)
global class MyCustomPickList extends VisualEditor.DynamicPickList{
    
    global override VisualEditor.DataRow getDefaultValue(){
        VisualEditor.DataRow defaultValue = new VisualEditor.DataRow('red', 'RED');
        return defaultValue;
    }
    global override VisualEditor.DynamicPickListRows getValues() {
        VisualEditor.DataRow value1 = new VisualEditor.DataRow('red', 'RED');
        VisualEditor.DataRow value2 = new VisualEditor.DataRow('yellow', 'YELLOW');
        VisualEditor.DynamicPickListRows  myValues = new VisualEditor.DynamicPickListRows();
        myValues.addRow(value1);
        myValues.addRow(value2);
        return myValues;
    }
}

And this is the picklist output in lightning app builder:
User-added image

User-added image

Anyone is having the same issue? Is something that I missed here?

Thanks!









 
Hi,

Is there any way to get description of all fields of an object in apex code?
Able to query inline text help, label, api name, length etc, but not the description.
Any workaround/trick ?

Thanks
Sid

How we'll use Custom label in apex code in which we'll  take the label name dynamically???

  • March 05, 2012
  • Like
  • 0
I am trying to display custom error message in lightning:input field using setCustomValidity() and reportValidity().
Exactly as given in the documentation here :- https://developer.salesforce.com/docs/component-library/bundle/lightning:input/documentation
 
({
    validateRenewaldate : function(component, event) {
        var inputCmp = component.find("inputCmp");
        var value = inputCmp.get("v.value");

        var calcutedValue = <some calculation here>;
        

        // is input valid text?
        if (value > calcutedValue) {
            inputCmp.setCustomValidity("”);
        } else {
            inputCmp.setCustomValidity("");
        }
        inputCmp.reportValidity(); 
    })

It displays the right error message when the input is invalid . But it does not remove that error essage when a valid data is entered.
I have even used checkValidity() to confirm that its actually valid.

I have verified this in Chrome and Firefox

In the documentation it clearly says reportValidity()  clears displayed wrrors when the input is valid but its not working that way.

Is there any way around this ?

P.S we can not se anything validity object because that is read-only now.
Hi!, 

I'm populating a configuration picklist using DynamicPickList class in lightning component app builder page, but it seems that getDefaultValue() method is not working. I even copied/pasted Salesforce example and it didn`t work either! :(

This is salesforce example: (https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_class_VisualEditor_DynamicPickList.htm#apex_class_VisualEditor_DynamicPickList)
global class MyCustomPickList extends VisualEditor.DynamicPickList{
    
    global override VisualEditor.DataRow getDefaultValue(){
        VisualEditor.DataRow defaultValue = new VisualEditor.DataRow('red', 'RED');
        return defaultValue;
    }
    global override VisualEditor.DynamicPickListRows getValues() {
        VisualEditor.DataRow value1 = new VisualEditor.DataRow('red', 'RED');
        VisualEditor.DataRow value2 = new VisualEditor.DataRow('yellow', 'YELLOW');
        VisualEditor.DynamicPickListRows  myValues = new VisualEditor.DynamicPickListRows();
        myValues.addRow(value1);
        myValues.addRow(value2);
        return myValues;
    }
}

And this is the picklist output in lightning app builder:
User-added image

User-added image

Anyone is having the same issue? Is something that I missed here?

Thanks!