• Aratz Guerra
  • NEWBIE
  • 25 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 5
    Replies
Hello, 

I want to show 2 error messages using addError, but it seems like in Lightning  doesn´t work line breaks like </br> or </n>

I need something like this:

string br = '</br>';
a.addError('Error 1'+br+'Error 2 ');

Could anyone help me?
Hi, I need to remove the scrollbar from div in lightning.

Here is my code:

COMPONENT:
<aura:component implements="force:lightningQuickActionWithoutHeader,force:hasRecordId" access="global">
    
    <!-- Define Attribute-->
    <aura:attribute name="newQuote" type="Object"/>
    <aura:attribute name="simpleNewQuote" type="Object" default="{'sobjectType':'SBQQ__Quote__c', 'SBQQ__EndDate__c':''}"/>
    <aura:attribute name="newQuoteError" type="String"/> 
    <aura:attribute name="lookUpRecord" type="Object"/>
    
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>

    <force:recordData aura:id="QuoteRecordCreator" 
                      layoutType="FULL"
                      targetRecord="{!v.newQuote}"
                      targetFields="{!v.simpleNewQuote}"
                      targetError="{!v.newQuoteError}"/>
                      
    <div class="slds-modal__header">
        <h2 class="slds-text-heading--medium">New Quote</h2>
    </div>

    <!-- Display the new quote form -->
    <div class="slds-form_stacked">
        
        <c:customLookup objectAPIName="Contact" IconName="standard:Contact" label="Primary Contact" selectedRecord="{!v.lookUpRecord}"/>
        
        <lightning:input aura:id="QuoteField" type="date" name="Notes" label="Offer end date"
                         value="{!v.simpleNewQuote.SBQQ__EndDate__c}"/>
        <lightning:textarea aura:id="QuoteField" name="Notes" label="Additional notes"
                         value="{!v.simpleNewQuote.SBQQ__Notes__c}"/>
        
        <lightning:button label="Create Quote" onclick="{!c.handleSaveQuote}"
                   variant="brand" class="slds-m-top_medium"/>
   </div>
    
   

</aura:component>

CONTROLLER:
({
    doInit: function(component, event, helper) {
        // Prepare a new record from template
        component.find("QuoteRecordCreator").getNewRecord(
            "SBQQ__Quote__c", // sObject type (objectApiName)
            null,      // recordTypeId
            false,     // skip cache?
            $A.getCallback(function() {
                var rec = component.get("v.newQuote");
                var error = component.get("v.newQuoteError");
                if(error || (rec === null)) {                    
                    console.log("Error initializing record template: " + error);
                    return;
                }
                console.log("Record template initialized: " + rec.sobjectType);
            })
        );
    },

    handleSaveQuote: function(component, event, helper) {
            component.set("v.simpleNewQuote.SBQQ__Opportunity2__c", component.get("v.recordId"));
            component.set("v.simpleNewQuote.SBQQ__LineItemsGrouped__c", true);
            component.set("v.simpleNewQuote.SBQQ__Primary__c", true);
            component.find("QuoteRecordCreator").saveRecord(function(saveResult) {
                if (saveResult.state === "SUCCESS" || saveResult.state === "DRAFT") {
                    // record is saved successfully
                    var resultsToast = $A.get("e.force:showToast");
                    resultsToast.setParams({
                        "type": 'success',    
                        "title": "Saved",
                        "message": "The new quote has been created."
                    });
                    resultsToast.fire();
                    helper.navigateTo(component, saveResult.recordId);


                } else if (saveResult.state === "INCOMPLETE") {
                    // handle the incomplete state
                    console.log("User is offline, device doesn't support drafts.");
                } else if (saveResult.state === "ERROR") {
                    // handle the error state
                    var errors = "";
                    for (var i = 0; saveResult.error.length > i; i++){
                        errors = errors + saveResult.error[i].message;
                    }                    
                    console.log('Resultado var errors: '+errors);                
                    var resultsToast = $A.get("e.force:showToast");
                    resultsToast.setParams({
                        "type":"error",
                        "title": "Error!",
                        "message": errors                        
                    });
                    resultsToast.fire();
                } else {
                    console.log('Unknown problem, state: ' + saveResult.state + ', error: ' + JSON.stringify(saveResult.error));
                }
            });
    }
})

HELPER:
({
    navigateTo: function(component, recId) {
        var navEvt = $A.get("e.force:navigateToSObject");
        navEvt.setParams({
            "recordId": recId
        });
        navEvt.fire();
    }
    
})

