• Footprints on the Moon
  • NEWBIE
  • 254 Points
  • Member since 2020

  • Chatter
    Feed
  • 8
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 39
    Replies
I'm setting up a custom "Graduating Class" field for our contacts. I want users to either leave the field blank or enter numbers in the field in the YYYY format (no commas). How do you recommend I write the validation rule?

So far I have NOT(ISNUMBER( Graduating_Class__c )) to strip the comma, but I'm not sure how to modify to allow for a blank option.
Hello,

I am updating the records in below usecase:

- Get 60000 records by SOQL
- Prepare a list of 5000 records
- Update abouve records

As the operation is one time and long, how can i update the list using Batch.

thank you for rough code, please
  • July 27, 2020
  • Like
  • 0
Hey whatsup,

what does this mean?
 
Product2 pro;
            if ((pro = (Product2)Tools.findRecordByValue(pros, 'Id', rec.Product2Id)) != null) {
... some code here
}

Tools is a class I have a method called findRecordByValue, but WHAT IS THIS????
 
(Product2)Tools.findRecordByValue
Why is (Product2) before the Tools method???

Can someone give me a link to explanation about what this is? It seems like a java fundamental thing.

 
User-added imagewhy am I getting this error?
Hello there , 

I have a little problem here in my org , I have a field in order a dropdown list with Booked/Not Yet booked , what I wannt to do is: 
When i click this field Booked it is a picklist I want to change the other field to Today ()

So when i click Booked field i want to change the date to today other field :) 

Cheers
Hi Experts,

I am getting below error which i dont know how to solve.. Pls help.

Kindly help in resolving.

My controller

public class ViewQAAMController {

    public List<AggregateResult> BadgeList { get; set; }
   
    public List<AggregateResult> getBadgeList()
  {
          List<AggregateResult> badges = [select Week__c apple from QAAM_Weekly_Planner__c Max group by Week__c order by max(createddate) desc LIMIT 10];
          return badges;
  }
 
}

My VF page

<apex:page controller="ViewQAAMController">
<apex:form >
<apex:pageBlock >

<apex:pageBlockTable value="{!BadgeList}" var="data" >

    <apex:column value="{!data.Week__c}"/>

</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>

Error: Invalid field Week__c for SObject AggregateResult

Pls help.

Regards
Karthic Sankar V P

Hi Awesome coders, I am new to programming and need help with this Trigger. Your help is greatly appreciated !!

I have two Objects, 
1. Package_Shipment_Order__c (Parent) , 
2.Package_Shipment_Delivery__c (Child) M_Detail relationship . 
Parent object has a multi select picklist field ‘States__c’ . When User selects a couple of states, child records to be created on Package_Shipment_Delivery__c. Error is highlighted in Bold

