• Abdul Khatri
  • PRO
  • 4889 Points
  • Member since 2015

  • Chatter
    Feed
  • 156
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 1319
    Replies
I have a formula that currently works. Basically, if Investment Name is XYZ, then filling in the Total Size is required.
AND(ISBLANK(TEXT(Total_Size_c)), ISPICKVAL(Investment_Name_c,"XYZ"))

I want to add additional consideration for another picklist field. I want the above to kick in only if Type_c field is equal to “Addition”  OR  “New Investment”.  

I am not sure how to add this. Can anyone help?
 
Hi all,
Im getting a null pointer exception butwhen when i debug it everyone argument has a value but still it is throwing null pointer exxeption . can anyone please guide me User-added image
I keep receiving a "Missing ) Error"

IF(Acq_Comm_Calc__c CONTAINS $500),Estimated_Net_Profit_Retail_Renovation__c+500,
IF(AND Acq_Comm_Calc__c CONTAINS 8%),Estimated_Net_Profit_Retail_Renovation__c*0.08,
IF(AND Acq_Comm_Calc__c CONTAINS 10%),Estimated_Net_Profit_Retail_Renovation__c*0.1,
IF(AND Acq_Comm_Calc__c CONTAINS 12%),Estimated_Net_Profit_Retail_Renovation__c*0.12,
IF(AND Acq_Comm_Calc__c CONTAINS 15%),Estimated_Net_Profit_Retail_Renovation__c*0.15,
IF(Acq_Comm_Calc__c CONTAINS $7000),Estimated_Net_Profit_Retail_Renovation__c+7000,)
)
)
)
)

)
Trigger:
trigger PDFGenrate on Opportunity (after insert, after update) {
	 
   Set<Id> OppIds= new Set<Id>();
    
    for(Opportunity opp: trigger.new){        
        if(opp.StageName=='Closed Won'){            
         OppIds.add(Opp.Id);             
        } 
       }OpportunityPdfController.pdfGenration(OppIds);      
}

Trigger Handler: 
public class OpportunityPdfController {
    
    @future(callout=true)
    public static void pdfGenration(Set<Id> OppIds){
        List<Sobject> attachmentlist = new List<Sobject>();
        List<Sobject> ContentDocLink = new List<Sobject>();
        for(Id OppId: OppIds){

            Blob body;
            
                    PageReference pdf = new  PageReference('/apex/PrintPDF');
                    pdf.getParameters().put('Id',OppId);     
                  
                    ContentVersion cv=new ContentVersion();            
                    try{                
                        body=pdf.getContentAsPDF();
                    }catch (Exception e) {
                        body = Blob.valueOf('Text');
                        system.debug(e.getMessage());
                    }                     
                    cv.PathOnClient= 'Invoice'+'.pdf';            	
                    cv.Title= 'Invoice';
                    cv.IsMajorVersion = true;  
            		cv.VersionData=body;
                    attachmentlist.add(cv);     
            
        //   }     
     
     //  if(attachmentlist.size()>0){
            insert  attachmentlist;              
            
            
            Id conDocId = [SELECT ContentDocumentId FROM ContentVersion WHERE Id =:cv.Id].ContentDocumentId;
            system.debug(conDocId);
            ContentDocumentLink cdl = New ContentDocumentLink();

            cdl.LinkedEntityId = OppId;
            
            cdl.ContentDocumentId = conDocId;
            
            cdl.shareType = 'V';
            
        ContentDocLink.add(cdl);
            insert ContentDocLink;
            
        }
        
    }
}

 
  • August 03, 2022
  • Like
  • 0
Hey guys, I need to do the following, check if the banco__c fields
 and digito_da_conta return null and if they do I have a method that updates this field directly from another object
if(opp.Conta__c = null && opp.Banco__c = null && opp.Agencia__c = null ){
            CheckBankDataOfTheOpportunity(ssi,opp);
        }

   
private void CheckBankDataOfTheOpportunity(SelfSignIn__c ssi, Opportunity opp){
        opp.Agencia__c = ssi.Agencia__c;
        opp.Banco__c = ssi.Banco__c;
        opp.Conta__c = ssi.Conta__c;
    }

 
UseCase In Account Object:

Created a Trigger when the ParentAccount is selected in account object ,need to copy  the phone number and name and insert the record.
how can i add the Trigger in the Apex Class and Write Test Class...
 
