• Khalid mn
  • NEWBIE
  • 9 Points
  • Member since 2021

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 3
    Replies
Hi, 
I want some idea to create custom chatbot using lwc the requirement is just need a simple chatbot for practice purpose. using of js and html without any integration and einstine bot..

Thank You
Hi,
I have a scenario where if we insert two account at a time with same phone no then delete one account..
I tried below Trigger but there problem is if i am inserting one account with existing account phone no then it is working fine but on the insertion of two account it's not working...
can someone please help me...
trigger DelOneAcc on Account (before insert) {  
    // Here i am storing phone of account into set
    Set <String> phoneSet = new Set<String>();      
    // Iterate through each Account and add their phone number to their respective Sets   
    for (Account Acc:trigger.new) {        
        phoneSet.add(Acc.phone);         
    }      
    // New list to store the found phone numbers  
    List <Account> AccList = new List<Account>();      
        
    AccList = [Select Id, Name, Phone from account WHERE phone IN :phoneSet];     
    // Iterating through each account record to see if the same phone was found     
    for (Account Acc:AccList) {        
        If (AccList.size() > 1) {                             
        }  
    }   
    delete AccList; 
}
Thank You in Advance
 
Hi, 
I have a requirement can someone help me out..
 on toggle when i click then one modal will opne on modal there will a save and cancel button whn i click cancel then toggle will be inactive when i click save toggle will be active..
User-added image
 
Hi Community, 
I have a Trigger..
The logic is fetch Business Market's Field for Opportunity . when i update Business Market field them also Update Opportunity Fields. Opportunity is Lookup to Business Market.
and Also  i want that when i create any new Opportunity by selecting Business  Market field on opportunity then fetch Business Market fields also 
Code is below...

 
trigger BusinessMarketTrigger on Business_Market__c (after Update, before Insert) {
    if((Trigger.isAfter && Trigger.isUpdate) || (Trigger.isBefore && Trigger.isInsert)){
        BusinessMarketTriggerHandler.updateOwner(Trigger.new);
    }
}
 
public class BusinessMarketTriggerHandler {
    public static void updateOwner(List<Business_Market__c> bsnsList){
        List<Opportunity> oppIds = [SELECT OwnerId,Business_Market__c,Account_Dircetor__c,Advisory_Lead__c 
                                    ,Business_Market__r.Business_Lead__r.Name,Business_Market__r.Delivery_Lead__r.Name,
                                    Business_Market__r.Sr_Delivery_Lead__r.Name,Business_Market__r.Advisory_Lead__r.Name,
                                    Business_Market__r.Account_Dircetor__r.Name
                                    FROM Opportunity 
                                    WHERE Business_Market__c IN : Trigger.newMap.KeySet()];
        List<Opportunity> oppList = New List<Opportunity>();   
        for(Opportunity opp : oppIds){
            if(opp.Business_Market__c !=Null){
                opp.OwnerId = opp.Business_Market__r.Business_Lead__c;
                opp.Account_Dircetor__c = opp.Business_Market__r.Account_Dircetor__r.Name;
                opp.Advisory_Lead__c = opp.Business_Market__r.Advisory_Lead__r.Name;
                opp.Sr_Delivery_Lead__c = opp.Business_Market__r.Sr_Delivery_Lead__r.Name;
                opp.Delivery_Lead__c = opp.Business_Market__r.Delivery_Lead__r.Name;
                oppList.add(opp);
                
            }
        }
        update oppList;
    }
}

Thank You In Advance
Hi,
i have create a custome Lookup which show contact related to account for single pick only i want that after search when i click on contact that show in below table and if i search again and click on that contact that should also show into to table below.....
how can i do this...
Please help to do this...
apex....
public class CustomLookUpController {
    
    @AuraEnabled
    public static List<SObJectResult> getResults(String ObjectName, String fieldName, String value,Id recordId) {
        List<SObJectResult> sObjectResultList = new List<SObJectResult>();
        for(sObject so : Database.Query('Select Id,'+fieldName+' FROM '+ObjectName+' WHERE '+fieldName+'  LIKE \'%' + value + '%\' AND AccountId=:recordId ')) {
            String fieldvalue = (String)so.get(fieldName);
            sObjectResultList.add(new SObjectResult(fieldvalue, so.Id));
        }
        
        return sObjectResultList;
    }
    
