• Nitish
  • NEWBIE
  • 95 Points
  • Member since 2017

  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 61
    Replies
Hi,

Can someone please help on how we can add a print button on a lwc component page for Print. And on clicking on this the entire component will be open in a new window for print. Could not find a suitable solution till now. Winodw.print will print the entire wndow. But i want to print only the specific component html. There might be multiple components in the page.

Thanks,
Ashirbad
Hi I am trying to create a contact related record when a new account is created

trigger Createcontact on Account (before insert) {  
List<Contact> contactList=new List<Contact>();
    for (Account a : Trigger.new) {
    Contact c=new Contact();
    c.firstName=a.Name;
    c.lastName=a.Name;  
    contactList.add(c);
        // Iterate over each sObject
    }
  insert contactList;
}

the above trigger creates a new contact where in i want the contact to be related to the respective account
Hi Everyone,

Can anyone please explain me how to import data from one salesforce to another salesforce without changing the id values.

Thanks inadvance
In a lwc I have a  lightning-textarea control which is having a vertical scroll bar. And there is a Print button on click of which I am doing window.print() in the js. But if the content is more in the text box then the print window is displaying only the content which is visible while printing. I mean the content which you can see after scrolling down is not getting displayed in the print window. 

Can someone please help around this. How the print window will show all the contents which is there in the text box.
OnLoad function on RecordEditForm: 

handleLoad : function(component, event, helper){
        var record = event.getParams().recordUi.record;
        console.log("onLoad");
        console.log(JSON.parse(JSON.stringify(record)));
        var obj = JSON.parse(JSON.stringify(record));
        console.log('Record Id',obj.id);
        console.log('Record Id',obj.fields.EmploymentStatus__c.value);
        var fieldValue = obj.fields.EmploymentStatus__c.value;
        if(fieldValue === 'C2C'){
            component.set("v.vendorDetailsFlag", true);
        }
        else {
            component.set("v.vendorDetailsFlag", false);
        }
        
    },
Onchange Event on InputField:

    onchangeCalled : function(component, event, helper){
        
        component.set("v.spinnerFlag",true);
        window.setTimeout(
            $A.getCallback(function() {
                var val = event.getSource().get("v.value");
                if(val === 'C2C'){
                    component.set("v.vendorDetailsFlag", true);
                } else {
                    component.set("v.vendorDetailsFlag", false);
                }
                component.set("v.spinnerFlag",false);
            }), 500
        );
        
    },
Error1:
While loading a record onchangeCalled function is calling by default from onLoad and displaying spinners and all
Error2:
If I change a value on the field it is calling "handleLoad" too and "component.set("v.vendorDetailsFlag", true);" is failing because handleLoad is loading record  again.
 
<lightning:recordEditForm aura:id="recordViewForm"
                              objectApiName="Candidate"
                              recordId="{!v.recordId}"
                              recordTypeId=""
                              onload="{!c.handleLoad}"
                              onsubmit="{!c.handleSubmit}"
                              onsuccess="{!c.handleSuccess}"
                              >
 
<lightning:inputfield name="employmentStatus" aura:id="employmentStatus" fieldName="EmploymentStatus__c" onchange="{!c.onchangeCalled}"/>

Please help me on this
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" 
                access="global" >
    
    <aura:attribute name = "AmazeKart" type = "string" default = "AmazeKart"/>
    <aura:attribute name = "Computers" type = "string" default = "Computers"/>
    <aura:attribute name = "Mobiles"   type = "string" default = "Mobiles"/>
    <aura:attribute name = "Watches"   type = "string" default = "Watches"/>
    <aura:attribute name = "Cart"      type = "string" default = "Cart"/>
   <!-- <aura:attribute name = "pageReference" type = "object"/>
     <aura:handler name= "init" value = "{!this}" action= "{!c.doInit}"/>
     -->
    
    <lightning:layout class="slds-page-header slds-page-header--object-home">
        <lightning:layoutItem>
            <lightning:icon iconName="standard:scan_card" alternativeText="amazeKart"/>
        </lightning:layoutItem>
        <lightning:layoutItem padding="horizontal-small">
            <div class="page-section page-header">
                <h1 class="slds-text-heading--label">{!v.AmazeKart}</h1>
                
            </div>
        </lightning:layoutItem>
    </lightning:layout>
    
    <div class="slds-box slds-theme_shade slds-theme_alert-texture">
        <div class="slds-grid slds_align-center">
            
            <div class="slds-col slds-size_1-of-4">
                <span>
                    <div class="slds-box slds-box">
                        <p> <lightning:button label="Computers" class ="slds-m-top-medium" variant="brand"
                                              onclick="{!c.handleClick}"/></p>
                    </div>
                </span>
            </div>
            
            <div class="slds-col slds-size_1-of-4">
                <span>
                    <div class="slds-box slds-box">
                        <p><lightning:button label="Watches" class ="slds-m-top-medium" variant="brand"
                                             onclick="{!c.handleClick}"/></p>
                        
                    </div>
                </span>
            </div>
            
            <div class="slds-col slds-size_1-of-4">
                <span>
                    <div class="slds-box slds-box">
                        <p>
                           
    <lightning:navigation aura:id="navService"/>
    <lightning:button label="Mobiles" value= "Navigate" variant = "brand" onclick="{!c.handleClick}"/>
                        </p>
                    </div>
                </span>
            </div>
            
            <div class="slds-col slds-size_1-of-6">
                <span>
                    <div class="slds-box slds-box">
                        <p><lightning:button label="Cart" class ="slds-m-top-medium" variant="brand"
                                             onclick="{!c.handleClick}"/></p>
                        
                    </div>
                </span>
            </div>
        </div>
    </div>
