• GGill31
  • NEWBIE
  • 10 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 6
    Replies
The Einstein Chatbot header has default greeting text as "Hello Guest! An agent is on the way. And this text on header is white in color. I want to change it into a different color, probably darker color. Also, by default it has End Chat button on the header, how to remove that button from there ?
I have a Master aura component containing 2 buttons to open another aura component - 1 for each button in the master component. I'm transferring the control using the Application Events from master component to the child component using the below code:

**MasterComponent.cmp:**
```
<aura:component implements = "flexipage:availableForAllPageTypes, flexipage:availableForRecordHome, force:hasRecordId" access = "global">
    <aura:attribute name = "recordId" type = "Id"/>
    <aura:registerEvent name = "SubmitCandidateEvent" type = "c:SubmitCandidateEvent"/>
    <aura:registerEvent name = "SubmissionConfirmationEvent" type = "c:SubmissionConfirmationEvent"/>
    <div>
        <lightning:button type = "button" iconName = "utility:text_template" variant = "brand" label = "Submission Confirmation Email" title = "Submission Confirmation Email" onclick = "{!c.submissionConfirmation}"/>
        <lightning:button type = "button" iconName = "utility:text_template" variant = "brand" label = "Submit Candidate" title = "Submission Confirmation Email" onclick = "{!c.submitCandidate}"/>
    </div>
</aura:component>
```
**MasterComponent.js**
```
({
    submissionConfirmation : function(component, event, helper) {
        console.log("Inside Submission Confirmation Master Component Controller");
        var submissionConfirmationEvent = $A.get("e.c:SubmissionConfirmationEvent");
        submissionConfirmationEvent.setParams({"submissionStatus":"SubmissionComponent"});
        console.log("SubmissionConfirmationEvent: "+submissionConfirmationEvent);
        submissionConfirmationEvent.fire();
        console.log("SubmissionConfirmationEvent fired");
    },
    
    submitCandidate : function(component, event, helper) {
        console.log("Inside Submit Candidate Master Submit Controller");
        var submitCandidateEvent = $A.get("e.c:SubmitCandidateEvent");
        submitCandidateEvent.setParams({"submitStatus" : "SubmitComponent"});
        console.log("SubmitCandidateEvent: "+submitCandidateEvent);
        submitCandidateEvent.fire();
        console.log("SubmitCandidateEvent fired");
    },
})
```
**SubmitCandidateEvent.evt**
```
<aura:event type="APPLICATION" description="Event template" >
    <aura:attribute name = "submitStatus" type = "String" />
</aura:event>
```
**SubmissionConfirmationEvent.evt**
```
<aura:event type="APPLICATION" description="Event template" >
    <aura:attribute name = "submissionStatus" type = "String" />
</aura:event>
```
**SubmitCandidateComponent.cmp**
```
<aura:component controller = "SubmitCandidateController" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome" access="global">
    <aura:attribute name="recordId" type="String"/>
    <aura:attribute name="open" type="Boolean" default="false"/>
    <aura:attribute name = "isOpen" type = "Boolean" default = "false"/>
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
    <aura:handler event = "c:SubmitCandidateEvent" action = "{!c.openSubmitCandidate}"/>
    
    <aura:if isTrue = "{!v.isOpen}" >
        //doSomething
    </aura:if>
</aura:component>
```
**SubmitCandidateComponent.js**
```
({ openSubmitCandidate : function(component, event, helper) {
        console.log("In Submit Candidate Controller: Setting the open attribute");
        component.set("v.isOpen", true);
        var source = event.getSource();
        console.log("Source: "+source);
        var evt = $A.get("e.c:SubmitCandidateEvent");
        console.log("Submit Candidate Event: "+evt);
        var evtParam = evt.getParam("submitStatus");
        console.log("Event Param: "+evtParam);  
        alert(evtParam);
        var init = component.get("c.doInit");
        $A.enqueueAction(init);     
    },
})
```
**SubmissionConfirmationComponent.cmp**
```
<aura:component controller="SubmissionConfirmationEmailJobApplicant" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId" access="global" >
    <aura:attribute name="recordId" type="Id"/>
    <aura:attribute name="open" type="Boolean" default="false"/>
    <aura:attribute name = "isOpen" type = "Boolean" default = "false"/>

    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
    <aura:handler event = "c:SubmissionConfirmationEvent" action = "{!c.openSubmissionConfirmation}"/>
    
    <aura:if isTrue = "{!v.isOpen}" >
    //doSomething
    </aura:if>
</aura:component>
```
**SubmissionConfirmationComponent.js**
```

 ({ openSubmissionConfirmation : function(component, event, helper) {
        console.log("In Submission Confirmation Controller: Setting up the open attribute");
        component.set("v.isOpen", true);
        var source = event.getSource();
        console.log("Source: "+source);
        var evt = $A.get("e.c:SubmissionConfirmationEvent");
        console.log("Submission Confirmation Event: "+evt);
        var evtParam = evt.getParam("submissionStatus");
        console.log("Event Param: "+evtParam);
        alert(evtParam);
        var init = component.get("c.doInit");
        $A.enqueueAction(init);
    },
})
```