trigger CopyAccountTriggerTest on Account (before insert) {
  
   
    if(checkRecursiveTest.runOnce()) {
        Set<Id> accountIds = new Set<Id>();
        for (Account acc : Trigger.new) {
            if (acc.ParentId != null){
                accountIds.add(acc.ParentId);
            }
            if(accountIds.size() > 0){  
                  List<Account> accounts = [select id,Name,Phone from account where id in :accountIds ];
                
                for (Account acc2 : Trigger.new) {
                    if (acc2.ParentId != null){
                        acc2.Name = 'Duplicate'+accounts[0].Name;
                        acc2.Phone= 'Duplicate'+accounts[0].Phone;
                    }
                }
            }
        }
 }

  
 
    
}



Apex Class:
=========
 
public class checkRecursiveTest {
    private static boolean run = true;
    public static boolean runOnce(){
     if(run){
     run=false;
     return true;
    }else{
        return run;
    }
    }
}

 
trigger CopyAccountTriggerTest on Account (before insert) {
  
   
    if(checkRecursiveTest.runOnce()) {
        Set<Id> accountIds = new Set<Id>();
        for (Account acc : Trigger.new) {
            if (acc.ParentId != null){
                accountIds.add(acc.ParentId);
            }
            if(accountIds.size() > 0){  
                  List<Account> accounts = [select id,Name,Phone from account where id in :accountIds ];
                
                for (Account acc2 : Trigger.new) {
                    if (acc2.ParentId != null){
                        acc2.Name = 'Duplicate'+accounts[0].Name;
                        acc2.Phone= 'Duplicate'+accounts[0].Phone;
                    }
                }
            }
        }
 }

  
 
    
}

ApexClass:
 
public class checkRecursiveTest {
    private static boolean run = true;
    public static boolean runOnce(){
     if(run){
     run=false;
     return true;
    }else{
        return run;
    }
    }
}

UseCase In Account Object:

Created a Trigger when the ParentAccount is selected in account object ,need to copy  the phone number and name and insert the record.
how can i add the Trigger in the Apex Class and Write Test Class...

Thanks 
Samantha
 
Hi - basic beginner apex question but struggling. 

The list TR2 will have duplicate values for Supplier__c. I want to end up with map with count of records for each Supplier__c.

What needs to go in the for loop to get this ? Thanks 
 
List<Trading_Relationship__c> Tr2 = [SELECT Supplier__c FROM Trading_Relationship__c WHERE Supplier__c IN :AccIds ORDER By Supplier__c ASC];

Map<ID, Integer> Map1 = new Map<ID, Integer>();
        
 for (Trading_Relationship__c eachTr : Tr2){   
            
            
        }
I can't figure out why the insert function isn't working. Can anyone help me? Thank you so much.

CONTROLLER:

public class ApartmentMapLister {

    public Map_Lead__c MapLead {get;set;}
    public Map_Point__c MapPoint {get;set;}
    public Map<Integer, Map_Point__c> ApartmentMap {get;set;}
    Public List<Wrapper> Wrapperlist {get;set;}

    public ApartmentMapLister() {
        MapLead = [SELECT ID, NAME, First_Name__c, Last_Name__c FROM Map_Lead__c WHERE ID=:ApexPages.currentPage().getParameters().get('id')];
    }    

    public Map<Integer, Map_Point__c> getonebedadmin() {

       Wrapperlist = new List<Wrapper>();
       
       ApartmentMap = new Map<Integer, Map_Point__c>();
       List<Map_Point__c> ApartmentList = [SELECT Id, Name, IsSelected__c FROM Map_Point__c Order By Name];

        for(Map_Point__c mp: ApartmentMap.values()) {
            Wrapper wrap = new Wrapper();
            wrap.mappoint = mp;
            Wrapperlist.add(wrap);
            }
                    
       for(Integer index = 0 ; index < ApartmentList.size() ; index++) {
           ApartmentMap.put(index, ApartmentList[index]);
       }
       return ApartmentMap;
    }

    public class Wrapper{
    
        public boolean isSelected {get;set;}
        public Map_Point__c mappoint {get;set;}
               
    }
    
    public void InsertApartment(){
        
        for(Wrapper wr : Wrapperlist){
        
            if(wr.mappoint.isSelected__c == true){
                
        Map_List__c ml = new Map_List__c();
            ml.Map_Lead__c=ApexPages.currentPage().getParameters().get('id');
            ml.Map_Point__c=wr.mappoint.ID;
            ml.Unique__c=(MapLead.NAME + wr.mappoint.AIMid__c);
            insert ml;
            }
        }
    }
    