    public class SObJectResult {
        @AuraEnabled
        public String recName;
        @AuraEnabled
        public Id recId;
        
        public SObJectResult(String recNameTemp, Id recIdTemp) {
            recName = recNameTemp;
            recId = recIdTemp;
        }
    }
}
 
<aura:component controller="CustomLookUpController" 
                implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,force:lightningQuickAction" access="global">
    <aura:attribute name="objectName" type="String" default="Contact"/>
    <aura:attribute name="fieldName" type="String" default="Name"/>
    <aura:attribute name="recordId" type="Id" />
    <aura:attribute name="selectRecordId" type="String"/>
    <aura:attribute name="selectRecordName" type="String"/>
    <aura:attribute name="Label" type="String"/>
    <aura:attribute name="searchRecords" type="List"/>
    <aura:attribute name="required" type="Boolean" default="false"/>
    <aura:attribute name="iconName" type="String" default="action:new_contact"/>
    <aura:attribute name="LoadingText" type="Boolean" default="false"/>
    <div>
        <div class="slds-form-element">
            
            <div class="slds-form-element__control">
                <div class="slds-combobox_container">
                    
                    <div class="slds-combobox slds-dropdown-trigger slds-dropdown-trigger_click" aura:id="resultBox" aria-expanded="false" aria-haspopup="listbox" role="combobox">
                        <div class="slds-form-element__control slds-input-has-icon slds-input-has-icon slds-input-has-icon_left-right" role="none">
                            
                            <aura:if isTrue="{!!empty(v.selectRecordId)}">
                                <span class="slds-icon_container slds-icon-utility-search slds-input__icon iconheight">
                                    <lightning:icon class="slds-icon slds-icon slds-icon_small slds-icon-text-default" iconName="{!v.iconName}" size="x-small" alternativeText="icon" />
                                </span> 
                            </aura:if>
                            <lightning:input required="{!v.required}" aura:id="userinput" label="{!v.Label}" name="searchText" onchange="{!c.searchField}" value="{!v.selectRecordName}" class="leftspace"/> 
                            <aura:if isTrue="{!empty(v.selectRecordId)}">
                                <span class="slds-icon_container slds-icon-utility-search slds-input__icon slds-input__icon_right iconheight">
                                    <lightning:icon class="slds-icon slds-icon slds-icon_small slds-icon-text-default" iconName="utility:search" size="x-small" alternativeText="icon" />
                                </span> 
                                <aura:set attribute="else">
                                    <button class="slds-input__icon slds-input__icon_right slds-button slds-button_icon iconheight" onclick="{!c.resetData}">
                                        <lightning:icon class="slds-icon slds-icon slds-icon_small slds-icon-text-default" iconName="utility:clear" size="x-small" alternativeText="icon" />
                                        <span class="slds-assistive-text">Clear</span></button>
                                </aura:set>
                            </aura:if>
                        </div>
                        
                        <!-- Second part display result -->
                        <div id="listbox-id-1" class="slds-dropdown slds-dropdown_length-with-icon-7 slds-dropdown_fluid" role="listbox">
                            <ul class="slds-listbox slds-listbox_vertical" role="presentation">
                                <aura:iteration items="{!v.searchRecords}" var="serecord" indexVar="hdtv">
                                    <li role="presentation" class="slds-listbox__item">
                                        
                                       <div id="{!serecord.recId}" data-name="{!serecord.recName}" onclick="{!c.setSelectedRecord}" class="slds-media slds-listbox__option slds-listbox__option_entity slds-listbox__option_has-meta" role="option">
                                            <span class="slds-media__figure">
                                                <span class="slds-icon_container slds-icon-standard-contact">
                                                    <lightning:icon iconName="{!v.iconName}" class="slds-icon slds-icon slds-icon_small slds-icon-text-default" size="x-small"/>
                                                </span>
                                            </span>
                                            <span class="slds-media__body">
                                                <span class="slds-listbox__option-text slds-listbox__option-text_entity">{!serecord.recName}</span>
                                                <span class="slds-listbox__option-meta slds-listbox__option-meta_entity">{!v.objectName} • {!serecord.recName}</span>
                                            </span> 
                                        </div>
                                    </li>
                                </aura:iteration>
                                <aura:if isTrue="{!and(v.searchRecords.length == 0 , !v.LoadingText)}">
                                    No result found.
                                </aura:if>
                                <aura:if isTrue="{!v.LoadingText}">
                                    Loading...
                                </aura:if>
                            </ul>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    
