• akshay desai 9
  • NEWBIE
  • 50 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 23
    Questions
  • 8
    Replies
I have search box in header
when i search something i get search results in another page
but when i redirect to another page i want to show searchtext in searchbox which i didnt get
window.location.href = base_url + '/community/s/search-results?searchterm=' + searchquery + '&searchcontext=' + objType + '&globalsearch=true&aid=' + this.portalConfig.selectedAccount;
using this to redirect
 
@AuraEnabled
    public static String getContactPhone(){
     if(String.isNotBlank(lstAcc[0].Customer_Care_Phone__c)){
            return lstAcc[0].Customer_Care_Phone__c;
          }else if(String.isNotBlank(lstAcc[0].Customer_Care_Phone_FZ__c)){
            return lstAcc[0].Customer_Care_Phone_FZ__c;
          }
}
I wanted to call this return string in LWC
 
How to implement select all disselect all in lightning-dual-listbox in LWC
Parent Component Html
<template>
<template if:true={overlayVisible}>
        <div class="overlay" id="overlay" onclick={closeNav}>
        </div>
    </template>
      <lightning-layout>
 <lightning-layout-item padding="around-small" class="frstRowLeft minPadding">
<span class="span-menu" onclick={openNav}><img src={menu} alt="Menu bar">
   </span>
     </lightning-layout-item>
</lightning layout>
<template if:true={navVisible}>
        <c-sidebar item={navVisible} overlay={overlayVisible}></c-sidebar>
    </template>
<template>
Parent Component JS
@api navVisible = false;
  @api overlayVisible = false;
openNav() {
        this.navVisible = true;
        this.overlayVisible = true;
    }
    closeNav() {
        this.navVisible = false;
        this.overlayVisible = false;
    }
when I click on image sidebar open then I navigate to another page when I navigate to another page i want to close the Sidebar but it is not it is navigating to another page successfully

child component Html
<li onclick={navigateCase}>
                <a href="#" onmouseover={chngToWhiteCase} onmouseout={chngToBlackCase}>
                    <template if:false={showWhiteCaseIcon}>
                        <div class="listImg"><img src={caseicbla} alt="Cases"></div><span>Cases</span>
                    </template>
                    <template if:true={showWhiteCaseIcon}>
                        <div class="listImg"><img src={caseicwht} alt="Cases"></div><span>Cases</span>
                    </template>
                </a>
            </li>
            <li>

Child Component JS
@api item;
  @api overlay;
navigateCase() {
        console.log('item value',this.item);
        console.log('overlay vale'+this.overlay);
        this[NavigationMixin.Navigate]({
            type: 'comm__namedPage',
            attributes: {
                pageName: 'casetab'
            },
        });
        this.overlay=false;
        this.item = false;
        console.log('item value',this.item);
        console.log('overlay vale'+this.overlay);
        this.template.querySelector("c-hrwdcommunityheader").closenav();
    }



 
My page settings are like like thisMy page settings are like like thisUser-added image

and the code i am using for navigation is
navigateCase() {
        console.log('item value',this.item);
        this.item = false;
        this.isshow=false;
        this[NavigationMixin.Navigate]({
            type: 'comm__namedPage',
            attributes: {
                pageName: 'casetab'
            },
        });
    }
    navigateHome() {
        //this.isOpenDashboard = true;
        this[NavigationMixin.Navigate]({
            type: 'comm__namedPage',
            attributes: {
                pageName: 's'
            },
        });
    }

 i am able to navigate to other pages but not in home page
<template if:true={openRecordCount}>
                                <c-hrwddatatable hide-checkbox-column="true"  show-actions="true" action-img3={addNewActivityIMG} onrowactionthree={showAddActivity} columns={opencolumns} column-value={opencolumnValue}  onsort={handleSort} onlinkclicked={handleLinkClick}></c-hrwddatatable>
                            </template