      public PageReference SaveRecords(){
    
        List<Map_Point__c> records = new List<Map_Point__c>();
        for(Map_Point__c df : ApartmentMap.values()) {
            records.add(df);
        }
        // Bulk update with one DML call
        update records;
        return null;
      }
}


VISUALFORCE PAGE:
<apex:page sidebar="false" showHeader="false" cache="true" id="page" docType="HTML" readOnly="false" controller="ApartmentMapLister">
<apex:form >
    {!MapLead.First_Name__c} {!MapLead.Last_Name__c}
    
    <apex:pageBlock >
       <apex:pageBlockButtons location="top">
           <apex:commandButton value="Save" action="{!InsertApartment}"/>
       </apex:pageBlockButtons>
       <apex:pageBlockTable value="{!onebedadmin}" var="Map_Point__c">
            <apex:column >
                <apex:inputField value="{!onebedadmin[Map_Point__c].IsSelected__c}"/>
            </apex:column>
            <apex:column >
                <apex:inputField value="{!onebedadmin[Map_Point__c].Name}"/>
            </apex:column>
        </apex:pageBlockTable>
    </apex:pageBlock>
</apex:form>
</apex:page>
I wrote this. But its not wokrking if one of the fields is blank(but working if both are blank). what changes should i make ?
IF(
AND(NOT(ISBLANK( abc__c )) , NOT(ISBLANK( xyz__c ))) ,


IMAGE("/servlet/servlet.ImageServer?id=0150R000001JUkT&oid="+$Organization.Id, "icon" ,24, 128),
""
)

 
I have a Visualforce Page, with some input text fields. (There is NO standard or custom object associated with this Page). There is a button 'Generate PDF'. On click of this button, PDF needs to be generated having all the input text values.
How do we send the input text values to the PDF? (PDF is getting generated having only labels, no values) Please let me know!
  • October 25, 2021
  • Like
  • 0
Hope this is the right area to post this.  I am logged into SalesForce Lightning and can move around normally with our data. When I open up a new tab and access Workbench, the objects I run a query against are not ours.  For example, our Account object has 26 records in it currently.  But in Workbench, a count against the Account object indicates there are over 200,000 records.  Also the custom fields are not listed. I havent logged in a little over a month but up until my last login, everything was fine.  Any help and/or ideas?
Hi folks,

I have a custom code for dependent Picklist lightning component which is inserted in the case ,like below,now my requirement is whenever user wants to close the case ,i need to display a message in my custom picklist lightning component as below

"Level 1, level 2 and level 3 field must be populated before saving."

Here is the case stages as "CLOSED" and custom picklist component screenshot

User-added image


Your help is highly apreciated

Regards,
Fiona
I try not divided by 0 

I have variable with the Yearky Results this is the code
IF((AND(ISBLANK(Q1_c__c),ISBLANK(Q2_c__c),ISBLANK(Q3_c__c),ISBLANK(Q4_c__c))), 0,

IF((Q1_c__c + Q2_c__c + Q3_c__c + Q4_c__c) = Goal_Number__c,Goal_Number__c,

(((Q1_c__c + Q2_c__c + Q3_c__c + Q4_c__c)/Goal_Number__c)/4)))

With 4 Quarents with results 
 
Variable = Q1_c__c
IF(OR(ISBLANK(Q1_Value__c),ISBLANK(Q1_Goal__c)),0,Q1_Value__c / Q1_Goal__c) 

By in this quarter variables in one year you can use one quarter only or two or 3 or used all. And add to this you go over of 5,000 caracters in each formula. How can i do this 
Using the following call and JSON data I have been trying to Create a new opportunity attached to an account. Headers/Call are correct as I've been able to create Leads/Accounts. Something with the JSON is wrong but i'm not sure what it is. 

/services/data/v53.0/sobjects/Opportunity

data={
'Name': "Test opportunity",
'Accountid': "XXXXXXXXXXXXX",
'closedate': "1/12/2021",
'stagename':"Needs Analysis",
'Probability': "10"
}
Hi folks,

while calling a service at test class at Line 58 saying
here is test class code 
// Set mock callout class 
        Test.setMock(HttpCalloutMock.class, new MockHttpResponseGenerator());
        
        // Call method to test.
        // This causes a fake response to be sent
        // from the class that implements HttpCalloutMock. 
        HttpResponse res = HerokuBanSync.getBANInfoUpdate('990135742');
        
        // Verify response received contains fake values
        String contentType = res.getHeader('Content-Type');
        System.assert(contentType == 'application/json');
        String actualValue = res.getBody();
        String expectedValue = '{"GSMStackableSOC__c":"false"}';
        System.assertEquals(actualValue, expectedValue);
        System.assertEquals(200, res.getStatusCode());

