• Naga Alapati
  • NEWBIE
  • 65 Points
  • Member since 2020
  • Developer

  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 3
    Likes Given
  • 0
    Questions
  • 23
    Replies
hello,
I am new in salesforce, so I hope i will explain well.

I have a list inside my class:

AttLst = new List<Attendance__c>([SELECT id,Name,Exam__c, FROM Attendance__c]);

The Exam__c is a lookup object, Inside the Exam Object i have Name and Datetime__c field.

I want to get in visualforce the Datetime field.

  <apex:pageBlockTable value="{!AttLst }" var="at">
          <apex:column value="{!at.Name}" />
           <apex:column value="{!at.Exam__c}" /> // here i get the name of the exam
            <apex:column value="{!at.Exam__c.Datetime__c}" /> // Here i get an error.
  </apex:pageBlockTable>

How can i do it? maybe changing the SOQL or maybe I didn't syntax error...

Please help me understand. Thank you.
  • December 18, 2020
  • Like
  • 0
I have a list here which has city name as a column, how to filter the rows by values from the city name column.
global Database.QueryLocator start(Database.BatchableContext BC) {
        return Database.getQueryLocator('SELECT CITY_NAME__c,PROVINCE_CODE__c,STATUS__c,INTERNET_SERVICE__c,VIDEO_SERVICE__c,PHONE_SERVICE__c FROM MDU_Squad_Data_min__c');
    }
 
   // Execute method

    global void execute(Database.BatchableContext BC, List<MDU_Squad_Data_min__c> cityStats) {               
        // Here I am trying to filter the values of the cityStats list
    }

 
hello,
I am new in salesforce, so I hope i will explain well.

I have a list inside my class:

AttLst = new List<Attendance__c>([SELECT id,Name,Exam__c, FROM Attendance__c]);

The Exam__c is a lookup object, Inside the Exam Object i have Name and Datetime__c field.

I want to get in visualforce the Datetime field.

  <apex:pageBlockTable value="{!AttLst }" var="at">
          <apex:column value="{!at.Name}" />
           <apex:column value="{!at.Exam__c}" /> // here i get the name of the exam
            <apex:column value="{!at.Exam__c.Datetime__c}" /> // Here i get an error.
  </apex:pageBlockTable>

How can i do it? maybe changing the SOQL or maybe I didn't syntax error...

Please help me understand. Thank you.
  • December 18, 2020
  • Like
  • 0
I have a requirement where i have two objects say, Product and Product line item(Both are custom objects). I have got a requirement where i need to map the fields in the product record to the product line item record whenever the Product is selected in the look-up of Product Line Item.(Product line item has got a look up relationship with product in my case). For now in my code i am mapping fields like,
Pli.Billed__c = Prod.Billed__c;
I wonder if there is anyway i can do this dynamically using Custom metadata.
So my question goes like, for mapping fields from one object to fields of another object, is there anyway i can do it dynamically using custom Metadata?
Hello. An error message has popped up for some of my users and it's way above my head to fix. Before I turn to Premier Support our our outside support, I thought I'd try here. 
As a System Admin, I can create new Opportunities. However, those with a different profiel cannot. I've attached a jpeg of the error message. I am not a Developer, so if we have to spend some money, so be it. Any help would be appreciated.Error Message 

 

I am trying to put the id from database.saveresult return values and then the matching value from the citylist list into this map below, but I get an error "Method does not exist or incorrect signature: void put(sumchans__City_Master__c, Id) from the type Map<String,String>"
 
Database.SaveResult[] saveCityMaster = Database.Insert(cityList, false);
        Map<String,String> findCityId = new Map<String,String>();
        for (Database.SaveResult sr : saveCityMaster) {
            if (!sr.isSuccess()) {
                findCityId.put(cityList.get(0),sr.getId());
            }
        }

 
Hello,

I am beginner in Salesforce and still in initial steps in understanding the concepts..i tried the below class and the output didnt come as expected 

public class mytest2 
{
    Public integer marks;
    Public string result;
        {
        if(marks >= 35 && marks <= 50)
        result = 'passed';
        else if (marks >= 51 && marks <= 70)
        result = 'B';
        else if (marks >= 71)
        result ='A';
        else 
        result = 'failed';
                {
                  system.debug('Your results:' + result);
                }
        }    
}

and executing it in anonymous window 

mytest2 c1 = new mytest2();
c1.marks = 55;
system.debug(c1);

Output was Your results:failed