<template for:each={columns} for:item="column" for:index="index" >
                        <template if:true={column.HSOP_Enable_Sorting__c}>
                            <th class="heading cursorHand uparrow downarrow headerClass" key={column.HSOP_Field_API_Name__c} onclick={handleHeaderClick} data-index={index}
                            data-message={column.HSOP_Field_API_Name__c}>
                                <div class="row" data-index={index} data-message={column.HSOP_Field_API_Name__c}>
                                <div class="column left cursorHand" data-index={index} data-message={column.HSOP_Field_API_Name__c}>{column.HSOP_Column_Header__c}</div>
                                <div class="column right" data-index={index} data-message={column.HSOP_Field_API_Name__c}>
                                    <div class="slds-align_absolute-center glyphicon " data-index={index} data-message={column.HSOP_Field_API_Name__c}></div>
                                </div>
                            </div>
                        </th>    
                        </template>
</template>
columns are coming from metadata
there are 12 columns are coming but i just wanted to show particular 7 columns
how should i filter the data in my JS


 
I have a parent Account and a child account
whenever user search for either on I want to show  the search record with parent and child as well
I want to show like 
Parent then below that there childs like
Parent 
child1
Child2 
I have 1 VF page with lookup & "Done" command button
i have requirement of by clicking done button it will navigate to aura component & show data of that record to component
<apex:page standardController="Campaign" extensions="ForSaleLookupOnCampaignController"> 
    <script type="text/javascript">
        function selectAllCheckboxes(obj,receivedInputID){
            var inputCheckBox = document.getElementsByTagName("input");                  
            for(var i=0; i<inputCheckBox.length; i++){          
                if(inputCheckBox[i].id.indexOf(receivedInputID)!=-1){                                     
                    inputCheckBox[i].checked = obj.checked;
                }
            }
        }
   
}
    </script>
    <apex:form >
        <apex:pageBlock >
             <apex:pageBlockButtons >
                <apex:commandButton value="Save" style="width: 100px; height: 30px" action="{!processSelected}" rerender="table2"/>
            </apex:pageBlockButtons>
            <p style="font-size: 15px;font-weight: bold;">Select FID :</p><apex:inputfield style="width: 200px; height: 30px" value="{!Campaign.For_Sale__c}" id="forsaleid"/><br/>
            <apex:pageblockSection title="Related Campaign Members" collapsible="false">
                <apex:pageBlockTable value="{!wrapcontactList}" var="conWrap" id="table" title="All Related Campaign Members">     
                    <apex:column >
                        <!--apex:facet name="header">
                          <apex:inputCheckbox onclick="selectAllCheckboxes(this,'inputId')"/>
                         </apex:facet-->
                        <apex:inputCheckbox value="{!conWrap.selected}" id="inputId"/>
                    </apex:column>
                    <apex:column value="{!conWrap.con.Name}" />
                    <apex:column value="{!conWrap.con.Account.name}" />
                </apex:pageBlockTable>
            </apex:pageblockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>