</aura:component>
 
({
    searchField : function(component, event, helper) {
        var currentText = event.getSource().get("v.value");
        var resultBox = component.find('resultBox');
        component.set("v.LoadingText", true);
        if(currentText.length > 0) {
            $A.util.addClass(resultBox, 'slds-is-open');
        }
        else {
            $A.util.removeClass(resultBox, 'slds-is-open');
        }
        var action = component.get("c.getResults");
        action.setParams({
            recordId: component.get("v.recordId"),
            "ObjectName" : component.get("v.objectName"),
            "fieldName" : component.get("v.fieldName"),
            "value" : currentText
            
        });
        
        action.setCallback(this, function(response){
            var STATE = response.getState();
            if(STATE === "SUCCESS") {
                component.set("v.searchRecords", response.getReturnValue());
                if(component.get("v.searchRecords").length == 0) {
                    console.log('000000');
                }
            }
            else if (state === "ERROR") {
                var errors = response.getError();
                if (errors) {
                    if (errors[0] && errors[0].message) {
                        console.log("Error message: " + 
                                    errors[0].message);
                    }
                } else {
                    console.log("Unknown error");
                }
            }
            component.set("v.LoadingText", false);
        });
        
        $A.enqueueAction(action);
    },
    
    setSelectedRecord : function(component, event, helper) {
        var currentText = event.currentTarget.id;
        var resultBox = component.find('resultBox');
        $A.util.removeClass(resultBox, 'slds-is-open');
        //component.set("v.selectRecordName", currentText);
        component.set("v.selectRecordName", event.currentTarget.dataset.name);
        component.set("v.selectRecordId", currentText);
        component.find('userinput').set("v.readonly", true);
    }, 
    
    resetData : function(component, event, helper) {
        component.set("v.selectRecordName", "");
        component.set("v.selectRecordId", "");
        component.find('userinput').set("v.readonly", false);
    }
})

 
Hi, Community
can someone help me to create search bar which will only display that contact which is related to account. after search when i click that contact contact details should show bellow..
please help me to do this
Hi,
I have a scenario where if we insert two account at a time with same phone no then delete one account..
I tried below Trigger but there problem is if i am inserting one account with existing account phone no then it is working fine but on the insertion of two account it's not working...
can someone please help me...
trigger DelOneAcc on Account (before insert) {  
    // Here i am storing phone of account into set
    Set <String> phoneSet = new Set<String>();      
    // Iterate through each Account and add their phone number to their respective Sets   
    for (Account Acc:trigger.new) {        
        phoneSet.add(Acc.phone);         
    }      
    // New list to store the found phone numbers  
    List <Account> AccList = new List<Account>();      
        
    AccList = [Select Id, Name, Phone from account WHERE phone IN :phoneSet];     
    // Iterating through each account record to see if the same phone was found     
    for (Account Acc:AccList) {        
        If (AccList.size() > 1) {                             
        }  
    }   
    delete AccList; 
}
Thank You in Advance
 
how can apply CSS on LWC component?

I want to hide the default save and cancel buttons
User-added image
with css but I  get this error: 

LWC1503: Parsing error: /home/sfdc/tools/lwc/2.2.9-234.6/cases.js: Only one default export allowed per module. (31:0) (31:0)

User-added imageI don´t know very well the way to hide that buttons with css, or How can I do it?
Hi, 
I have a requirement can someone help me out..
 on toggle when i click then one modal will opne on modal there will a save and cancel button whn i click cancel then toggle will be inactive when i click save toggle will be active..
User-added image