• Jigar.Lakhani
  • NEWBIE
  • 481 Points
  • Member since 2014
  • Lead Specialist
  • Jade Global

  • Chatter
    Feed
  • 13
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 124
    Replies
Hi Folks,

I am building a LWC to load external JS script file in LWC. However whenever loadScript function is executing it is failing to load and there is not error received.

LWC
import { LightningElement, track  } from 'lwc';
import { loadScript } from 'lightning/platformResourceLoader';
import BrandfolderJS from '@salesforce/resourceUrl/BrandfolderJS';

export default class brandFolderLink extends LightningElement {
	
    @track blnBrandfolderJSInitialized = false;
    
    renderedCallback() {

        if (this.blnBrandfolderJSInitialized) {
            return;
        }
        this.blnBrandfolderJSInitialized = true;

        loadScript(this, BrandfolderJS)
        .then(() => {
            alert('success.......');
        })
        .catch(error => {
            alert('failed.....'+error);
        });
    }
	
}

JS file from Static Resource - Brandfolder JS (https://cdn.brandfolder.com/bf.min.js)
I have created JS file as static resource (BrandfolderJS) and using it in LWC.

LWC is added to App Builder Page/Home Page and trying to load, however it is going to catch block in loadScript method without any error. Error variable is undefined.

Can you please help?

Thank you,
Jigar Lakhani

Hi Guys,

I want to pass recordID from a LWC Component to a apex class in connectedCallback method.,But sommehow i am getting the value as null inside the class, Not able to understand where i am going wrong,
Can anyone please help me out .

export default class AddContacToDl extends LightningElement {
connectedCallback() {
var rcid= this.recordId;
console.log('rcid---beofre----'+rcid);
getSelectedDLDetails({contactIDname:this.rcid})
.then(data => {
console.log('data------'+data);
for(var i=0; i<data.length; i++) {
console.log('id=seleccted' + data[i]);
this.distvalue = [...this.distvalue ,{value:data[i], label: data[i]}];
}
this.error = undefined;
}).catch(error=>{
this.error = error;
this.distvalue = undefined;
})
}

Apex class-

@AuraEnabled
public static List<String> getSelectedDLDetails(String contactIDname)
{
System.debug(LoggingLevel.info,'ID value------'+contactIDname);
HI All,
Thanks in advance!! 
I have created visualforce page & displaying result dynamically below is the controller of my class:
public with sharing class DoctorsListdata1 {


    public Myforce_Campaign__c cmpg{get;set;}
    public Myforce_Campaign__c cmpg1{get;set;}
    public Patch_Customer__c pc{get;set;}
    public List<Patch_Customer__c> selectedAccounts{get;set;}
     public Id cmpId;
   public Decimal maxLimit{get;set;}
     
    public DoctorsListdata1(ApexPages.StandardController controller) {
        this.cmpg = (Myforce_Campaign__c)controller.getRecord();
         cmpId = ApexPages.CurrentPage().getParameters().get('id');
        cmpg.Id = apexpages.currentpage().getparameters().get('Id');
        system.debug('Plan ID' +cmpg.Id);
        
        cmpg1 = [select id, name,Speciality__c,Class__c,Visit_Frequency__c,Max_Doctor_Participation_Count__c,Min_Doctor_Participation_Count__c FROM Myforce_Campaign__c WHERE Id=:cmpId];
        maxLimit = cmpg1.Max_Doctor_Participation_Count__c;
        pharmaProductList();
    }
    
   Public List<PatchCusWrapper> productList{get;set;}
   public List<PatchCusWrapper> pharmaProductList(){
         productList = new List<PatchCusWrapper>();
         
         list<String> Speciality = new list<String>();
         
         system.debug(cmpg1);
         system.debug(cmpg1.Speciality__c);
         if(cmpg1.Speciality__c <> null)
         
         for(String str : cmpg1.Speciality__c.split(';'))
            {
            String lpmstr = '\'' +str+'\'';
            String lpm1 = '';
            lpm1 = lpm1 + lpmstr;
               Speciality.add(lpm1);


            }

List<String> Class1 = new List<String>();
for(String str : cmpg1.Class__c.split(';'))
            {
            String lpmstr = '\'' +str+'\'';
            String lpm1 = '';
            lpm1 = lpm1 + lpmstr;
               Class1.add(lpm1);


            }
list<String> Frequency = new list<String>();
for(String str : cmpg1.Visit_Frequency__c.split(';'))
            {
            String lpmstr = '\'' +str+'\'';
            String lpm1 = '';
            lpm1 = lpm1 + lpmstr;
               Frequency.add(lpm1);


            }



string Doctor='Doctor';
string status='Approved';
List<Patch_Customer__c> pcList = new List<Patch_Customer__c>();
String query='Select Id,First_Name__c,Last_Name__c,Patch__c,Patch__r.Name,Speciality__c,Graduation__c,Class__c,Frequency__c,City__c, Hospitals_Name__c from Patch_Customer__c WHERE RecordType.Name = \'' +Doctor+'\' ';


        if(cmpg1.Speciality__c !=null ){
            cmpg1.Speciality__c= cmpg1.Speciality__c.replace(';', ',');
            query +=  ' AND Speciality__c IN ' +Speciality;
        }
        
        if(cmpg1.Class__c !=null ){
            query +=  ' AND Class__c IN ' +Class1;
        }
        
        if(cmpg1.Visit_Frequency__c !=null ){
            query +=  ' AND Frequency__c IN ' +Frequency;
        }
         query += '  LIMIT 1000';
system.debug(query);
        pcList= Database.query(query);
         
             // List<Patch_Customer__c> pcList = [Select Id,First_Name__c,Last_Name__c,Patch__c,Patch__r.Name,Speciality__c,Graduation__c,Class__c,Frequency__c,City__c, Hospitals_Name__c from Patch_Customer__c WHERE RecordType.Name = 'Doctor' limit 5];
             system.debug(pcList);
             
             List<Id> customerList = new List<Id>();
                Map<Id, Patch_Customer__c> customerMap = new Map<Id, Patch_Customer__c>();
                for(Patch_Customer__c p : pcList){
                    customerList.add(p.Id);
                    customerMap.put(p.Id, p);
                }
   List<Campaign_Data__c> cdList = [SELECT Id, Customer__c FROM Campaign_Data__c WHERE Myforce_Campaign__c =:cmpg.Id ];
          
             Map<Id, Campaign_Data__c> cdMap = new Map<Id, Campaign_Data__c>();
             for(Campaign_Data__c b : cdList){
                 cdMap.put(b.Customer__c, b);
             }
             for(Id c : customerList){
             
                 if(cdMap.get(c) !=null){
                     productList.add(new PatchCusWrapper(cdMap.get(c),customerMap.get(c), true)); 
                 }
                 else{
                     Campaign_Data__c ppp = new Campaign_Data__c();
                     productList.add(new PatchCusWrapper(ppp, customerMap.get(c), false)); 
                }
             }
             system.debug('sdfkgfdgk jdfg hj');
         system.debug(productList);
         return productList;
     }

The above query is working fine when even I am selecting less than 9 Speciality from the picklist value,but whenever I am choosing more than 10 values in speciality .I am getting the below error:

System.QueryException: expecting a colon, found '.'
Class.DoctorsListdata1.pharmaProductList: line 86, column 1
Class.DoctorsListdata1.<init>: line 19, column 1

Thanks in advance.

Regards
Subrat
. Create a new PickList “Custom Status” in Opportunity object.(New,Open,Close,Reset) values.When this field changed and value is “Reset” now then delete all associated products(opp. Lines)
with related Opportunity
when ever parent picklist chages automatically child picklist values should be chage
ex: my parent picklist 1,2,3,4
     child picklist values 1a,1b,2a,2b....like that
   
Hi Experts,

I need in below image yellow color line meaning.

User-added image
Create a Scheduler to mail to Opportunity Owner , if not modified for last 30 days.
In Opportunity, If the stage is changed from another value to CLOSED_WON or CLOSED_LOST,populates the Close Date field with Today().
Hi All

I am trying the below to access the lookup field's value and I get null.
ObjA.fieldA__c =  ObjB.fieldB__r.Name 
where fieldB is a lookup field to object C
Whats wrong here ? 

 
Hi

I have created a Vf page .but i am unable to use two page block table in single page block.how its possible can any body tell me
 
<apex:page tabstyle="Account" showHeader="false" sidebar="false" Controller="ManageListController1">

<apex:define name="body">
            
            <div style="width:900px;margin: 10px auto 10px auto;background-color:Gray;">
            
 <apex:form >
 

   <apex:pageBlock title="Bank Book Entry:">
      <apex:pageBlockSection columns="2"> 
      
      <apex:pageBlockTable value="{!wrappers1}" var="wrapper1" id="wtable1">
      <apex:column headerValue="Date" style="background:gray;">
           <apex:outputText value="{!wrapper1.Txn_Date__c}"/>
         </apex:column>
      
      
      </apex:pageBlockTable>
      
          
   <div style="width:500px;margin: 10px auto 10px auto;">
   
      <apex:pageBlockTable value="{!wrappers}" var="wrapper" id="wtable">
       
         <apex:column headerValue="Ident" style="background:gray;">
            <apex:outputText value="{!wrapper.ident}"/>
         </apex:column>
         <apex:column headerValue="Master Code" style="background:gray;">
            <apex:inputField value="{!wrapper.acc.Entries_Code__c}"/>
         </apex:column>
         <apex:column headerValue="Amount" style="background:gray;">
            <apex:inputField value="{!wrapper.acc.Amount__c}"/>
         </apex:column>
         <apex:column headerValue="Narration" style="background:gray;">
            <apex:inputField value="{!wrapper.acc.Narration__c}"/>
         </apex:column>
          
       <apex:column headerValue="">
            <apex:commandButton value="Enter" action="{!addRows}" rerender="wtable" style="background:pink" >
         <apex:param name="addCount" value="1" assignTo="{!addCount}"/> 
      </apex:commandButton>
         </apex:column>
       
         <apex:column headerValue="Action">
            <apex:commandButton value="Delete" action="{!delWrapper}" rerender="wtable" style="background:Red">
               <apex:param name="toDelIdent" value="{!wrapper.ident}" assignTo="{!toDelIdent}"/> 
            </apex:commandButton>
         </apex:column>
         
      </apex:pageBlockTable>
     </div>
        
        
      <apex:commandButton value="Add 5 Rows" action="{!addRows}" rerender="wtable" style="width:100px;margin: 10px auto 10px auto;">
         <apex:param name="addCount" value="5" assignTo="{!addCount}"/> 
      </apex:commandButton>
      
      <apex:commandButton value="Save" action="{!save}" style="width:100px;margin: 10px auto 10px auto;"/>
   
     </apex:pageBlockSection>
     </apex:pageBlock>
 </apex:form>
  </div>
        </apex:define>
</apex:page>
 
public class ManageListController1 
{

    
    public ManageListController1(ApexPages.StandardController controller) {

    }

 public List<AccountWrapper> wrappers {get; set;}
  public List<AccountWrapper> wrappers1 {get; set;}
 public static Integer toDelIdent {get; set;}
 public static Integer addCount {get; set;}
 private Integer nextIdent=0;
  
 public ManageListController1()
 {
  wrappers=new List<AccountWrapper>();
  Wrappers1=new List<AccountWrapper>();
  for (Integer idx=0; idx<1; idx++)
  {
   wrappers.add(new AccountWrapper(nextIdent++));
    wrappers1.add(new AccountWrapper(nextIdent++));
   
  }
 }
  
 public void delWrapper()
 {
  Integer toDelPos=-1;
  for (Integer idx=0; idx<wrappers.size(); idx++)
  {
   if (wrappers[idx].ident==toDelIdent)
   {
    toDelPos=idx;
   }
  }
   
  if (-1!=toDelPos)
  {
   wrappers.remove(toDelPos);
  }
 }
  
 public void addRows()
 {
  for (Integer idx=0; idx<addCount; idx++)
  {
   wrappers.add(new AccountWrapper(nextIdent++));
  }
 }
  
 public PageReference save()
 {
  List<BankBook__c> accs=new List<BankBook__c>();
  for (AccountWrapper wrap : wrappers)
  {
   accs.add(wrap.acc);
  }
   
  insert accs;
   
  return new PageReference('/' + Schema.getGlobalDescribe().get('BankBook__c').getDescribe().getKeyPrefix() + '/o');
 }
 
 public pageReference parentPage () {

          return new pageReference('/apex/Receivables');
} 
  
  
  
 public class AccountWrapper
 {
  public BankBook__c acc {get; private set;}
  public Integer ident {get; private set;}
   
  public AccountWrapper(Integer inIdent)
  {
   ident=inIdent;
   acc=new BankBook__c();
  }
 }
}

 
Hi all

Thanks In Advc..


I am facing small bit of problem like want to data catagory in the form of series like 
aaa,bbb,ccc,ddd---Series1
eee,fff,ggg,iii-----Series2......Like this

i have one object having some field .when i am entering value with field aaa and click on save it will be saved in series1 catagory means data will be saved with respective series based on value..
Is there any way to solve this