public class ForSaleLookupOnCampaignController { 
    public List<CampaignMember> Campaignmemberlist{get;set;} 
    public Campaign cmp {get;set;} 
    public List<wrapContact> wrapcontactList {get; set;}
    public List<Contact> selectedcontacts{get;set;}
    set<id>conid=new set<ID>();
    public String ID { get; set;}
    set<id>ForSaleid=new set<id>();
    public ForSaleLookupOnCampaignController (ApexPages.StandardController standardControllerParam) {
        this.cmp = (Campaign)standardControllerParam.getRecord();
        Campaignmemberlist = [SELECT id,name,Campaignid,Company__c,type,For_Sale__c,Contact.For_Sale__c  FROM CampaignMember WHERE Campaignid = : ApexPages.currentPage().getParameters().get('id') ];
        for(CampaignMember cm:Campaignmemberlist){
            conid.add(cm.ContactId);
            ForSaleid.add(cm.For_Sale__c);
        }
        //
        if(wrapContactList == null) {
            wrapContactList = new List<wrapContact>();
            for(Contact c: [select Id,Name,Account.name,For_Sale__c from Contact where id=:conid]) {
                wrapContactList.add(new wrapContact(c));
            }
        }
        
    }
    public PageReference processSelected() {
        PageReference pr;
        selectedcontacts = new List<contact>();
        system.debug('for sale '+cmp.For_Sale__c);
        for(wrapContact wrapcontactObj : wrapcontactList) {
            if(wrapcontactObj.selected == true) {
                selectedcontacts.add(wrapcontactObj.con);
                
            }
        }
        for(contact s:selectedcontacts){
            s.For_Sale__c=cmp.For_Sale__c;
        }
            try{
                
                database.update(selectedcontacts);
                
            }catch( Exception e ){
                ApexPages.addMessages(e);
            }
            system.debug('selectedcontacts'+selectedcontacts);
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.CONFIRM,'FID Update on Contact'));
      return pr;   
    }
    public class wrapContact {
        public Contact con {get; set;}
        public string forsaleid{get;set;}
        public Boolean selected {get; set;}
        
        public wrapContact(Contact c) {
            con = c;
            forsaleid=c.For_Sale__c;
            selected = false;
        }
    }
}
How should I show success message on VF Page
& another thing is
here <apex:inputfield style="width: 200px; height: 30px" value="{!Campaign.For_Sale__c}" id="forsaleid"/> when I click on button & page is load the value is already populate on this but I want to clear this value when page populate how can I do that?


 
My list button is on CampaignMember button but i am accessing this button from campaign object related list
so i am getting error
Id value 7018A000000ITTu is not valid for the Campaign Member standard controller

I just started to write code so its just like this
<apex:page standardController="CampaignMember" extensions="ForSaleLookupOnCampaignController" action="{!routeToFlow}"> 
    <apex:form> 
        For Sale :
<apex:inputfield value="{!CampaignMember.For_Sale__c}"/>   
        <apex:commandButton value="Save"/> 
    </apex:form> 
</apex:page>
public class ForSaleLookupOnCampaignController { 
        public ForSaleLookupOnCampaignController (ApexPages.StandardController standardControllerParam) {
  
}
}


 
I have 2 picklist Department & product which are dependent.
On a visualforce page i want to show the product picklist but want to show only those products in which department is 'Warehouse'