The component appears like this:
User-added image

And I would like to remove the scrollbar.

Can anyone help me?
Hi, this is my Lightning component code:
 
<aura:component implements="force:lightningQuickActionWithoutHeader,force:hasRecordId" access="global">
    
    <!-- Define Attribute-->
    <aura:attribute name="newQuote" type="Object"/>
    <aura:attribute name="simpleNewQuote" type="Object" default="{'sobjectType':'SBQQ__Quote__c', 'SBQQ__EndDate__c':2018-01-01}"/>
    <aura:attribute name="newQuoteError" type="String"/>    
    
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>

    <force:recordData aura:id="QuoteRecordCreator" 
                      layoutType="FULL"
                      targetRecord="{!v.newQuote}"
                      targetFields="{!v.simpleNewQuote}"
                      targetError="{!v.newQuoteError}" />
                      
    <div class="slds-modal__header">
        <h2 class="slds-text-heading--medium">New Quote</h2>
    </div>

    <!-- Display the new quote form -->
    <div class="slds-form_stacked">
        
        <lightning:input aura:id="QuoteField" type="date" name="Notes" label="Offer end date"
                         value="{!v.simpleNewQuote.SBQQ__EndDate__c}"/>
        <lightning:textarea aura:id="QuoteField" name="Notes" label="Additional notes"
                         value="{!v.simpleNewQuote.SBQQ__Notes__c}"/>

        
        <lightning:button label="Create Quote" onclick="{!c.handleSaveQuote}"
                   variant="brand" class="slds-m-top_medium"/>
   </div>

</aura:component>

But when I select a Date, the following error appears:

Uncaught Error in $A.getCallback() [Cannot read property 'SBQQ__EndDate__c' of null]
throws at https://hum.lightning.force.com/auraFW/javascript/1bO4dJePbDnoI-_VdhdsEQ/aura_proddebug.js:31064:9. Caused by: Error in $A.getCallback() [Cannot read property 'SBQQ__EndDate__c' of null]
AttributeSet.set()@https://hum.lightning.force.com/auraFW/javascript/1bO4dJePbDnoI-_VdhdsEQ/aura_proddebug.js:22401:12
componentConstructor.Component.set()@https://hum.lightning.force.com/auraFW/javascript/1bO4dJePbDnoI-_VdhdsEQ/aura_proddebug.js:16854:37
PropertyReferenceValue.set()@https://hum.lightning.force.com/auraFW/javascript/1bO4dJePbDnoI-_VdhdsEQ/aura_proddebug.js:15155:41
AttributeSet.set()@https://hum.lightning.force.com/auraFW/javascript/1bO4dJePbDnoI-_VdhdsEQ/aura_proddebug.js:22402:17
componentConstructor.Component.set()@https://hum.lightning.force.com/auraFW/javascript/1bO4dJePbDnoI-_VdhdsEQ/aura_proddebug.js:16854:37
Object.onNodeValueChange()@https://hum.lightning.force.com/components/lightning/input.js:319:27
Object.eval [as input]()@https://hum.lightning.force.com/libraries/lightning/domLibrary/dom.js:218:33
runSyntheticEvent()@https://hum.lightning.force.com/libraries/lightning/domLibrary/dom.js:128:27
HTMLInputElement.eventListener()@https://hum.lightning.force.com/libraries/lightning/domLibrary/dom.js:131:24


Can anyone tell me how to solve it please?
Hi, I need to capture and show in the page any error that could happens. I have this component:
 
<aura:component implements="force:lightningQuickActionWithoutHeader,force:hasRecordId" access="global">
    
    <!-- Define Attribute-->
    <aura:attribute name="newQuote" type="Object"/>
    <aura:attribute name="simpleNewQuote" type="Object"/>
    <aura:attribute name="newQuoteError" type="String"/>
    
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>

    <force:recordData aura:id="QuoteRecordCreator" 
                      layoutType="FULL"
                      targetRecord="{!v.newQuote}"
                      targetFields="{!v.simpleNewQuote}"
                      targetError="{!v.newQuoteError}" />

</aura:component>

and the controller:
 