which seems to be wrong ..not sure what went wrong here
I have been having a wierd issue for sometime now, I am not getting any system.debug messages on my logs, instead I get a lot of not useful stuff. I am trying to print out the value of 'stat' here, it doesn't work at all.
sumchans__City_Stat__c stat = new sumchans__City_Stat__c();
stat.sumchans__ON_BILLINGS__c = onBillings;
stat.sumchans__OFF_BILLINGS__c = offBillings;             stat.sumchans__TOTAL_INTERNET_OFFERINGS__c = internetOfferings;
stat.sumchans__TOTAL_VIDEO_OFFERINGS__c = videoOfferings;
stat.sumchans__TOTAL_PHONE_OFFERINGS__c = phoneOfferings;
cityStats.add(stat);
System.debug(stat);
And here is the full log list. I done want any of these messages as of now, what I am only looking for is the System.debug messages.
Plz advise!
Logs
 
Hello everyone

I need a small help in bulkifying the below code, Basically what this trigger does is when country is populated, it checks with the Formula Field (Updated_Region__c) and assigns with the Correct Region Field, Ex - when Updated Region is Middle east(ME) then the custom fields related to ME(Lead_No_Region_ME__c) gets incremented with 1,2,3....

Now i hear this is not a best pratices for deploying in the production, because when bulk records gets updated, the code may fail, but to my suprise i have Written a Test class with code coverage of 98%, Could any please help with the solution or suggestion
 
trigger LeadIncrement on Lead (before insert,Before Update) {
    if(trigger.isBefore && (trigger.isInsert || trigger.isUpdate)) {
        List<Lead> leadList = [Select Id,Lead_No_Region_IN__c From Lead Where Region__c = 'India'];
        For(Lead l : trigger.New) {
            if(l.Region__c == 'India') {
                if(leadList.size() > 0){
                    l.Lead_No_Region_IN__c = leadList.size()+0;   
                } else {
                    l.Lead_No_Region_IN__c = 1;
                }
            }
        }
        List<Lead> leadListt = [Select Id,Lead_No_Region_USA__c From Lead Where Region__c = 'US'];
        For(Lead m : trigger.New) {
            if(m.Region__c == 'US') {
                if(leadListt.size() > 0){
                    m.Lead_No_Region_USA__c = leadListt.size()+0;   
                } else {
                    m.Lead_No_Region_USA__c = 1;
                }
            }
        } 
        List<Lead> leadListm = [Select Id,Lead_No_Region_EU__c From Lead Where Region__c = 'EU'];
        For(Lead n : trigger.New) {
            if(n.Region__c == 'EU') {
                if(leadListm.size() > 0){
                    n.Lead_No_Region_EU__c = leadListm.size()+0;   
                } else {
                    n.Lead_No_Region_EU__c = 1;
                }
            }
        } 
        List<Lead> leadListo = [Select Id,Lead_No_Region_EU__c From Lead Where Region__c = 'SEA'];
        For(Lead o : trigger.New) {
            if(o.Region__c == 'SEA') {
                if(leadListo.size() > 0){
                    o.Lead_No_Region_SEA__c = leadListo.size()+0;   
                } else {
                    o.Lead_No_Region_SEA__c = 1;
                }
            }
        }
        List<Lead> leadListp = [Select Id,Lead_No_Region_ME__c From Lead Where Region__c = 'ME'];
        For(Lead p : trigger.New) {
            if(p.Region__c == 'ME') {
                if(leadListp.size() > 0){
                    p.Lead_No_Region_ME__c = leadListp.size()+0;   
                } else {
                    p.Lead_No_Region_ME__c = 1;
                }
            }
        } 
        
    }					
}

Test Class
 