I am using Schema.PicklistEntry but i dont want to show every value of picklist on a vf page 
function checkExpiryDate(){        
            var expiry_date1=document.getElementById('{!$Component.page.formid.pgBlk.expiry_date}').value;
            var exp='^[0-9]*$';
            var check=expiry_date1.includes('-');
            
            if(check==true)
            {
                var splitText=expiry_date1.split('-');
                if(splitText.length==2)
                {
                    if(splitText[0].length==4 && splitText[1].length==2)
                    {
                        if(splitText[0].match(exp) && splitText[1].match(exp))
                        {
                            document.getElementById('{!$Component.page.formid.pgBlk.sbtn1}').disabled=false;
                            return true; 
                        }
                        else
                        {
                            document.getElementById('{!$Component.page.formid.pgBlk.expiry_date}').value='';
                            document.getElementById('{!$Component.page.formid.pgBlk.expiry_date}').focus();
                            alert('Expiry date should be in (YYYY-MM) format');
                            document.getElementById('{!$Component.page.formid.pgBlk.sbtn1}').disabled=true;
                            return false;
                        }
                    }
                    else
                    {
                        document.getElementById('{!$Component.page.formid.pgBlk.expiry_date}').value='';
                        document.getElementById('{!$Component.page.formid.pgBlk.expiry_date}').focus();
                        alert('Expiry date should be in (YYYY-MM) format');
                        document.getElementById('{!$Component.page.formid.pgBlk.sbtn1}').disabled=true;
                        return false;
                    }
                }
                else
                {
                    document.getElementById('{!$Component.page.formid.pgBlk.expiry_date}').value='';
                    document.getElementById('{!$Component.page.formid.pgBlk.expiry_date}').focus();
                    alert('Expiry date should be in (YYYY-MM) format');
                    document.getElementById('{!$Component.page.formid.pgBlk.sbtn1}').disabled=true;
                    return false;
                }
            }
            else
            {
                document.getElementById('{!$Component.page.formid.pgBlk.expiry_date}').value='';
                document.getElementById('{!$Component.page.formid.pgBlk.expiry_date}').focus();
                alert('Expiry date should be in (YYYY-MM) format');
                document.getElementById('{!$Component.page.formid.pgBlk.sbtn1}').disabled=true;
                return false;
            }

i want to take value in the format mm-yy 

& then want to convert into yyyy-mm for use into my controller class which is a api that is validating expiry date of credit card
I want to write a trigger when user insert or change name(whoid) of task then there is field in task object that has to be change with contact name
trigger taskupdatetrigger on Task (after insert,after update) {
    list<task>tasklist=new list<task>();
    list<contact>contactlist=[select id,name from contact];
       id taskid;
    id contactid;
    for(task taskobj:trigger.new){
        taskid=taskobj.id;
        system.debug('task id'+taskid);
        for(contact conobj:contactlist){
            if(taskobj.WhoId==conobj.Id){
            system.debug('inside if');
            /taskobj.POC_name__c=conobj.Name;
                system.debug('POC_name__c'+taskobj.POC_name__c);
        }
            
        }
        
    }
    system.debug('contactlist'+contactlist);
}

this is giving me error on saving "execution of AfterUpdate caused by: System.FinalException: Record is read-only Trigger.Calendar_trigger: line 12, column 1"
Order order1=new Order();
        order1.AccountId=ac.Id;
        order1.EndDate=Date.newInstance(2019,07,25);
        order1.Pricebook2Id=priceBookS.Id;
        order1.EffectiveDate=Date.newInstance(2019,07,16);
        order1.Status='In';
         order1.TotalAmount=1;
        order1.totaltransaction=1;
        //order1.Status='In';
        insert order1;

my test class is this I have validation rule that is totalamount = totaltransaction so when i am running the test it is failing because of validation rule 

But totalAmount field is not writeable and totaltransaction is rollup field 

how can I insert the TotalAmount field in testclass
I have 4 objects 
Object A has look-up relation of object B
Object B has look-up relation of object C
Object C has look-up relation of object D

The page has standard controller of D 
How should i show the data of object A on visual force here i am iterating a list of records of object C

I used this code in my vf controller

 public List<SelectOption> getmonth() {
          List<SelectOption> options = new List<SelectOption>();
          options.add(new SelectOption('JANUARY','January'));
          options.add(new SelectOption('FEBRUARY','February'));
          options.add(new SelectOption('MARCH','March'));
        options.add(new SelectOption('APRIL','April'));
        options.add(new SelectOption('MAY','May'));
        options.add(new SelectOption('JUNE','June'));
        options.add(new SelectOption('JULY','July'));
        options.add(new SelectOption('AUGUST','August'));
        options.add(new SelectOption('SEPTEMBER','September'));
        options.add(new SelectOption('OCTOBER','October'));
        options.add(new SelectOption('NOVEMBER','November'));
        options.add(new SelectOption('DECEMBER','December'));                           
          return options;
      }

now I want to show data of may if user select may  how should I do that?
@AuraEnabled
    public static String getContactPhone(){
     if(String.isNotBlank(lstAcc[0].Customer_Care_Phone__c)){
            return lstAcc[0].Customer_Care_Phone__c;
          }else if(String.isNotBlank(lstAcc[0].Customer_Care_Phone_FZ__c)){
            return lstAcc[0].Customer_Care_Phone_FZ__c;
          }
}
I wanted to call this return string in LWC
 
Parent Component Html
<template>
<template if:true={overlayVisible}>
        <div class="overlay" id="overlay" onclick={closeNav}>
        </div>
    </template>
      <lightning-layout>
 <lightning-layout-item padding="around-small" class="frstRowLeft minPadding">
<span class="span-menu" onclick={openNav}><img src={menu} alt="Menu bar">
   </span>
     </lightning-layout-item>
</lightning layout>
<template if:true={navVisible}>
        <c-sidebar item={navVisible} overlay={overlayVisible}></c-sidebar>
    </template>
<template>
Parent Component JS
@api navVisible = false;
  @api overlayVisible = false;
openNav() {
        this.navVisible = true;
        this.overlayVisible = true;
    }
    closeNav() {
        this.navVisible = false;
        this.overlayVisible = false;
    }
when I click on image sidebar open then I navigate to another page when I navigate to another page i want to close the Sidebar but it is not it is navigating to another page successfully

child component Html
<li onclick={navigateCase}>
                <a href="#" onmouseover={chngToWhiteCase} onmouseout={chngToBlackCase}>
                    <template if:false={showWhiteCaseIcon}>
                        <div class="listImg"><img src={caseicbla} alt="Cases"></div><span>Cases</span>
                    </template>
                    <template if:true={showWhiteCaseIcon}>
                        <div class="listImg"><img src={caseicwht} alt="Cases"></div><span>Cases</span>
                    </template>
                </a>
            </li>
            <li>

Child Component JS
@api item;
  @api overlay;
navigateCase() {
        console.log('item value',this.item);
        console.log('overlay vale'+this.overlay);
        this[NavigationMixin.Navigate]({
            type: 'comm__namedPage',
            attributes: {
                pageName: 'casetab'
            },
        });
        this.overlay=false;
        this.item = false;
        console.log('item value',this.item);
        console.log('overlay vale'+this.overlay);
        this.template.querySelector("c-hrwdcommunityheader").closenav();
    }



 
<apex:page standardController="Campaign" extensions="ForSaleLookupOnCampaignController"> 
    <script type="text/javascript">
        function selectAllCheckboxes(obj,receivedInputID){
            var inputCheckBox = document.getElementsByTagName("input");                  
            for(var i=0; i<inputCheckBox.length; i++){          
                if(inputCheckBox[i].id.indexOf(receivedInputID)!=-1){                                     
                    inputCheckBox[i].checked = obj.checked;
                }
            }
        }
   
}
    </script>
    <apex:form >
        <apex:pageBlock >
             <apex:pageBlockButtons >
                <apex:commandButton value="Save" style="width: 100px; height: 30px" action="{!processSelected}" rerender="table2"/>
            </apex:pageBlockButtons>
            <p style="font-size: 15px;font-weight: bold;">Select FID :</p><apex:inputfield style="width: 200px; height: 30px" value="{!Campaign.For_Sale__c}" id="forsaleid"/><br/>
            <apex:pageblockSection title="Related Campaign Members" collapsible="false">
                <apex:pageBlockTable value="{!wrapcontactList}" var="conWrap" id="table" title="All Related Campaign Members">     
                    <apex:column >
                        <!--apex:facet name="header">
                          <apex:inputCheckbox onclick="selectAllCheckboxes(this,'inputId')"/>
                         </apex:facet-->
                        <apex:inputCheckbox value="{!conWrap.selected}" id="inputId"/>
                    </apex:column>
                    <apex:column value="{!conWrap.con.Name}" />
                    <apex:column value="{!conWrap.con.Account.name}" />
                </apex:pageBlockTable>
            </apex:pageblockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>