</aura:component >
 
({
    handleClick : function(component, event, helper) {
       var navService = component.find("navService");
        var pageReferenceNav = {
            type: 'standard__component',
            attributes: {
                componentName: 'c__mobiles',
            },
            state: {
                "myAttr": "attrValue" 
            }
        };
        pageReference.navigate(pageReferenceNav);
     },
   
    
})

Please help me with above issue
We have an integration with Zendesk and all profiles, except for the System Administrator, are receiving the following error message. Is tnis something on the Salesforce side or the Zendesk side?  User-added image
how to create the records by using rest api post method tthrough process builder
Hi,

Can someone please help on how we can add a print button on a lwc component page for Print. And on clicking on this the entire component will be open in a new window for print. Could not find a suitable solution till now. Winodw.print will print the entire wndow. But i want to print only the specific component html. There might be multiple components in the page.

Thanks,
Ashirbad
Hello folks , 
I want to show a custom message or toast message if no contacts are found for an account . could you please correct my code . 

please tell how to check the size or length of the  returned contacts .  

below code displays Contacts if present under an account . 

html code:
<template>
<lightning-card title="Apex Method With Parameters">
<lightning-layout>
<lightning-layout-item flexibility="auto" padding="around-small">
<lightning-layout-item flexibility="grow">
<lightning-input label="Enter Account Name" type="search" onchange={searchContact} value={searchKey}> </lightning-input>
</lightning-layout-item>
                <lightning-layout-item class="slds-p-left_xx-small">
<lightning-button label="Search" onclick={doSearch} ></lightning-button> </lightning-layout-item>
<lightning-layout-item class="slds-m-bottom_small">
<template if:true={contacts}>
<template for:each={contacts} for:item="contact">
<p key={contact.Id}> {contact.Name} </p>
</template>
</template>
<template if:false={contacts}>
<p> No Contacts found for this Account </p>
</template>
<template if:true={error}>
{error}>
</template>
</lightning-layout-item>
         </lightning-layout-item>
</lightning-layout>
</lightning-card>
</template>

js code: 

import { LightningElement, track } from 'lwc';
import SearchContactList from '@salesforce/apex/ApexMethodWithParameters.SearchContactList';
export default class ShowContactsIMP extends LightningElement {
/* eslint-disable no-console */
/* eslint-disable no-alert */
@track contacts;
@track error;
searchContact(event){
this.searchKey = event.target.value;
}
doSearch() {
SearchContactList({ accountName: this.searchKey })
.then(
result => {
this.contacts = result;
console.log('contacts => ', JSON.stringify(this.contacts));
alert('contacts => ', JSON.stringify(this.contacts));
this.error = undefined;
}
)
.catch(error => {
this.error = error;
this.contacts = undefined;
});
}
}
 

Hi everyone, I'm new to lightning and trying to learn few things.
Problem is that I am able to display the picklist for objects as well as a multi select picklist. But when I click on an object I am getting the related fields in my console.log(resoponseValue) but not in the UI of my aura app when I run the code. Please help me acheiving this task. Here is my code for the same :

Apex Controller:
public class PickList {
    @AuraEnabled
    public static List <String> getPiklistValues(String objName) {
        System.debug('objName--'+objName);
        List<String>apiNames =  new list<String>();
        
        Map<String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
        Map<String, Schema.SObjectField> fieldMap=new  Map<String, Schema.SObjectField>();
        if(objName.contains('Account')){
            fieldMap= schemaMap.get('Account').getDescribe().fields.getMap();             
        }else if(objName.contains('Case')){
            fieldMap= schemaMap.get('Case').getDescribe().fields.getMap();   
        }else if(objName.contains('Contact')){
            fieldMap= schemaMap.get('Contact').getDescribe().fields.getMap();   
        }else if(objName.contains('Opportunity')){
            fieldMap= schemaMap.get('Opportunity').getDescribe().fields.getMap();   
        }
        
        for(String fieldName : fieldMap.keyset() )
        {
            system.debug('@@@@@@@'+fieldName); 
            apiNames.add(fieldName);
        }
        return apiNames;
    }
}