trigger PicklistCreateChild on Package_Shipment_Order__c (after insert , after update) {
List<Package_Shipment_Delivery__c> PkgShipDe = new List<Package_Shipment_Delivery__c>();
    for(Package_Shipment_Order__c PkgShipOr : Trigger.new){
        if (PkgShipOr.Shipment_States__c != Null){
            List<String> ShipStates = PkgShipOr.Shipment_States__c.Split(';');
            If(ShipStates != Null && ShipStates.size()>0){
                for (String ShipSt : ShipStates){
       Package_Shipment_Delivery__c PkShipDe = new Package_Shipment_Delivery__c();   
       PkShipDe.Package_Shipment_Orders__c = PkgShipOr.Id;
       PkShipDe.State__c = PkgShipDe.get(ShipSt);  
                    PkgShipDe.add(PkShipDe) ;
                }
            }
        }
    Insert PkgShipDe;
Component: 

<aura:attribute name="negotiatePrice" type="Integer" />

<table class="slds-table slds-table--bordered slds-table--cell-buffer">
                  <tbody>
<aura:iteration items="{!v.userList}" var="con" aura:id="usrLst">
                                <tr>
                                    <th scope="row">
                                        <div class="slds-truncate" title="{!con.Name}">{!con.Name}</div>
                                    </th>
                                    <th scope="row">
                                        <div aura:id="usrLic" class="slds-truncate" title="{!con.TotalLicenses}">{!con.TotalLicenses}</div>
                                    </th>
                                    <th scope="row"> 
                                   <aura:iteration items="{!v.costList}" var="cst">                                     
                                   <aura:if isTrue="{!con.Name == cst.Name}">                                   
                                   <div class="slds-truncate" title="{!cst.License_Price_Per_Month__c}">{!cst.License_Price_Per_Month__c}</div>
                                   </aura:if>
                                   </aura:iteration>
                                        </th>
                                    
                                    <th scope="row" >
                                     <div class="slds-truncate">
                                    <input type="number" aura:id="myAtt" placeholder="Enter Negotiated Price" class="slds-input inputField"  value="{v.negotiatePrice}" onchange="{!c.CalculatePrice}" /> 
                               
                                    </div>
                                        </th>
                                   
                                    </tr>   
                                </aura:iteration>
 </tbody>
                    </table>

Controller:

CalculatePrice : function(component, event, helper) {  
        
        alert('Calculate');
          var nPrice = component.find("myAtt");
          var negotiatePrice = nPrice.get("v.value");
        
         alert('negotiatePrice'+negotiatePrice);
        
    },  
object[quote line__c] have a lookup field [product master__c] with product object and two custom currency field  one  is base_price__c and other selling_price__c.
I want a trigger, 
when removing the product from the lookup field then automatically assign the null value in the other two mentioned field.

please help.
trigger Emailnotification on Student__c (after insert) {

  List<Messaging.SingleEmailMessage> mails = new list<Messaging.SingleEmailMessage>();
  
  for (Student__c stu : Trigger.new) {
      
      Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
      List<String> sendTo = new List<String>();
      sendTo.add(stu.Email__c);
      mail.setToAddresses(sendTo);
      mail.setSenderDisplayName('salesforceAdmin');      
      mail.setSubject('Welcome Aboard');
      String body = 'Dear ' + stu.Name__c + ', \n';
      body += 'Thankyou for Choosing sfdc.';
      body += 'You selected '+ stu.Trainer__r.Name+' as your trainer' ;
      mail.setHtmlBody(body);
      mails.add(mail);
    }
  
  Messaging.sendEmail(mails);
}
I am writing a trigger to update two currency field as null when a lookup field is Null but I getting the error when try to update record"
Get_ProductPrice_On_Sq_lines: execution of AfterUpdate caused by: System.StringException: Invalid id: Trigger.Get_ProductPrice_On_Sq_lines: line 65, column 1"User-added imagei am new in this plse help..ASAP

 

I have some apex i want to run but only if Quotes are an enabled feature, i have tried to check this by doing the following.

public static Boolean sfQuotesEnabled () {
        boolean enabled;
        // sObject types to describe
        String[] types = new String[]{'Quote'};
            Schema.DescribeSobjectResult[] results;
            try{
                // Make the describe call
        		results = Schema.describeSObjects(types);
            }catch(DmlException e){
        		System.debug('sfQuotesEnabled: failed to get object type');
                enabled = false;
            }
        System.debug('Got describe information for ' + results.size() + ' sObjects.');
        
        if(results.size() > 0){
            enabled = true;          
        }
        return  enabled;
    }

Unfortunatly this is resulting in an "Entity is not org-accessible" error when i disable Quotes and the Apex falls over (does not continue to the catch) can somone help identify what my issue is / how i can do this check.
I'm setting up a custom "Graduating Class" field for our contacts. I want users to either leave the field blank or enter numbers in the field in the YYYY format (no commas). How do you recommend I write the validation rule?

So far I have NOT(ISNUMBER( Graduating_Class__c )) to strip the comma, but I'm not sure how to modify to allow for a blank option.
Hello,

I am updating the records in below usecase:

- Get 60000 records by SOQL
- Prepare a list of 5000 records
- Update abouve records

As the operation is one time and long, how can i update the list using Batch.

thank you for rough code, please
  • July 27, 2020
  • Like
  • 0
I have custom field in case of datatype datetime, which is being used in one of the other custom formula field to count number of days from last updated. 
So everytime there is an update on the case, this field gets updated, but I am not able to figure out from where this field is getting updated?
 
I did search in apex class and trigger (searched using Enhanced code searcher chrome plugin)
I checked all workflows in Case object 
I checked all process builder flows(only 2 for case object)

Is there any place I missed where a field udpate can happen. ? 
Hello there,

I have a bit of trouble correctly displaying my data:

my apex class:
 
public class QuoteList {

public Opportunity currentOpp {get;set;}
public List<Quote> quotes  {get;set;} 

 public QuoteList(ApexPages.StandardController stdController) {
     currentOpp  = [SELECT Id FROM Opportunity WHERE ID =: stdController.getID()];
     }
    
public PageReference getPdfs() {         

quotes = [SELECT Id,Name,(SELECT Id,CreatedDate,Name,ContentVersionDocumentId,QuoteId FROM QuoteDocuments)FROM Quote WHERE OpportunityId = :currentOpp.id];


return null;
}
}

my visualforce page:
 
<apex:page standardcontroller="Opportunity" extensions="QuoteList" lightningStylesheets="true" action="{!getPdfs}">  
       
    
  <apex:form >
<apex:pageBlock >  
    <apex:repeat value="{!quotes}" var="quote">
    
      <apex:pageBlockTable value="{!quote.QuoteDocuments}" var="pdf" >

        <apex:column headerValue="Name">
        <apex:outputlink value="https://meinestadt--syncs.my.salesforce.com/servlet/servlet.FileDownload?file={!pdf.id}" target="_blank">{!pdf.Name}</apex:outputlink>
       </apex:column>
       
        <apex:column value="{!pdf.CreatedDate}"/>
       
     </apex:pageBlockTable>
  
    </apex:repeat>

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

the result:

User-added image
I am doing almost identical code (class & vf) when I display all contacts from the account related to a task - this works just fine:

User-added image
Where did I go wrong?

Thanks!
Hi Experts,

Can anyone pls help me why I am gettting NULL value here.

MY Contoller

public class ViewQAAMController {

    public PageReference MyMethod() {
        System.debug('I am called');
        pageReference pg = new pageReference('http://www.google.com/');
        pg.setRedirect(true);
        return pg;
    }
    
    public void callMe()
    {
        System.debug('I am called by JavaScript' + ValueFromVF);
        
    }


    public String valueFromVF { get; set; }
    //valueFromVF
   
    public List<AggregateResult> BadgeList
  {
      get
      {
          List<AggregateResult> badges = [select Week__c, max(createddate) apple from QAAM_Weekly_Planner__c Max group by Week__c order by max(createddate) desc LIMIT 10];
          return badges;
      }
      set;
  }
    
   }

My VF page:

<apex:page controller="ViewQAAMController">
<apex:form >
<apex:actionFunction action="{!callMe}" name="callthisinJavaScript" reRender="a" />
<apex:pageBlock >

<apex:pageBlockTable value="{!BadgeList}" var="data" align="center" styleClass="table table-striped" >
<apex:column headerValue="MyValues">
<apex:outputLink value="{!data['Week__c']}" onclick="openWindow()">{!data['Week__c']}</apex:outputLink>
<apex:param name="weekValue" value="{!data['Week__c']}" assignTo="{!valueFromVF}"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
<script>
function openWindow(){
         window.open('/apex/AddQAAMWeeklyPlanner');
         alert(callthisinJavaScript());
         callthisinJavaScript();
        }
    </script>
</apex:page>


I am getting value as NULL in controller

Regards
Karthic
 
The requirement is about fetching and displaying the data completely dynamic based on the object and field selection. The display of the data from various objects (either related or not-related) should be like how we see in reports. Based on the fields selected to bring the matched data from selected objects and should be represented/displayed in the below format. I request your valuable suggestions/ideas to start with. 
User-added imageThanks in Advance !!!
Hey whatsup,

what does this mean?
 
Product2 pro;
            if ((pro = (Product2)Tools.findRecordByValue(pros, 'Id', rec.Product2Id)) != null) {
... some code here
}

Tools is a class I have a method called findRecordByValue, but WHAT IS THIS????
 
(Product2)Tools.findRecordByValue
Why is (Product2) before the Tools method???

Can someone give me a link to explanation about what this is? It seems like a java fundamental thing.

 
Following is my Apex class:

public class Calculator {
    
    public Decimal Operand1 {get;set;}
    public Decimal Operand2 {get;set;}
    public Decimal Result   {get;set;}
    public String errMessage {
        get { return errMessage;}
        set { errMessage='No Error';
              system.debug('in setter errMessage: '+ errMessage);}
    }
    
    public  Void Addition (){
        Result=Operand1+Operand2;
            //errMessage=null;
            }
    
    public  Void Substraction (){
        Result=Operand1-Operand2;
            //errMessage=null;
            }    
    
    public  Void Multiplication (){
        Result=Operand1*Operand2;
            //errMessage=null;
            }
    
    public  Void Division (){
        if (Operand2 != 0 ){
            Result=Operand1/Operand2;
            //errMessage=null;
            }
        else
        {   
            Result=Null;
            errMessage= ' Operand can not be Zero';
            system.debug('in Action method errMessage: '+ errMessage);
         }
    }
}

And Following is from Anonymous block to run the above class.
---------------------------------------------------------------
Calculator Calc = new Calculator();
Calc.Operand1=5;
Calc.Operand2=0;
Calc.Division();
system.debug('Final Result: ' + Calc.Result);
system.debug('Final errMessage: ' + Calc.errMessage);
--------------------------------------------------------

Why I don't see the error message "Operand can not be Zero" when i run the above.  
Hello, I'm new-ish to apex and am trying to copy over an existing Class we have in our current org. Can someone help me with this one?

Error : Error: Compile Error: Method does not exist or incorrect signature: void assembleFinAcctName(FinServ__FinancialAccount__c, Map<String,Beneficiary__c>) from the type ReportAsset at line 51 column 10

public ReportAsset(FinServ__FinancialAccount__c a,Map<String,String> rtMap,Map<String,String> bfNoteMap,Map<String,Beneficiary__c> primaryBMap,Account household, Boolean isRMD) {
    initialize();
    
        this.itemDate = a.As_of_Date__c;
        if (this.itemDate == NULL) {
          this.itemDate = date.today();
        }
        this.isRMD = isRMD;
User-added imagewhy am I getting this error?

Hi All,
 Can anyone help me to increase my test class code coverage to 100%, This is my first test class, Now my test class coverage is 85%, I want to increase the code coverage to 100%, What are the changes i need to do in my test class to get code coverage of 100%?

My Apex Class :

public class UpdateContactAddress {
    public void  updateContact(List<ID> contactId){
        List<Contact> contactSO = [Select id,MailingAddress,AccountId from Contact Where id=:contactId];
        List<Contact> contactList = new List<Contact>();
            for(Contact con : contactSO){
                //for(Account acc: [Select BillingCity,BillingStreet from Account where id=:con.AccountId]){
                       Account account = [Select BillingCity,BillingStreet from Account where id=:con.AccountId];
                        con.MailingCity  = account.BillingCity;
                       con.MailingStreet = account.BillingStreet;
                    contactList.add(con);
                //}
                }
         update contactList;
    }
}
Trigger Code:
trigger IFAddrChangedUpdateContact on Account (after Update) {
    List<Id> contactIds = new List<Id>();
    List<Id> accountIds = new List<Id>();
    for(Account acc: Trigger.New){
    for(Contact con : acc.Contacts){
          contactIds.add(con.id);
    }
    }
    UpdateContactAddress obj = new UpdateContactAddress();
        obj.updateContact(contactIds);
}
Test Method:
@isTest
public class TestUpdateContactAddress {
    @isTest static void TestupdateContact() {
        Test.startTest();
        Account Acc1 = new Account(Name = 'Acc1 by Test',BillingCity = 'Chennai',BillingStreet = 'Lakeview Street');
        insert Acc1;
         Account Acc2 = new Account(Name = 'Acc2 by Test',BillingCity = 'Chennai',BillingStreet = 'Lakeview Street');
        insert Acc2;
        Contact con1 = new Contact(LastName='Contact created using test1', AccountId=Acc1.Id);
        Contact con2 = new Contact(LastName='Contact created using test2', AccountId=Acc1.Id);
        insert con2;
        insert con1;
         Contact con3 = new Contact(LastName='Contact created using test1', AccountId=Acc2.Id);
        Contact con4 = new Contact(LastName='Contact created using test2', AccountId=Acc2.Id);
        insert con3;
        insert con4;
        Account account1 = [Select Id,BillingCity,(SELECT ID from Contacts) from Account Where id =: Acc1.Id];
        account1.BillingCity='Vellore';
        update account1;
        Account account2 = [Select Id,BillingCity,(SELECT ID from Contacts) from Account Where id =: Acc1.Id];
        account2.BillingCity='Bangalore City';
        update account2;
        Test.stopTest();
    }
}
 

In the trigger code, I got only 85% code coverage and my apex class covered 100%. It shows,  contactIds.add(con.id);  this line is not covered.Please help me to cover my trigger code to 100%. 

Hi Experts,

Can u pls let me know how to pass argument from my VF page to controller, using javaScript?

My VF page

<apex:page controller="ViewQAAMController">
<apex:form >
<apex:actionFunction action="{!callMe}" name="callthisinJavaScript" reRender="a" />
<apex:pageBlock >

<apex:pageBlockTable value="{!BadgeList}" var="data" align="center" styleClass="table table-striped" >
<apex:column headerValue="MyValues">
<apex:outputLink value="{!data['Week__c']}" onclick="openWindow()">{!data['Week__c']}</apex:outputLink>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
<script>
function openWindow(){
         window.open('/apex/AddQAAMWeeklyPlanner');
         alert(callthisinJavaScript());
         callthisinJavaScript();
        }
    </script>
</apex:page>

My controller:

public class ViewQAAMController {

    public PageReference MyMethod() {
        System.debug('I am called');
        pageReference pg = new pageReference('http://www.google.com/');
        pg.setRedirect(true);
        return pg;
    }
    
    public void callMe()
    {
        System.debug('I am called by JavaScript');
    }


    //public List<AggregateResult> BadgeList { get; set; }
   
    public List<AggregateResult> BadgeList
  {
      get
      {
          List<AggregateResult> badges = [select Week__c, max(createddate) apple from QAAM_Weekly_Planner__c Max group by Week__c order by max(createddate) desc LIMIT 10];
          return badges;
      }
      set;
  }
    
   }

I wanted to pass value: {!data['Week__c']} to my controller from JavaScript, pls let me know how to achieve this?

Regards
Karthic Sankar V P