public class ForSaleLookupOnCampaignController { 
    public List<CampaignMember> Campaignmemberlist{get;set;} 
    public Campaign cmp {get;set;} 
    public List<wrapContact> wrapcontactList {get; set;}
    public List<Contact> selectedcontacts{get;set;}
    set<id>conid=new set<ID>();
    public String ID { get; set;}
    set<id>ForSaleid=new set<id>();
    public ForSaleLookupOnCampaignController (ApexPages.StandardController standardControllerParam) {
        this.cmp = (Campaign)standardControllerParam.getRecord();
        Campaignmemberlist = [SELECT id,name,Campaignid,Company__c,type,For_Sale__c,Contact.For_Sale__c  FROM CampaignMember WHERE Campaignid = : ApexPages.currentPage().getParameters().get('id') ];
        for(CampaignMember cm:Campaignmemberlist){
            conid.add(cm.ContactId);
            ForSaleid.add(cm.For_Sale__c);
        }
        //
        if(wrapContactList == null) {
            wrapContactList = new List<wrapContact>();
            for(Contact c: [select Id,Name,Account.name,For_Sale__c from Contact where id=:conid]) {
                wrapContactList.add(new wrapContact(c));
            }
        }
        
    }
    public PageReference processSelected() {
        PageReference pr;
        selectedcontacts = new List<contact>();
        system.debug('for sale '+cmp.For_Sale__c);
        for(wrapContact wrapcontactObj : wrapcontactList) {
            if(wrapcontactObj.selected == true) {
                selectedcontacts.add(wrapcontactObj.con);
                
            }
        }
        for(contact s:selectedcontacts){
            s.For_Sale__c=cmp.For_Sale__c;
        }
            try{
                
                database.update(selectedcontacts);
                
            }catch( Exception e ){
                ApexPages.addMessages(e);
            }
            system.debug('selectedcontacts'+selectedcontacts);
            ApexPages.addmessage(new ApexPages.message(ApexPages.severity.CONFIRM,'FID Update on Contact'));
      return pr;   
    }
    public class wrapContact {
        public Contact con {get; set;}
        public string forsaleid{get;set;}
        public Boolean selected {get; set;}
        
