• PINKY REGHU
  • NEWBIE
  • 79 Points
  • Member since 2018

  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 30
    Replies
In my lightning component I am having like this.

<aura:attribute name="claimType"  type="String" default="Pharmacy" description="some pharamcy"/>

I want the default value of the attribute in the controller.js file of the component for further processing.

Please tell me how to do this.

thanks
sheila

 
Hello All,
whenever I click command button it works properly however it refreshed immediately which I want to prevent.
<apex:page id="pgId" controller="calculateBMICon">
    <script language="JavaScript">
        function calculateBmi() {
             var weight =   document.getElementById('pgId:bmiForm:pb:pbs:we').value;
               
            var height =document.getElementById('pgId:bmiForm:pb:pbs:he').value;

            if(weight > 0 && height > 0){   
                var finalBmi = weight/(height/100*height/100)
                document.getElementById('pgId:bmiForm:pb:pbs1:bm').innerHTML =   finalBmi;
              
                if(finalBmi < 18.5){
                    document.getElementById('pgId:bmiForm:pb:pbs1:bw').innerHTML = "UNDER-WEIGHT"
                }
                if(finalBmi > 18.5 && finalBmi < 25){
                    document.getElementById('pgId:bmiForm:pb:pbs1:bw').innerHTML = "NORMAL-WEIGHT"
                }
                if(finalBmi > 25){
                    document.getElementById('pgId:bmiForm:pb:pbs1:bw').innerHTML = "OVER-WEIGHT"
                }
            }
            else{
                alert("Please Fill everything correctly")
            }
        }
    </script>

    <apex:form id="bmiForm">
        <apex:pageblock mode="mainDetail" id="pb">
            <apex:pageBlockSection columns="1" id="pbs">
                <apex:inputText label="{!$objectType.Volunteer__c.fields.Name.label}" />
                <apex:inputText label="{!$objectType.Volunteer__c.fields.Height_in_CMs__c.label}" id="he"/>
                <apex:inputText label="{!$objectType.Volunteer__c.fields.Weight_in_KGs__c.label}" id="we"/>
            </apex:pageBlockSection>
            <apex:pageblockSection id="pbs1">
                <apex:outputLabel id="bm" value=""/>
                 <apex:outputLabel id="bw" value=""/>
            </apex:pageblockSection>
            <apex:pageBlockButtons >
                <apex:commandButton value="Calculate BMI" onclick="calculateBmi()"/>
            </apex:pageBlockButtons>
        </apex:pageblock>

    </apex:form>
         
</apex:page>



Thanks 
  • August 13, 2018
  • Like
  • 0
trigger Product_Schedule on OpportunityLineItem (after update,after insert) 
{
    for ( OpportunityLineItem o : Trigger.new)
    { 
        Opportunity opps;
        // id OppLineItemID = o.Opp_Line_Item_Id__c ;
        id OppLineItemID = o.ID ;
        system.debug('Opurtunity line item triggered ' + o.Opp_Line_Item_Id__c  + 'Opportunity ID ' + o.ID);
        
        opps =  [Select  o.First_Ship_Date__c  ,o.Expected_Return_Ship_Date__c, o.Min_K_QPID__c,
                 (Select Quantity, productcode  From OpportunityLineItems where ProductCode = 'K-QPID') From Opportunity o 
                 Where id IN (SELECT OpportunityId FROM OpportunityLineItem WHERE Quantity > 0 and id =:o.id) ];
        
        OpportunityLineItem prod;
        prod =  [Select Quantity, productcode, Nav_Inventory__c  From OpportunityLineItem where Opp_Line_Item_Id__c =:o.Opp_Line_Item_Id__c];
        
        Datascan_Product_Availability__c Avail = [select K_QPID__c , Count_Date__c From Datascan_Product_Availability__c c 
                                                  where (c.Count_Date__c > :opps.First_Ship_Date__c) and (c.Count_Date__c < :opps.Expected_Return_Ship_Date__c) 
                                                  order by Count_Date__c asc limit 1 ];
        
        opps.Min_K_QPID__c  = Avail.K_QPID__c ;
        opps.Min_K_QPID_Date__c = Avail.Count_Date__c;
        update opps;
        
        //select MIN(K_DS_WIFI_1__c) From Datascan_Product_Availability__c where count_date__C > 2019-10-18 and count_date__c < 2019-11-22
        system.debug('opps ' + opps.First_Ship_Date__c + opps.Expected_Return_Ship_Date__c );
        system.debug('prod ' + prod.quantity + prod.productcode );
        system.debug('Avail ' + Avail.K_QPID__c  );
        
    }
}
  • October 30, 2019
  • Like
  • 0