@isTest
public class LeadIncrementV3Test {
    @isTest
    public static void LeadIncrementV3TestMethod() {
        List<Lead> leadList = new List<Lead>();

        Lead l = new Lead();
        l.Country = 'India';
        l.Company = 'Test';
        l.LastName = 'testLast';
        l.Status = 'Enquiry';
        leadList.add(l);

        Lead l1 = new Lead();
        l1.Country = 'India';
        l1.Company = 'Test1';
        l1.LastName = 'testLast1';
        l1.Status = 'Enquiry';
        leadList.add(l1);

        Lead l2 = new Lead();
        l2.Country = 'US';
        l2.Company = 'Test2';
        l2.LastName = 'testLast2';
        l2.Status = 'Enquiry';
        leadList.add(l2);

        Lead l21 = new Lead();
        l21.Country = 'USA';
        l21.Company = 'Test21';
        l21.LastName = 'testLast21';
        l21.Status = 'Enquiry';
        leadList.add(l21);

        Lead l3 = new Lead();
        l3.Country = 'Brazil';
        l3.Company = 'Test3';
        l3.LastName = 'testLast3';
        l3.Status = 'Enquiry';
        leadList.add(l3);

        Lead l31 = new Lead();
        l31.Country = 'Belgium';
        l31.Company = 'Test31';
        l31.LastName = 'testLast31';
        l31.Status = 'Enquiry';
        leadList.add(l31);

        Lead l4 = new Lead();
        l4.Country = 'Thailand';
        l4.Company = 'Test4';
        l4.LastName = 'testLast4';
        l4.Status = 'Enquiry';
        leadList.add(l4);

        Lead l41 = new Lead();
        l41.Country = 'Japan';
        l41.Company = 'Test41';
        l41.LastName = 'testLast41';
        l41.Status = 'Enquiry';
        leadList.add(l41);

        Lead l5 = new Lead();
        l5.Country = 'Iran';
        l5.Company = 'Test5';
        l5.LastName = 'testLast5';
        l5.Status = 'Enquiry';
        leadList.add(l5);

        Lead l51 = new Lead();
        l51.Country = 'Kuwait';
        l51.Company = 'Test51';
        l51.LastName = 'testLast51';
        l51.Status = 'Enquiry';
        leadList.add(l51);  
        
        Insert leadList;
    }
}

​​​​​​​
I have a test function with seeAllData=true declared.  It creates an opportunity, queries the PricebookEntry object for a specific record, and then creates an opportunity line referencing that pricebook entry.
The first two System.debug statements return a record ID for the PricebookEntry and related Product2 entry.   When the PricebookEntry ID is assigned to an opportunity line item and then referenced as oli.PricebookEntry.Product2Id the value is 'null'.  What is going on here, where the SOQL query result shows a value but assigning it to a line causes it to be null?
 