Cmp : 
<aura:component controller="PickList" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction,lightning:actionOverride" access="global" >
    <aura:attribute name="options" type="List" default="Select Object, Account, Case, Contact, Opportunity"/>
    <aura:attribute name="selectedValue" type="String" />
    <aura:attribute name="FieldsList" type="List" />
    <aura:attribute name="SelectedFieldsList" type="List" />
   <!-- <aura:handler name="init" action="{!c.doInit}" value="{!this}"/>-->

    <!--Code for displaying objects in picklist-->
    <select style="border: 1px solid #A9A29E;" class="slds-select"  id="objectName" onchange="{!c.myAction}">
        <aura:iteration items="{!v.options}" var="abc">
            <option value="{!abc}" text="{!abc}" />
        </aura:iteration>
    </select>
    <!--Code for displaying fields of object-->
    <div class="slds-m-around_xx-large">
        <lightning:dualListbox aura:id="selectFields"
                               name="Fields"
                               label="Select Fields"
                               sourceLabel="Available Fields"
                               selectedLabel="Selected Fields"
                               options="{!v.FieldsList }"
                               value="{!v.SelectedFieldsList}"
                               onchange="{!c.handleSubmitChange}"/>
        <lightning:button variant="brand" label="Submit" onclick="{!c.getSelectedFields}" />
    </div>
</aura:component/>

Controller JS :
({
 myAction : function(component, event, helper) {
        var action = component.get('c.getPiklistValues');
        var t=document.getElementById("objectName").value;
        alert('object--'+t);
        action.setParams({
            objName : t,
        });
        action.setCallback(this,function(response){
            var responseValue = response.getReturnValue();
                    console.log(responseValue);
            component.set("v.FieldsList",responseValue);
        });
        $A.enqueueAction(action);
    },
    handleSubmitChange: function (component, event, helper) {
        //alert('ok');
        var e = event.getParam("value");
        component.set("v.SelectedFieldsList", e);
    },
    getSelectedFields : function(component, event, helper){
        // alert('fine');
        var s = component.get("v.SelectedFieldsList");
        console.log('$$$$' , s);
    }
})

Thanks in advance.

Hi Team,

I am facing this error 'class java.lang.String cannot be cast to class moduleapi.interaction.DateOnly (java.lang.String is in module java.base of loader 'bootstrap'; moduleapi.interaction.DateOnly is in unnamed module of loader org.eclipse.osgi.internal.loader.EquinoxClassLoader @58c34bb3)' on case object. Could anyone please let me know why this error occurs?

Thanks-in-advance.
I have a lightning web component with a record-edit-form and a button to submit the form. I am trying to prevent the form submission when a required field is missing, but it's not working properly with just the "required" attribute of the lightning-input-field. This is what I have so far:

component.html
<lightning-record-edit-form object-api-name="ts2__Placement__c" record-id={recordId} onsuccess={handleSuccess} onsubmit={handleSubmit1}>
            <lightning-messages></lightning-messages>
            <div class="slds-grid slds-gutters">
                <div class="slds-col slds-size_6-of-12"> 
               <lightning-output-field field-name="ts2__Employee__c"></lightning-output-field>
                <lightning-input-field id="onboardingMeth" field-name="Onboarding_Method__c" onchange={handleChange2} value={oboMeth} required></lightning-input-field>
                 <lightning-input-field name="contractorType" field-name="Contractor_Type__c" onchange={handleChange3} value={conType} required></lightning-input-field>
                    </div>
                    </div>
    </lightning-record-edit-form>  
<lightning-button variant="brand" class="slds-m-left_x-small" icon-name="utility:forward" type="submit" icon-position=right label="Submit" onclick={handleNext}></lightning-button>
</template>
component.js
import { LightningElement , api, track} from 'lwc';

export default class LwcBasicWizard extends LightningElement {
    @api recordId;

handleSubmit1(){
     this.template.querySelector('lightning-record-edit-form').submit();
    }

 
Hi,
I have a question, I need to search the data only what I posted /created in my object. Now, it is searching for all the data, including which other's posted/created.
Hi All,
We have a requirement where we need to merge two accounts. Master account has few contacts and other one has few. 

Once we merge the accounts, I think related contacts will not added to Master account. If it is not then how do we update accountid to existing contact using Dataloader / import wizard?

Please let me know.

Thanks,
Sirisha