User-added image
How to resolve the "Non static method cannot be referenced from a static context:" error

Thanks in advance
Fiona




 

I have a formula text field that looks up the Account_Owner_Role__c (text) from the Account record. 

I now need the formula to populate only if a text field on the Account contains "Hunter" 

This is what I've tried:

IF(
OR(
TEXT(Sales_Role__c)='Hunter - 1',
TEXT(Sales_Role__c)='Hunter - 2',
TEXT(Sales_Role__c)='Manager - Hunter 1')
),
Account_Owner_Role__c
))

 

Hello - Below is a soql query I'm using to retrieve leads and a For Loop to update the lead. I'm finding that the For Loop selects a record at random. Sometimes the For Loop updates the oldest lead and sometimes the newest lead. Is there any logic to the record returned by the For Loop if no index is specified? 
 
existingLead = [SELECT Id, street, LastName, PostalCode, 
           LastNameStreetAndZipCode__c, Core_Number_Text__c, Status, Home_Phone__c,
           CreatedDate, Core_Number__c, Policy_Core_Number__c, Lead_Type__c 
                                FROM LEAD 
                                WHERE  (
                                    Policy_Core_Number__c IN :coreNumberTextSet OR
                                    Core_Number__c IN :coreNumberTextSet
                                    OR ( LastNameStreetAndZipCode__c IN :lastNameStreetZipSet
                                        AND Core_Number__c NOT IN :coreNumberTextSet)
                                    OR (LastNameStreetAndZipCode__c IN :setOfPoBoxes
                                        AND Core_Number__c NOT IN :coreNumberTextSet))
                                AND Household__c != null
                                AND Duplicate__c != True
                                AND IsDeleted = False
                                ORDER BY CreatedDate ASC
                                LIMIT 20000];

 
if(existingLead.size() > 0){
                for(Lead leadsToAddToMap : existingLead) {
                    mapOfCoreNumbers.put(leadsToAddToMap.Core_Number__c, 
                              leadsToAddToMap.Core_Number__c);
                   
                    mapOfCreatedDate.put(leadsToAddToMap.LastNameStreetAndZipCode__c, 
                        leadsToAddToMap.CreatedDate);
                }
            }
I hope u understand my question. Please help as I am very very new to Lightning web component. Is there any way to insert both these using uiRecordApi ???? if yes plz explain how.
Hi,

I am looking to see the best approach for Salesforce CI. I have gone through many forum and blogs but haven't been able to grasp them. I tried to setup CI for the entire org but facing a lot of challeges which I guess you guys quite aware of.

What I am looking to do incremental deployment based on the git diff, dynamically generate package.xml based on the metadata committed which I think would be manageable something like sfdc-git-package https://www.npmjs.com/package/sfdc-git-package. I am having a hard time implementing this.

Please someone help
Can someone help me to show how I can change the Sales Console Lightning Layout. Currently it is showing as shown in the screen shot below as 3 Column layout. I wanted to change the layout to show the highlight panel on top. I am finding no help from Salesforce help section or trailhead for this. Please bear in mind I am talking about Lightning Sales Console and not Classic. I did the Edit Page and takes me but doesn't allow me to change the layout. 

User-added image
Is there a way to hide "Save & New" Button from the Task page Layout?

User-added image

I looked at everywhere and couldn't find the solution. I do want to give them Create/Edit Permission so no option there to remove that.

Please help
Custom URL for the cast creating inline headers and side bar. I tried the following addition things

            urlConcat += '&inline=0';
            urlConcat += '&isdtp=lt';
            urlConcat += '&isdtp=nv';
            urlConcat += '&isdtp=vw';

the only one that work is '&isdtp=nv' but after saving the activity, the hyperlink in the related list doesn't work. I have attached a screen shot 

User-added image

Anyone can help?

 
Hi,

I am looking to see the best approach for Salesforce CI. I have gone through many forum and blogs but haven't been able to grasp them. I tried to setup CI for the entire org but facing a lot of challeges which I guess you guys quite aware of.

What I am looking to do incremental deployment based on the git diff, dynamically generate package.xml based on the metadata committed which I think would be manageable something like sfdc-git-package https://www.npmjs.com/package/sfdc-git-package. I am having a hard time implementing this.

Please someone help
I have a formula that currently works. Basically, if Investment Name is XYZ, then filling in the Total Size is required.
AND(ISBLANK(TEXT(Total_Size_c)), ISPICKVAL(Investment_Name_c,"XYZ"))