Please Help me to write test class for below apex class controller


abc.apexclass


public class EmailInvoiceA {
    
    @auraEnabled
    public static void sendMailWithPDF(String recordId){
        
        for(Invoice__c cc : [select Id,Distributor__r.E_mail__c,Distributor__r.CC_to_if_any__c,Distributor__r.Name from Invoice__c WHERE Id =: recordId]){
            list<Messaging.SingleEmailMessage> mails =  new List<Messaging.SingleEmailMessage>();  
            Messaging.SingleEmailMessage semail = new Messaging.SingleEmailMessage();
            List<String> sendTo = new List<String>();//to string
        
            Messaging.EmailFileAttachment attach = new Messaging.EmailFileAttachment();
            PageReference pref = page.PdfEmailInvoice;
            pref.getParameters().put('Id',recordId);
            pref.setRedirect(true);
            Blob b;
            b = pref.getContent();
            attach.setFileName('Invoice.pdf');
            attach.setBody(b);
            semail.setSubject('Invoice details');
            semail.setReplyTo('noreply@gmail.com');
            semail.setSenderDisplayName('salesforce User');
           
           sendTo.add(cc.Distributor__r.E_mail__c);
            
            List<String> send = new List<String>();//cc string
            system.debug('sendlis'+send);
        //    if(cc.Distributor__r.CC_to_if_any__c != null)
      //      {
        //         send.add(cc.Distributor__r.CC_to_if_any__c);
                 
     //       }
            
            if(cc.Distributor__r.E_mail__c==null && cc.Distributor__r.CC_to_if_any__c != null)
            {  
                
                send.add(cc.Distributor__r.CC_to_if_any__c);
               //semail.setccAddresses(sendTo);
               semail.setToAddresses(send);
           
            }
            else if(cc.Distributor__r.E_mail__c !=null && cc.Distributor__r.CC_to_if_any__c != null)
            {
                sendTo.add(cc.Distributor__r.E_mail__c);
                send.add(cc.Distributor__r.CC_to_if_any__c);
                
              semail.setccAddresses(send);
              semail.setToAddresses(sendTo);
                
           }
           else if(cc.Distributor__r.E_mail__c !=null && cc.Distributor__r.CC_to_if_any__c == null)
            {
                
              sendTo.add(cc.Distributor__r.E_mail__c);
               
                   semail.setToAddresses(sendTo);
         }
       
        
                mails.add(semail);
            String emailBody =' <html><body><p> Dear '+ cc.Distributor__r.Name+' ,<br><br> Please find the attached Invoice details. <br><br>    Regards, <br> IT Team <br>  Sayaji Groups.</p></body></html>';
            semail.setHtmlBody(emailBody);
            semail.setFileAttachments(new Messaging.EmailFileAttachment[]{attach});
            Messaging.sendEmail(new Messaging.SingleEmailMessage[]{semail});
        }
    }    
  
    
    @auraEnabled
     public static void sendMailWith(String recordId,String mMail){
        
        for(Invoice__c cc : [select Id,Distributor__r.E_mail__c,Distributor__r.CC_to_if_any__c,Distributor__r.Name from Invoice__c WHERE Id =: recordId]){
            list<Messaging.SingleEmailMessage> mails =  new List<Messaging.SingleEmailMessage>();  
            Messaging.SingleEmailMessage semail = new Messaging.SingleEmailMessage();
            List<String> sendTo = new List<String>();
            sendTo.add(mMail);
            Messaging.EmailFileAttachment attach = new Messaging.EmailFileAttachment();
            PageReference pref = page.PdfEmailInvoice;
            pref.getParameters().put('Id',recordId);
            pref.setRedirect(true);
            Blob b;
            b = pref.getContent();
            attach.setFileName('Invoice.pdf');
            attach.setBody(b);
            semail.setSubject('Invoice details');
            semail.setReplyTo('noreply@gmail.com');
            semail.setSenderDisplayName('salesforce User');
           
            //sendTo.add(cc.Distributor__r.E_mail__c);
              List<String> send = new List<String>();
            if(cc.Distributor__r.CC_to_if_any__c != null)
            {
                 send.add(cc.Distributor__r.CC_to_if_any__c);
                 
            }
         
            mails.add(semail);
            semail.setCcAddresses(send);
            semail.setToAddresses(sendTo);
            String emailBody =' <html><body><p> Dear '+ cc.Distributor__r.Name+' ,<br><br> Please find the attached Invoice details. <br><br>    Regards, <br> IT Team <br>  Sayaji Groups.</p></body></html>';
            semail.setHtmlBody(emailBody);
            semail.setFileAttachments(new Messaging.EmailFileAttachment[]{attach});
            Messaging.sendEmail(new Messaging.SingleEmailMessage[]{semail});
            system.debug('email send');
        }
    }    
  
    
     @auraEnabled
   public static void Mail(String recordId,String mMail,boolean checkCmp){
        
        for(Invoice__c cc : [select Id,Distributor__r.E_mail__c,Distributor__r.CC_to_if_any__c,Distributor__r.Name from Invoice__c WHERE Id =: recordId]){
            list<Messaging.SingleEmailMessage> mails =  new List<Messaging.SingleEmailMessage>();  
            Messaging.SingleEmailMessage semail = new Messaging.SingleEmailMessage();
            List<String> sendTo = new List<String>();//to string
           
              system.debug(checkCmp);  
           
       //     semail.setToAddresses(sendTo);
          //shrutinigam1998@gmail.com  
        
            Messaging.EmailFileAttachment attach = new Messaging.EmailFileAttachment();
            PageReference pref = page.PdfEmailInvoice;
            pref.getParameters().put('Id',recordId);
            pref.setRedirect(true);
            Blob b;
            b = pref.getContent();
            attach.setFileName('Invoice.pdf');
            attach.setBody(b);
            semail.setSubject('Invoice details');
            semail.setReplyTo('noreply@gmail.com');
            semail.setSenderDisplayName('salesforce User');
            
            
            
           if(checkCmp==true)
               {
                  sendTo.add(mMail);
                   semail.setToAddresses(sendTo);
               }
           else  if(checkCmp==false)
            {
               system.debug('hi check'+checkCmp);
              if(mMail != null)
            {
                 system.debug('hi mMail'+mMail);
                sendTo.add(mMail);
                semail.setToAddresses(sendTo);
            }
                
             if(cc.Distributor__r.E_mail__c != null)
            { system.debug('hi Distributor mail'+cc.Distributor__r.E_mail__c);
               sendTo.add(cc.Distributor__r.E_mail__c);  
                semail.setToAddresses(sendTo);
            } 
                
             if(cc.Distributor__r.CC_to_if_any__c != null)
   
            { 
                system.debug('hi Distributor cc mail'+cc.Distributor__r.CC_to_if_any__c);
                List<String> send = new List<String>();//cc string
                send.add(cc.Distributor__r.CC_to_if_any__c);  
               semail.setCcAddresses(send);
           }   
                
                
                
            }
            
      
            mails.add(semail);

            String emailBody =' <html><body><p> Dear '+ cc.Distributor__r.Name+' ,<br><br> Please find the attached Invoice details. <br><br>    Regards, <br> IT Team <br>  Sayaji Groups.</p></body></html>';
            semail.setHtmlBody(emailBody);
            semail.setFileAttachments(new Messaging.EmailFileAttachment[]{attach});
            Messaging.sendEmail(new Messaging.SingleEmailMessage[]{semail});
            system.debug('email send');
        }
    }       
}
Hello all 