        public wrapContact(Contact c) {
            con = c;
            forsaleid=c.For_Sale__c;
            selected = false;
        }
    }
}
How should I show success message on VF Page
& another thing is
here <apex:inputfield style="width: 200px; height: 30px" value="{!Campaign.For_Sale__c}" id="forsaleid"/> when I click on button & page is load the value is already populate on this but I want to clear this value when page populate how can I do that?


 
I want to write a trigger when user insert or change name(whoid) of task then there is field in task object that has to be change with contact name
trigger taskupdatetrigger on Task (after insert,after update) {
    list<task>tasklist=new list<task>();
    list<contact>contactlist=[select id,name from contact];
       id taskid;
    id contactid;
    for(task taskobj:trigger.new){
        taskid=taskobj.id;
        system.debug('task id'+taskid);
        for(contact conobj:contactlist){
            if(taskobj.WhoId==conobj.Id){
            system.debug('inside if');
            /taskobj.POC_name__c=conobj.Name;
                system.debug('POC_name__c'+taskobj.POC_name__c);
        }
            
        }
        
    }
    system.debug('contactlist'+contactlist);
}

this is giving me error on saving "execution of AfterUpdate caused by: System.FinalException: Record is read-only Trigger.Calendar_trigger: line 12, column 1"

I used this code in my vf controller

 public List<SelectOption> getmonth() {
          List<SelectOption> options = new List<SelectOption>();
          options.add(new SelectOption('JANUARY','January'));
          options.add(new SelectOption('FEBRUARY','February'));
          options.add(new SelectOption('MARCH','March'));
        options.add(new SelectOption('APRIL','April'));
        options.add(new SelectOption('MAY','May'));
        options.add(new SelectOption('JUNE','June'));
        options.add(new SelectOption('JULY','July'));
        options.add(new SelectOption('AUGUST','August'));
        options.add(new SelectOption('SEPTEMBER','September'));
        options.add(new SelectOption('OCTOBER','October'));
        options.add(new SelectOption('NOVEMBER','November'));
        options.add(new SelectOption('DECEMBER','December'));                           
          return options;
      }

now I want to show data of may if user select may  how should I do that?
I have a object product I want to update a task field value such as 
Order price is 100 then in task price should be automatically update as 100 I want to do this by workflow