handleSaveQuote: function(component, event, helper) {
            component.set("v.simpleNewQuote.SBQQ__Opportunity2__c", component.get("v.recordId"));
            component.set("v.simpleNewQuote.SBQQ__LineItemsGrouped__c", true);
            component.set("v.simpleNewQuote.SBQQ__Primary__c", true);
            component.find("QuoteRecordCreator").saveRecord(function(saveResult) {
                if (saveResult.state === "SUCCESS" || saveResult.state === "DRAFT") {
                    // record is saved successfully
                    var resultsToast = $A.get("e.force:showToast");
                    resultsToast.setParams({
                        "type": 'success',    
                        "title": "Saved",
                        "message": "The new quote has been created."
                    });
                    resultsToast.fire();
                    helper.navigateTo(component, saveResult.recordId);


                } else if (saveResult.state === "INCOMPLETE") {
                    // handle the incomplete state
                    console.log("User is offline, device doesn't support drafts.");
                } else if (saveResult.state === "ERROR") {
                    // handle the error state
                    var resultsToast = $A.get("e.force:showToast");
                    resultsToast.setParams({
                        "type": 'error',    
                        "title": "Not Saved",
                        "message": "The new quote has an error."
                    });
                    resultsToast.fire();
                    helper.navigateTo(component, saveResult.recordId);
                    console.log('Problem saving contact, error: ' + JSON.stringify(saveResult.error));
                } else {
                    console.log('Unknown problem, state: ' + saveResult.state + ', error: ' + JSON.stringify(saveResult.error));
                }
            });
    }
if saveResult.state === "ERROR"  I need to show a message (like in the SUCCESS case) but it can be generic message, I must capture the error.

Could anyone help me please?
 
Hello,

I have a List of Objects, for example:

myList = (Object1, Object2 , Object3, Object4)

where:
Object1.Name = 'NameA',
Object2.Name = 'NameB',
Object3.Name = 'NameA' and
Object4.Name='NameC'

I have to create a List of Names without repeated Names, and also I need a List that counts the number of the elements, in this example:

NonRepeatedNamesList = ('NameA','NameB','NameC');
CounterList = (2,1,1);

Can anybody help me please?




 
Hello, I have this query:

SELECT b.Outstanding_Amount__c
FROM Billing__C b, Contract c
WHERE b.Contract_Number__C = c.ContractNumber
AND  c.AccountId =: cuenta.Id 

(cuenta.Id is the value that I pass)

But i need to do it in SOQL, could anybody help me pease?
 
Hi, this is my Lightning component code:
 
<aura:component implements="force:lightningQuickActionWithoutHeader,force:hasRecordId" access="global">
    
    <!-- Define Attribute-->
    <aura:attribute name="newQuote" type="Object"/>
    <aura:attribute name="simpleNewQuote" type="Object" default="{'sobjectType':'SBQQ__Quote__c', 'SBQQ__EndDate__c':2018-01-01}"/>
    <aura:attribute name="newQuoteError" type="String"/>    
    
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>

    <force:recordData aura:id="QuoteRecordCreator" 
                      layoutType="FULL"
                      targetRecord="{!v.newQuote}"
                      targetFields="{!v.simpleNewQuote}"
                      targetError="{!v.newQuoteError}" />
                      
    <div class="slds-modal__header">
        <h2 class="slds-text-heading--medium">New Quote</h2>
    </div>

    <!-- Display the new quote form -->
    <div class="slds-form_stacked">
        
        <lightning:input aura:id="QuoteField" type="date" name="Notes" label="Offer end date"
                         value="{!v.simpleNewQuote.SBQQ__EndDate__c}"/>
        <lightning:textarea aura:id="QuoteField" name="Notes" label="Additional notes"
                         value="{!v.simpleNewQuote.SBQQ__Notes__c}"/>

        
        <lightning:button label="Create Quote" onclick="{!c.handleSaveQuote}"
                   variant="brand" class="slds-m-top_medium"/>
   </div>

</aura:component>

But when I select a Date, the following error appears:

Uncaught Error in $A.getCallback() [Cannot read property 'SBQQ__EndDate__c' of null]
throws at https://hum.lightning.force.com/auraFW/javascript/1bO4dJePbDnoI-_VdhdsEQ/aura_proddebug.js:31064:9. Caused by: Error in $A.getCallback() [Cannot read property 'SBQQ__EndDate__c' of null]
AttributeSet.set()@https://hum.lightning.force.com/auraFW/javascript/1bO4dJePbDnoI-_VdhdsEQ/aura_proddebug.js:22401:12
componentConstructor.Component.set()@https://hum.lightning.force.com/auraFW/javascript/1bO4dJePbDnoI-_VdhdsEQ/aura_proddebug.js:16854:37
PropertyReferenceValue.set()@https://hum.lightning.force.com/auraFW/javascript/1bO4dJePbDnoI-_VdhdsEQ/aura_proddebug.js:15155:41
AttributeSet.set()@https://hum.lightning.force.com/auraFW/javascript/1bO4dJePbDnoI-_VdhdsEQ/aura_proddebug.js:22402:17
componentConstructor.Component.set()@https://hum.lightning.force.com/auraFW/javascript/1bO4dJePbDnoI-_VdhdsEQ/aura_proddebug.js:16854:37
Object.onNodeValueChange()@https://hum.lightning.force.com/components/lightning/input.js:319:27
Object.eval [as input]()@https://hum.lightning.force.com/libraries/lightning/domLibrary/dom.js:218:33
runSyntheticEvent()@https://hum.lightning.force.com/libraries/lightning/domLibrary/dom.js:128:27
HTMLInputElement.eventListener()@https://hum.lightning.force.com/libraries/lightning/domLibrary/dom.js:131:24


Can anyone tell me how to solve it please?
Hi, I need to capture and show in the page any error that could happens. I have this component:
 
<aura:component implements="force:lightningQuickActionWithoutHeader,force:hasRecordId" access="global">
    
    <!-- Define Attribute-->
    <aura:attribute name="newQuote" type="Object"/>
    <aura:attribute name="simpleNewQuote" type="Object"/>
    <aura:attribute name="newQuoteError" type="String"/>
    
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>

    <force:recordData aura:id="QuoteRecordCreator" 
                      layoutType="FULL"
                      targetRecord="{!v.newQuote}"
                      targetFields="{!v.simpleNewQuote}"
                      targetError="{!v.newQuoteError}" />

</aura:component>

and the controller:
 
handleSaveQuote: function(component, event, helper) {
            component.set("v.simpleNewQuote.SBQQ__Opportunity2__c", component.get("v.recordId"));
            component.set("v.simpleNewQuote.SBQQ__LineItemsGrouped__c", true);
            component.set("v.simpleNewQuote.SBQQ__Primary__c", true);
            component.find("QuoteRecordCreator").saveRecord(function(saveResult) {
                if (saveResult.state === "SUCCESS" || saveResult.state === "DRAFT") {
                    // record is saved successfully
                    var resultsToast = $A.get("e.force:showToast");
                    resultsToast.setParams({
                        "type": 'success',    
                        "title": "Saved",
                        "message": "The new quote has been created."
                    });
                    resultsToast.fire();
                    helper.navigateTo(component, saveResult.recordId);


                } else if (saveResult.state === "INCOMPLETE") {
                    // handle the incomplete state
                    console.log("User is offline, device doesn't support drafts.");
                } else if (saveResult.state === "ERROR") {
                    // handle the error state
                    var resultsToast = $A.get("e.force:showToast");
                    resultsToast.setParams({
                        "type": 'error',    
                        "title": "Not Saved",
                        "message": "The new quote has an error."
                    });
                    resultsToast.fire();
                    helper.navigateTo(component, saveResult.recordId);
                    console.log('Problem saving contact, error: ' + JSON.stringify(saveResult.error));
                } else {
                    console.log('Unknown problem, state: ' + saveResult.state + ', error: ' + JSON.stringify(saveResult.error));
                }
            });
    }
if saveResult.state === "ERROR"  I need to show a message (like in the SUCCESS case) but it can be generic message, I must capture the error.

Could anyone help me please?
 
Hello,

I have a List of Objects, for example:

myList = (Object1, Object2 , Object3, Object4)

where:
Object1.Name = 'NameA',
Object2.Name = 'NameB',
Object3.Name = 'NameA' and
Object4.Name='NameC'

I have to create a List of Names without repeated Names, and also I need a List that counts the number of the elements, in this example:

NonRepeatedNamesList = ('NameA','NameB','NameC');
CounterList = (2,1,1);

Can anybody help me please?




 
Hello, I have this query:

SELECT b.Outstanding_Amount__c
FROM Billing__C b, Contract c
WHERE b.Contract_Number__C = c.ContractNumber
AND  c.AccountId =: cuenta.Id 

(cuenta.Id is the value that I pass)

But i need to do it in SOQL, could anybody help me pease?