My requirement is that whenever i change the status in the picklict field different color should pop up,
In my requirement i have picklist field called flat status, in that there are 3 fields (Sold,available,Booked), whenever i click on Sold it should show as "red", when i click on Available it should show as "Green", when i click on booked it should show as "Yellow"

for this i have tried formula field and written a formula as
IMAGE( 
CASE(Project_Status__c, 
"Green", "/img/samples/light_green.gif",
"Yellow", "/img/samples/light_yellow.gif",
"Red", "/img/samples/light_red.gif", 
"/s.gif"), 
"status color")

The error shows as " Error: Field Flat_Status__c is a picklist field. Picklist fields are only supported in certain functions"

Is there any better way to achive this

Any Help or suggestion would be Highly appreciated
 
I am trying to use a custom controller to get back case comments for a particular case (case id will be in URL).  I need to do this so I can sort columns (very annoying that Salesforce doesn't allow this with dataTables).  Right now I'm just trying to get some data back from my controller and failing miserably.

How can I do this?

So far this doesn't work....
****My test VF page****
<apex:page standardController="Case" extensions="TestController"> 
    <apex:form >   
        <apex:pageBlock title="{!Case.CaseNumber}"> 
			TEST:{!caseComm[0].CommentBody}
        </apex:pageBlock>   
    </apex:form>  
</apex:page>
***My test controller***
public class TestController {
    public List<Case> caseComm {get;set;}
    
    public TestController(ApexPages.StandardController controller) {
		
    }
    
    public List<Case> caseComm() {   
		List<Case> comments = [Select (Select Id, 
                            ParentId,  
                            IsPublished, 
                            CommentBody, 
                            CreatedById, 
                            CreatedDate,                  
                            LastModifiedDate, 
                            LastModifiedById, 
                            From CaseComments) From Case ];
        return comments;
    }
    
    
}


 
In my lightning component I am having like this.

<aura:attribute name="claimType"  type="String" default="Pharmacy" description="some pharamcy"/>

I want the default value of the attribute in the controller.js file of the component for further processing.

Please tell me how to do this.

thanks
sheila

 
I have multiple related lists which appear in the Contact page. I would like a way to only show related list sections if a record exists for the related object. From a design perspective I was thinking of adding custom button / quick action for each related object and if a user creates a related record then the actual related section will appear on the page.

Is this possible and if so could any guide me on how I can achieve it?
Hi, What is the query limit for @future method and can i use future method to fetch more that 50,000 reocords
Hello,

On vf page I wnat  to delete multiple record   on seletct checkbox  using delte button. I have implemented using wrapper class but I don't want use wraper class.

User-added image
----------------------Controller---------------------

public with sharing class SRC_ServiceCloudHomePage4 {

  public List<product2> productlist{
        get {
            if (productlist== null) {
                productlist=  [select id, IsActive, Name, ProductCode, Battery_Type__c, Product_Image__c, Purchase_Date__c, Warranty__c, Description from Product2 where Battery_Type__c != 'Radio Battery'
       ];
            }
            return productlist;
        }
        set;
    }
    
    
       public List<Case> caseList{
        get {
            if (caseList == null) {
                caseList=[select id, Owner.Name, CaseNumber, Description, Product_Code__c, Reason, Status, Origin, CreatedDate From Case  ];
            }
            return caseList;
        }
        set;
      }
      
      
      
       public List<Observance_Managment__C > omlist{
        get {
            if (omlist== null) {
                omlist=[select id, Name, Owner.Name, Status__C, Battery_Number__c, Within_Warranty__c, Observed_Problem__c, Description__c, Case__r.CaseNumber from Observance_Managment__c  ];
            }
            return omlist;
        }
        set;
      }
      
     public product2 prData {get;set;}
     
    public String paramprouctId{get;set;}
    public Boolean displayPopUp {get;set;}
        

    public PageReference showPopup() {

         prData =  [select id, IsActive, Name, ProductCode, Battery_Type__c, Product_Image__c, Purchase_Date__c, Warranty__c, Description from Product2 where id=:paramprouctId];
        displaypopup = true;

        return null;

    }
    
   
    public String productId{get;set;}
    public product2 prData1{get;set;}
    
    public void deleteRecord()
    {
        System.debug('before calling delete methode'+productId);

            System.debug('************************'+productId);    

    
//            String productId= System.currentPageReference().getParameters().get('row_id');

        prData1=new product2();
        System.debug('prId'+productId);    
        prData1=[select id, IsActive, Name, ProductCode, Battery_Type__c, Product_Image__c, Purchase_Date__c, Warranty__c, Description from Product2 where id=:productId];
        System.debug('prData'+prData1);
      delete prData1;
        
    
    }

     
     
    
   
      
}


 
  • August 31, 2018
  • Like
  • 0
Am Selecting Contract Begining Date in a Visual Force Page
User-added image
When I select Contract Begining Date populating Contract Ending Date
User-added image
Now i would like show Contract Ending Date automatically empty when Contract Begining Date is empty
User-added image
VF Page Code:
<apex:actionRegion >
<apex:inputField value="{!cont.Contract_Beginning_Date__c}" taborderhint="2" Style="margin-left:0.0%;" required="true" >
<apex:actionSupport event="onchange" action="{!AccAddress}" rerender="rty"/>
</apex:inputField>
</apex:actionRegion >

Apex Code:

Public void AccAddress()
    {   
        if(cont.Contract_Beginning_Date__c!= null)
        {
            cont.Contract_Ending_Date__c = cont.Contract_Beginning_Date__c.addMonths(6);
        }
        if(cont.Contract_Beginning_Date__c == null)
        {
             cont.Contract_Ending_Date__c = null;             
        }
    }    
error is in <apex:outputPanel rendered="{!IF(finance__c.Income__c >=0,true,false)}"/> in <outputpanel> component .

I am trying to first check null values for the field to void the error,but i am stuck

Previouly  we have <apex:outputPanel rendered="{!IF(finance__c.Income__c >=0,true,false)}">
after that we got a requirment to check first if field value is nulll so i tried   something like
<apex:outputPanel rendered="{!!IsNull(finance__c.Income__c) && finance__c.Income__c > 0}">
$<apex:outputField value="{!finance__c.Income__c}" />
                        </apex:outputPanel> 

The element type "apex:outputpanel" must be terminated by the matching end-tag "</apex:outputpanel>".

i already terminated output panel not sure what i am missing. can someone help me with syntax
first i have to check if value is null and if not than i have to check whether it is greater than or quel to 0 and than i havr to disply the field.

thanks in advace
please help me with the solution
 
//This is an extension controller class
public class Speaker_conf_extension {

     private final Speaker__c speaker; // speaker__c is custom object and standard controller which is using This(Speaker_conf_extension)                                                                           //extension class
     
      private ApexPages.StandardController sController;
    
    public Speaker_conf_extension(ApexPages.StandardController scontroller) {
    
    this.speaker= (speaker__C)scontroller.getRecord();
    this.scontroller = scontroller;
    
    }

public PageReference save() {
..................................
...............................
...............
return null;
}

This extension_controller is trying to over ride Save button and insert an InputFile field to upload image.
I didn't understand what the  constructor of extension_controller is doing . Please explain the behaviour ,Thank you 
ListOfAccounts VfPage
<apex:page controller="Controller1" >
<apex:form >
<apex:PageBlock title="Account">
<apex:outputLabel value="Enter Account Name: ">
<apex:inputText value="{!AccountName}"/>
</apex:outputLabel>
<apex:commandButton value="Search" action="{!Display}"/>
    </apex:PageBlock>
<apex:pageBlock title="The list of account are" rendered="{!b2}">
<apex:outputText  value="{!Error}"></apex:outputText>    
</apex:pageBlock>
<apex:pageBlock title="The list of account are" rendered="{!b1}">   
<apex:pageBlockTable value="{!acclist}" var="b">
  
<apex:column headerValue="Action">
<apex:inputCheckbox value="{!b.Checked}"/>
</apex:column>
    <apex:column value="{!b.acc.Name}"/>

</apex:pageBlockTable>


 <apex:pageBlockButtons >
    <apex:commandbutton value="Get Details" action="{!Details}" />
        </apex:pageBlockButtons>
</apex:PageBlock>
</apex:form>
</apex:page>

SelectedAccounts VfPage
<apex:page controller="Controller1" >
<apex:pageBlock Title="Details of selected accounts are">
<apex:pageBlockTable value="{!Selected}" var="c">
    <apex:column value="{!c.id}" />
    <apex:column value="{!c.Name}"/>
    <apex:column value="{!c.type}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>

Controller1-->Custom Controller
public class Controller1 {
public string AccountName{Get;Set;}
public list<waccount> acclist{Get;Set;}
public list<Account> selected{Get;Set;}
public boolean b1{Get;Set;}
public boolean b2{Get;Set;}
public string Error{Get;Set;}
public void Display()
{
    if(acclist==null)
    {
        acclist=new list<waccount>();
        list<Account> ls=[select name,type from account where name=:AccountName];
        if(ls.size()>0)
        {
        b1=true;
        for(Account a:ls)
        {
            acclist.add(new waccount(a));
        }
        }
        else
        {
            b2=true;
            Error='No Account Found with that name';
        }
    }
}
public PageReference Details()
{
    selected=new List<Account>();
    for(waccount w:acclist)
    {
        if(w.checked==true)
        {
            selected.add(w.acc);
        }
    }
    return page.SelectedAccounts;
}
public class waccount
{
    public Account acc{get;set;}
    public boolean checked{get;set;}
    public waccount(Account acc)
    {
       this.acc=acc;
       checked=false;
    }
}
}

Can Anyone help me with test class for above controller 
Hi we are using javascript remoting in visualforce pages. There is a method in javascript that is passing a password in encrypted form using btoa function. Then this data is recieving by one Apex method which is annotated by @remoteAction. But how i can decrypt that password in Apex. Please help in this.
Hello All,
whenever I click command button it works properly however it refreshed immediately which I want to prevent.
<apex:page id="pgId" controller="calculateBMICon">
    <script language="JavaScript">
        function calculateBmi() {
             var weight =   document.getElementById('pgId:bmiForm:pb:pbs:we').value;
               
            var height =document.getElementById('pgId:bmiForm:pb:pbs:he').value;

            if(weight > 0 && height > 0){   
                var finalBmi = weight/(height/100*height/100)
                document.getElementById('pgId:bmiForm:pb:pbs1:bm').innerHTML =   finalBmi;
              
                if(finalBmi < 18.5){
                    document.getElementById('pgId:bmiForm:pb:pbs1:bw').innerHTML = "UNDER-WEIGHT"
                }
                if(finalBmi > 18.5 && finalBmi < 25){
                    document.getElementById('pgId:bmiForm:pb:pbs1:bw').innerHTML = "NORMAL-WEIGHT"
                }
                if(finalBmi > 25){
                    document.getElementById('pgId:bmiForm:pb:pbs1:bw').innerHTML = "OVER-WEIGHT"
                }
            }
            else{
                alert("Please Fill everything correctly")
            }
        }
    </script>

    <apex:form id="bmiForm">
        <apex:pageblock mode="mainDetail" id="pb">
            <apex:pageBlockSection columns="1" id="pbs">
                <apex:inputText label="{!$objectType.Volunteer__c.fields.Name.label}" />
                <apex:inputText label="{!$objectType.Volunteer__c.fields.Height_in_CMs__c.label}" id="he"/>
                <apex:inputText label="{!$objectType.Volunteer__c.fields.Weight_in_KGs__c.label}" id="we"/>
            </apex:pageBlockSection>
            <apex:pageblockSection id="pbs1">
                <apex:outputLabel id="bm" value=""/>
                 <apex:outputLabel id="bw" value=""/>
            </apex:pageblockSection>
            <apex:pageBlockButtons >
                <apex:commandButton value="Calculate BMI" onclick="calculateBmi()"/>
            </apex:pageBlockButtons>
        </apex:pageblock>

    </apex:form>
         
</apex:page>



Thanks 
  • August 13, 2018
  • Like
  • 0
HI,

I need to display opportunity fields as dropdown in VF page. can anyone suggest me the idea?
Suggest a soql query to find duplicates in Account objects . R1_ACC_TXT_Id_Golden_record__c is a primay key on our Account object.I am using below query to find all instnaces of an Account in our org but the query is timing out.
SELECT count(Id) FROM Account GROUP BY R1_ACC_TXT_Id_Golden_record__c HAVING count(Id)>1