I want to add additional consideration for another picklist field. I want the above to kick in only if Type_c field is equal to “Addition”  OR  “New Investment”.  

I am not sure how to add this. Can anyone help?
 
Hello, I am trying to perform a SOQL query in Salesforce. 

currently, when I search this query: 

select Id, Account.Id, Account.WBCNumber__c from Opportunity
WHERE FiscalQuarter__c = 'Q2 2020'
and 
AccountBoxoutNumber__c IN ('1-1206799572','1-1206525485','1-1206525485')

I only receive two values because the last two AccountBoxoutNumber values are repeating in the query. is there a way to make SOQL provide me with unique values even when there are repetitions in the Query?
 
In the below class, how to put the List(oppList) in the value of Map(oppMap)?

public class class1{
    
    public static Map<Id, list<opportunity>> oppmethod(Set<Id> oppId){
        
    List<Opportunity> oppList = [SELECT Id, AccountId, Name FROM Opportunity where ID IN: oppId];

    Map<Id, list<opportunity>> oppmap = new Map<Id, list<opportunity>>();
    
    for(Opportunity op : oppList){
        oppmap.put(op.AccountId, op);
    }
    
    return oppmap;
    }
}
Hi all,
Im getting a null pointer exception butwhen when i debug it everyone argument has a value but still it is throwing null pointer exxeption . can anyone please guide me User-added image

Hello!

Could you help to solve this ussue?

I cann't create an anouncement via Apex. I used this code, but it doesn't work properly.

List<ConnectApi.MessageSegmentInput> test = new List<ConnectApi.MessageSegmentInput>();
        test.add('test');
        ConnectApi.MessageBodyInput testBody = new ConnectApi.MessageBodyInput();
        testBody = test;
        ConnectApi.AnnouncementInput testGroup = new ConnectApi.AnnouncementInput();
        testGroup.body = testBody;
        testGroup.expirationDate = Date.today() + 2;
        testGroup.parentId = '0F95i000000xSYpCAM';
        ConnectApi.Announcement.postAnnouncement(null, testGroup);

Hi All,

I am just starting to learn to code and I have a small question regarding the code I wrote below. 
My goal is to first calculate the number of fields which are not null(there are 6 fields I am interested in as you can see in the list) and then show that number in the custom Key_Fields_Populated__c  field.
Once I have the Key_Fields_Populated__c filled out with correct number I would also like to create a new Task and link that Task to the Lead.

For some reason when I try to create Lead I get the following message: CreatingTask: execution of AfterInsert caused by: System.FinalException: Record is read-only Trigger.CreatingTask: line 21, column 1
I

Line 21 is this line in the code below
myLead.Key_Fields_Populated__c = NonEmptyFields.size();

Here is my code:

trigger Homework5 on Lead (after insert) {
    
    for (Lead myLead:Trigger.new){

        List<String> NameOfFields = New List<String>();
        NameOfFields.add('FirstName');
        NameOfFields.add('LastName');
        NameOfFields.add('Email');
        NameOfFields.add('Phone');
        NameOfFields.add('Website');
        NameOfFields.add('Title');
        
        List<String> NonEmptyFields = new List<String>();
               
        for(Integer i=0;i<NameOfFields.size();i++){
            if(myLead.get(NameOfFields.get(i)) !=null){
               NonEmptyFields.add(NameOfFields.get(i));
           
            }
        }
      myLead.Key_Fields_Populated__c = NonEmptyFields.size();
        
       Task myTask = new Task();
       myTask.whoId = myLead.Id;
       myTask.Status = 'Not Started';
       insert myTask;
         
    } 
           
}

Thanks in advance.

Darko
I keep receiving a "Missing ) Error"

IF(Acq_Comm_Calc__c CONTAINS $500),Estimated_Net_Profit_Retail_Renovation__c+500,
IF(AND Acq_Comm_Calc__c CONTAINS 8%),Estimated_Net_Profit_Retail_Renovation__c*0.08,
IF(AND Acq_Comm_Calc__c CONTAINS 10%),Estimated_Net_Profit_Retail_Renovation__c*0.1,
IF(AND Acq_Comm_Calc__c CONTAINS 12%),Estimated_Net_Profit_Retail_Renovation__c*0.12,
IF(AND Acq_Comm_Calc__c CONTAINS 15%),Estimated_Net_Profit_Retail_Renovation__c*0.15,
IF(Acq_Comm_Calc__c CONTAINS $7000),Estimated_Net_Profit_Retail_Renovation__c+7000,)
)
)
)
)

)