@isTest(seeAllData=true)
    public static void integrationTest(){
        Account testAccount = TestUtil.createAccount();
        Opportunity o = TestUtil.createOpportunity(testAccount.Id);
        String currencyCode = [select CurrencyIsoCode from Opportunity where Id = :o.Id].CurrencyIsoCode;
        PricebookEntry pe1 = [select Id,Product2Id 
                              from PricebookEntry 
                              where IsActive = true 
                              and Pricebook2.IsStandard = true 
                              and CurrencyIsoCode = :currencyCode 
                              limit 1];
        System.debug('>>> pe1.Id = ' + pe1.Id);
        System.debug('>>> pe1.Product2Id = ' + pe1.Product2Id);
        OpportunityLineItem oli1 = new OpportunityLineItem(
            OpportunityId = o.Id,
            Quantity = 1,
            UnitPrice = 1,
            Configurator_Timestamp__c = Datetime.now()
        );
        oli1.PricebookEntryId = pe1.Id;
        System.debug('>>> oli1.PricebookEntryId = ' + oli1.PricebookEntryId);
        System.debug('>>> oli1.PricebookEntry.Product2Id = ' + oli1.PricebookEntry.Product2Id);
Debug output.

debug output
Hi getting below error for the trigger,

Trigger :

trigger MobDiscount on Mobile__c (before insert,before update,before delete) {
    
    if(Trigger.isinsert == true)
    {
        DiscountForMobiles.DiscountNewCoustomer(Trigger.new);
    }
    
    if(Trigger.isupdate == true)
    {
        DiscountForMobiles.DiscountOldCoustomer(Trigger.new);
    }
    
    if(Trigger.isdelete == true && Trigger.isbefore == true)
    {
        DiscountForMobiles.OwnwerAloneCanDelete(Trigger.new);
    }
    
}

Apex class :

public class DiscountForMobiles {
    
    Public Static Void DiscountNewCoustomer(List<Mobile__c> CoustomerList)
    {
        for(Mobile__c SingleCoustomer : CoustomerList ){
            
            If(SingleCoustomer.Brand__c == 'Samsung')
            {
                
               SingleCoustomer.Price__c = SingleCoustomer.Price__c * 10/100;
               SingleCoustomer.Discount_Status__c = '10 % Discount';
            }
            
            If(SingleCoustomer.Brand__c == 'Apple')
            {
                
               SingleCoustomer.Price__c = SingleCoustomer.Price__c - SingleCoustomer.Price__c * 5/100;
               SingleCoustomer.Discount_Status__c = '5 % Discount';
            }
            
        }
        
    }

    Public Static Void DiscountOldCoustomer(List<Mobile__c> CoustomerList)
    {
        for(Mobile__c SingleCoustomer : CoustomerList ){
            
            If(SingleCoustomer.Brand__c == 'Samsung')
            {
                
               SingleCoustomer.Price__c = SingleCoustomer.Price__c - SingleCoustomer.Price__c * 10/100;
               SingleCoustomer.Discount_Status__c = '5 % Discount';
            }
            
            If(SingleCoustomer.Brand__c == 'Apple')
            {
                
               SingleCoustomer.Price__c = SingleCoustomer.Price__c * 5/100;
               SingleCoustomer.Discount_Status__c = 'NO Discount';
            }
            
        }
        
    }
    Public Static Void OwnwerAloneCanDelete(List<Mobile__c> CoustomerList)
    {
        
        for(Mobile__c Costomer : CoustomerList)
        {
            If(Costomer.OwnerId != Userinfo.getUserId())
            {
                Costomer.adderror('only owner can delete');
            }
        }
         
    }
      
}

i am trying to delete from the records owner account only.

Pls help
Hi

I know this is a really basic question but I am just gettign started.

I have the code but the inout box is not getting populated.

It would be really helpful if someone could pont me in the right direction.

I am hoping to do this wothout an apex class
 
<apex:page standardController="Lead" doctype="html-5.0">

    <head>
        
  <body>
      
      
   <apex:form id="form1">
    <apex:selectList multiselect="false" size="1" id="selectedCountry" onselect="SelectAPICountry()">

         <apex:selectOption itemValue="ie" itemLabel="Ireland"/>
         <apex:selectOption itemValue="gb" itemLabel="Northern Ireland"/>
         <apex:selectOption itemValue="ni" itemLabel="Great Britain"/>
      </apex:selectList>
        <apex:input size="20" label="country id" id="countryid"/>
    </apex:form> 

  
   <script type="text/javascript">
function SelectAPICountry() {
                document.getElementById('{!$Component.form1.countryid}').value = document.getElementById('{!$Component.form1.selectedCountry}').value;
            }

</script>
          </body>
</head>
          
    </apex:page>
Much appreciated 
 
Dear Team ,

Greetings !!!

I created button and m applying that button on page layout . But that button not appearing on Standard objects .

Thanks & Regards
Sachin BhaleraoUser-added imageI created Click on whatsapp chat button . What should i do in order this button will appear .
I have a list here which has city name as a column, how to filter the rows by values from the city name column.
global Database.QueryLocator start(Database.BatchableContext BC) {
        return Database.getQueryLocator('SELECT CITY_NAME__c,PROVINCE_CODE__c,STATUS__c,INTERNET_SERVICE__c,VIDEO_SERVICE__c,PHONE_SERVICE__c FROM MDU_Squad_Data_min__c');
    }
 
   // Execute method

    global void execute(Database.BatchableContext BC, List<MDU_Squad_Data_min__c> cityStats) {               
        // Here I am trying to filter the values of the cityStats list
    }

 
Hi,
If I create FeedItem + Attachment and after a period I need to delete all the old FeedItem -for example, those that before 30 days.
<Note that all this is with apex code, not manually>

I understand that deleting the FeedItem is not deleting the attachment file, so I found that I can delete the attachments by querying ContentDocument object.

The problem is that I want to delete only the attachment that related to the feeds that were deleted, not all those in ContentDocument.
Assume that I can mark those attachments in some way (when creation) that will help to retrieve only them when need to delete them.

But perhaps I can avoid it? Does SF store in some way the connection between the FeedItem in its attachment?
Hello,

I am beginner in Salesforce and still in initial steps in understanding the concepts..i tried the below class and the output didnt come as expected 

public class mytest2 
{
    Public integer marks;
    Public string result;
        {
        if(marks >= 35 && marks <= 50)
        result = 'passed';
        else if (marks >= 51 && marks <= 70)
        result = 'B';
        else if (marks >= 71)
        result ='A';
        else 
        result = 'failed';
                {
                  system.debug('Your results:' + result);
                }
        }    
}

and executing it in anonymous window 

mytest2 c1 = new mytest2();
c1.marks = 55;
system.debug(c1);

Output was Your results:failed

which seems to be wrong ..not sure what went wrong here
APPLY here:
Admin: https://bit.ly/2moPOq5
Developer: https://bit.ly/2lIszH8
Admin/Sales Automation PM: https://bit.ly/2z3c0sq

Join the Salesforce CRM team supporting the fast growing Amazon Business team. Check us out in the news:

https://www.cnbc.com/2019/03/19/amazon-business-could-be-worth-more-than-core-retail-e-commerce.html