I can see the events being fired when the buttons are clicked. But I can't see the flow moving to the handler component. Handler code in the SubmitCandidateComponent and SubmissionConfirmationComponent not getting invoked, hence the application event handler not working as it should do. Kindly suggest what can be wrong in this code, its been hours I'm stuck on this piece of code. 
Thanks!
Hi, 
I am a beginner in lightning components. I have a requirement to preview an email before sending it to users, contacts through Lightning aura components. I am trying to pre populate the email body with the HTMLEmailTemplate body text. I am querying the EmailTemplate object (et) to fetch the id, subject, body and passing that template id, body in the Messaging.SingleEmailMessage.setTemplateId(et.Id), Messaging.SingleEmailMessage.setSubject(et.Subject), Messaging.SingleEmailMessage.setBody(et.Body). It does not pre populate the Subject and Body content from the template into the component (can't see it). However, it sends the email with the template subject and body (when I check the email just received, it has the template content). My query is how can i pre populate the template content so that I can visualize it before sending and I can add something(customize) into it, if I want to.  Any help would be appreciated. Thanks.
I have a custom Borrow, Item and Employee object. The following code has the purpose of taking in the autonumber Employee ID and string Barcode ID from the user and as soon as user presses enter key, it should save the record in the Borrow database. I tested the controller code seprately in the execute anonymous code wiindow, it is able to create the record in the database. And the visualforce page is running fine too, as its displaying the barcodeId in the output text field 
<apex:outputText id="out" value="{!barcodeId}"></apex:outputText> 
once user inputs the Barcode ID in the text field and presses the enter key. If the apex method was not called properly then this output text field would have not populated as it is getting populated from {!barcodeId} (apex controller field). But its giving me an query exception.
System.QueryException: List has no rows for assignment to SObject
Error is in expression '{!createBorrowRecord}' in page checkoutitems: Class.BorrowController.createBorrowRecord: line 9, column 1
Class.BorrowController.createBorrowRecord: line 9, column 1

which is the query for retrieving employee record.
I'm unsure where can the problem be ? 
Your help will be highly appreciated.

Controller
public class BorrowController {
    
    public String barcodeId {get; set;}
    public String employeeId {get; set;}
    
    public void createBorrowRecord() {
        try {
            Item__c item = [SELECT Id, Item_ID__c, Barcode_ID__c FROM Item__c WHERE Barcode_ID__c =:barcodeId LIMIT 1];
            Employee__c emp = [SELECT Id, Name, Employee_ID__c FROM Employee__c WHERE Employee_ID__c =:employeeId LIMIT 1];
            Borrow__c b = new Borrow__c();
            b.Name = item.Name + 'Borrow';
            b.Item_Name__c = item.Id;
            b.Employee_Name__c = emp.Id;
        
            insert b;
        }
        catch(DmlException e) {
            System.debug('The following error has occured'+ e.getMessage());
        }
        
    }
}

Visualforce Page
<apex:page controller="BorrowController" showHeader="false" applyHtmlTag="false" applyBodyTag="false" docType="Html-5.0">  
    <apex:form >
        <apex:actionFunction action="{!createBorrowRecord}" name="createBorrow" reRender="out">
            <apex:param name="barcode" value="" assignTo="{!barcodeId}"/>
            <apex:param name="employee" value="" assignTo="{!employeeId}"/>
        </apex:actionFunction>
    </apex:form>
    <apex:outputText id="out" value="{!barcodeId}"></apex:outputText>
    <apex:outputText id="out1" value="{!employeeId}"></apex:outputText>
    
    <html>
        <head>
            <title>Checkout Items</title>
        </head>
        <body>
            <br />
            <label for = "employeeId">Employee ID: </label>
            <input type = "text" id = "employeeId" />
            <br />
            <br />
            <label for = "barcodeText">Enter Barcode ID: </label>
            <input type = "text" id = "barcodeText" />
            <br />
            <span id = "addedItems"/>
            
            <script type = "text/javascript">
                var barcodeText = document.getElementById("barcodeText");
                var empId = document.getElementById("employeeId")
                var items = document.getElementById("addedItems");
                var completeText = "";
                barcodeText.addEventListener("keydown", function(e) {
                    if(e.which != 13) {
                        if(e.which >= 48 && e.which <= 57 || e.which >= 65 && e.which <= 90) {
                        console.log("Inside If-Block");
                        completeText = completeText + e.key;   
                        }
                        else {
                        console.log("Invalid Key");
                        outputText.innerHTML = "Invalid Key Pressed"; 
                        barcodeText.value = "";
                        }
                  }
                    else {
                        console.log("Inside Else-Block");
                        items.innerHTML = completeText;
                        console.log("Calling Apex Method:");
                        createBorrow(completeText, empId);
                        console.log("Done calling apex method:");
                        barcodeText.value = "";
                        completeText = "";
                    }
                });
            </script>
        </body>
    </html>

Regards,
Gill
Hi There,
I'm trying to input multiple Barcode_ID's for given Item object for a given employee. The visualforce page requires an employee to input their Employee_ID and enter multiple Barcode_ID's (taking in multiple keyboard keys until enter is hit for every barcode id). The Borrow Object has lookup relationship with Employee and Item objects on Employee_ID and Item_ID autonumber fields from Employee and Item object respectively. On executing the following code, its giving me the following error
'System.NullPointerException: Attempt to de-reference a null object'
Error is in expression '{!insertRecord}' in component <apex:commandButton> in page checkoutitems: Class.BorrowController.createBorrowRecord: line 10, column 1
Class.BorrowController.insertRecord: line 38, column 1

This is my code:
 Visualforce page - Checkout.vfp
<apex:page controller="BorrowController" showHeader="false" applyHtmlTag="false" applyBodyTag="false" docType="html-5.0">
    <html>
        <head>
            <body>
                <apex:pageBlock >
                    <apex:pageBlockSection >
                        <label for = "employeeIDText">Employee ID: </label>
                        <input type = "text" id = "employeeIDText" value = "{!employee_ID}"/>
                    </apex:pageBlockSection>
                    <apex:pageBlockSection >
                        <label for = "inputText">Barcode ID:</label>
                        <input type = "text" id = "inputText"/>
                    </apex:pageBlockSection>
                    <apex:pageBlockSection >
                        <span id = "outputText"/>
                    </apex:pageBlockSection>
                    <apex:pageBlockSection >
                        <span id="addedItems"/>
                        <br />
                        <input type = "hidden" id = "hiddenItems" value = "{!barcodeList}"/>
                    </apex:pageBlockSection>
                </apex:pageBlock>
                <apex:form >
                    <apex:commandButton action="{!insertRecord}" value="Checkout" id="checkoutBtn">
                    </apex:commandButton>
                        
                </apex:form>
            </body>
            <script type = "text/javascript">
                var inputText = document.getElementById("inputText");
                var completeText = "";
                var arrayItems = [];
                var items = "";
                var hiddenItems = document.getElementById("hiddenItems");
                inputText.addEventListener("keydown", function(e) {
                console.log("Inside Event");
                if(e.which!=13) {
                    if(e.which >= 48 && e.which <= 57 || e.which >= 65 && e.which <= 90) {
                        console.log("Inside If-Block");
                        completeText = completeText + e.key;
                    }
                    else {
                        console.log("Invalid Key");
                        outputText.innerHTML = "Invalid Key Pressed";
                        inputText.value = "";
                    }
                    
                }
                else {   
                    arrayItems.push(completeText);
                    items = items + completeText + ",";
                    addedItems.innerHTML = items;
                    hiddenItems.value = items;
                    console.log("Inside Else-Block");
                    outputText.innerHTML = completeText;
                    inputText.value = "";
                    completeText = "";
                }
                console.log("Item Elements:");
                for(var i = 0; i < arrayItems.length; i++) {
                    console.log(i+": "+arrayItems[i]);
                }
        });
            </script>
        </head>
    </html>
</apex:page>

Controller - BorrowController.apex
public class BorrowController {
    public String employee_ID {get; set;}
    public String borrow_ID {get; set;}
    public String barcodeList{get; set;}
    
    public BorrowController() {}
    
    public void createBorrowRecord() {
        List<String> barcodeItems = barcodeList.split(',');
        System.debug('barcodeItems:'+barcodeItems);
        List<Item__c> itemList = new List<Item__c>();
        for(Integer i = 0; i < barcodeItems.size(); i++) {
            System.debug('Inside for loop');
            itemList = [SELECT Name, Item_ID__c, Price__c, Status__c FROM Item__c WHERE Barcode_ID__c =: barcodeItems[i]];
        }
        
        for(Item__c item: itemList) {
            if(item != null) {
            Borrow__c b = new Borrow__c();
            System.debug('Borrow Item initialised');
            b.Employee_ID__c = employee_ID;
            b.Item_ID__c = item.Item_ID__c;
            b.Barcode_ID__c = item.Barcode_ID__c;
            b.Item_Price__c = item.Price__c;
            borrow_ID = b.Borrow_ID__c;
            System.debug(b.Employee_ID__c +', '+b.Item_ID__c+', '+b.Barcode_ID__c+', '+b.Item_Price__c+', '+borrow_ID);
            insert b;
        }
      }
        
        
        
    }
    
    public PageReference insertRecord() {
        System.debug('Inside Page Reference: insertRecord()');
        createBorrowRecord();
        return new PageReference('/'+ borrow_ID);  
    }

}

Its also giving me a StringException for Employee_ID and Item_ID while inserting in Borrow object. The Employee_ID and Item_ID in respective objects are autonumber field beginning with E-{0001} and I-{0001}. My requirement is to get the user entered Barcode_ID's with Item's Barcode_ID to get information about other fields of Item object, and if its a match and corresponding item record is found, it should create a borrow object record. I'm unsure if the field values from form are correctly passed to the controller or not. I don't know how to pass these field values to the controller.

Any help would be greatly appreciated.

Thanks and Regards,
Gill
 
Hi there,

What can be possible problem in the following code ? Its giving me unexpected token on barcodeID.
My requirement is to fetch the record from Item custom object on the basis of the Barcode_ID and populate the Borrow custom object record using the information from Item object. Borrow object has lookup relationship with Item object. The values for barcode_id and employee_id are coming from the visualforce page.

public class BorrowController {
    public String employeeID {get; set;}
    public String barcodeID {get; set;}
    
    public BorrowController(){}
    
    public void createBorrowRecord() {
        Item__c item = [SELECT Name, Item_ID__c, Price__c, Status__c from Item__c where Barcode_ID__c = barcodeID];
        if(item != null) {
            Borrow__c b = new Borrow__c();
            b.Employee_ID__c = employeeID;
            b.Item_ID__c = item.Item_ID__c;
            b.Barcode_ID__c = barcodeID;
            b.Item_Price__c = item.Price__c;
        
            b.insert;
        }
        
    }
    
    public PageReference recordCreation() {
        createBorrowRecord();
    }
}

Any help would be greatly appreciated!
The Einstein Chatbot header has default greeting text as "Hello Guest! An agent is on the way. And this text on header is white in color. I want to change it into a different color, probably darker color. Also, by default it has End Chat button on the header, how to remove that button from there ?
I have a Master aura component containing 2 buttons to open another aura component - 1 for each button in the master component. I'm transferring the control using the Application Events from master component to the child component using the below code:

**MasterComponent.cmp:**
```
<aura:component implements = "flexipage:availableForAllPageTypes, flexipage:availableForRecordHome, force:hasRecordId" access = "global">
    <aura:attribute name = "recordId" type = "Id"/>
    <aura:registerEvent name = "SubmitCandidateEvent" type = "c:SubmitCandidateEvent"/>
    <aura:registerEvent name = "SubmissionConfirmationEvent" type = "c:SubmissionConfirmationEvent"/>
    <div>
        <lightning:button type = "button" iconName = "utility:text_template" variant = "brand" label = "Submission Confirmation Email" title = "Submission Confirmation Email" onclick = "{!c.submissionConfirmation}"/>
        <lightning:button type = "button" iconName = "utility:text_template" variant = "brand" label = "Submit Candidate" title = "Submission Confirmation Email" onclick = "{!c.submitCandidate}"/>
    </div>
</aura:component>
```
**MasterComponent.js**
```
({
    submissionConfirmation : function(component, event, helper) {
        console.log("Inside Submission Confirmation Master Component Controller");
        var submissionConfirmationEvent = $A.get("e.c:SubmissionConfirmationEvent");
        submissionConfirmationEvent.setParams({"submissionStatus":"SubmissionComponent"});
        console.log("SubmissionConfirmationEvent: "+submissionConfirmationEvent);
        submissionConfirmationEvent.fire();
        console.log("SubmissionConfirmationEvent fired");
    },
    
    submitCandidate : function(component, event, helper) {
        console.log("Inside Submit Candidate Master Submit Controller");
        var submitCandidateEvent = $A.get("e.c:SubmitCandidateEvent");
        submitCandidateEvent.setParams({"submitStatus" : "SubmitComponent"});
        console.log("SubmitCandidateEvent: "+submitCandidateEvent);
        submitCandidateEvent.fire();
        console.log("SubmitCandidateEvent fired");
    },
})
```
**SubmitCandidateEvent.evt**
```
<aura:event type="APPLICATION" description="Event template" >
    <aura:attribute name = "submitStatus" type = "String" />
</aura:event>
```
**SubmissionConfirmationEvent.evt**
```
<aura:event type="APPLICATION" description="Event template" >
    <aura:attribute name = "submissionStatus" type = "String" />
</aura:event>
```
**SubmitCandidateComponent.cmp**
```
<aura:component controller = "SubmitCandidateController" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome" access="global">
    <aura:attribute name="recordId" type="String"/>
    <aura:attribute name="open" type="Boolean" default="false"/>
    <aura:attribute name = "isOpen" type = "Boolean" default = "false"/>
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
    <aura:handler event = "c:SubmitCandidateEvent" action = "{!c.openSubmitCandidate}"/>
    
    <aura:if isTrue = "{!v.isOpen}" >
        //doSomething
    </aura:if>
</aura:component>
```
**SubmitCandidateComponent.js**
```
({ openSubmitCandidate : function(component, event, helper) {
        console.log("In Submit Candidate Controller: Setting the open attribute");
        component.set("v.isOpen", true);
        var source = event.getSource();
        console.log("Source: "+source);
        var evt = $A.get("e.c:SubmitCandidateEvent");
        console.log("Submit Candidate Event: "+evt);
        var evtParam = evt.getParam("submitStatus");
        console.log("Event Param: "+evtParam);  
        alert(evtParam);
        var init = component.get("c.doInit");
        $A.enqueueAction(init);     
    },
})
```
**SubmissionConfirmationComponent.cmp**
```
<aura:component controller="SubmissionConfirmationEmailJobApplicant" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId" access="global" >
    <aura:attribute name="recordId" type="Id"/>
    <aura:attribute name="open" type="Boolean" default="false"/>
    <aura:attribute name = "isOpen" type = "Boolean" default = "false"/>

    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
    <aura:handler event = "c:SubmissionConfirmationEvent" action = "{!c.openSubmissionConfirmation}"/>
    
    <aura:if isTrue = "{!v.isOpen}" >
    //doSomething
    </aura:if>
</aura:component>
```
**SubmissionConfirmationComponent.js**
```

 ({ openSubmissionConfirmation : function(component, event, helper) {
        console.log("In Submission Confirmation Controller: Setting up the open attribute");
        component.set("v.isOpen", true);
        var source = event.getSource();
        console.log("Source: "+source);
        var evt = $A.get("e.c:SubmissionConfirmationEvent");
        console.log("Submission Confirmation Event: "+evt);
        var evtParam = evt.getParam("submissionStatus");
        console.log("Event Param: "+evtParam);
        alert(evtParam);
        var init = component.get("c.doInit");
        $A.enqueueAction(init);
    },
})
```

I can see the events being fired when the buttons are clicked. But I can't see the flow moving to the handler component. Handler code in the SubmitCandidateComponent and SubmissionConfirmationComponent not getting invoked, hence the application event handler not working as it should do. Kindly suggest what can be wrong in this code, its been hours I'm stuck on this piece of code. 
Thanks!
Hi, 
I am a beginner in lightning components. I have a requirement to preview an email before sending it to users, contacts through Lightning aura components. I am trying to pre populate the email body with the HTMLEmailTemplate body text. I am querying the EmailTemplate object (et) to fetch the id, subject, body and passing that template id, body in the Messaging.SingleEmailMessage.setTemplateId(et.Id), Messaging.SingleEmailMessage.setSubject(et.Subject), Messaging.SingleEmailMessage.setBody(et.Body). It does not pre populate the Subject and Body content from the template into the component (can't see it). However, it sends the email with the template subject and body (when I check the email just received, it has the template content). My query is how can i pre populate the template content so that I can visualize it before sending and I can add something(customize) into it, if I want to.  Any help would be appreciated. Thanks.
Hi there,

What can be possible problem in the following code ? Its giving me unexpected token on barcodeID.
My requirement is to fetch the record from Item custom object on the basis of the Barcode_ID and populate the Borrow custom object record using the information from Item object. Borrow object has lookup relationship with Item object. The values for barcode_id and employee_id are coming from the visualforce page.

public class BorrowController {
    public String employeeID {get; set;}
    public String barcodeID {get; set;}
    
    public BorrowController(){}
    
    public void createBorrowRecord() {
        Item__c item = [SELECT Name, Item_ID__c, Price__c, Status__c from Item__c where Barcode_ID__c = barcodeID];
        if(item != null) {
            Borrow__c b = new Borrow__c();
            b.Employee_ID__c = employeeID;
            b.Item_ID__c = item.Item_ID__c;
            b.Barcode_ID__c = barcodeID;
            b.Item_Price__c = item.Price__c;
        
            b.insert;
        }
        
    }
    
    public PageReference recordCreation() {
        createBorrowRecord();
    }
}

Any help would be greatly appreciated!