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

  • Chatter
    Feed
  • 143
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 1241
    Replies
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?
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 All,

 

string templateId = '00XN0000002LbV8MAK';
string domainUrl = URL.getSalesforceBaseUrl().toExternalForm();
HttpRequest req = new HttpRequest();
req.setHeader('Authorization', 'Bearer ' + UserInfo.getSessionID());
req.setHeader('Content-Type', 'application/json');
req.setEndpoint(domainUrl+'/services/data/v51.0/tooling/query/?q=select+id,SenderType,templateId+from+WorkflowAlert+where+templateId=\''+templateId+'\'');
req.setMethod('GET'); 
Http h = new Http();
HttpResponse res = h.send(req);
system.debug(res.getBody());
Map<String, Object> deserialized = (Map<String, Object>)JSON.deserializeUntyped(res.getBody());
Object data1 = deserialized.get('records');
System.debug(deserialized.get('records'));
System.debug(deserialized.get('size'));

 

res.getBody(); -> {"size":1,"totalSize":1,"done":true,"queryLocator":null,"entityTypeName":"WorkflowAlert","records":[{"attributes":{"type":"WorkflowAlert","url":"/services/data/v51.0/tooling/sobjects/WorkflowAlert/01WN00000005esGMAQ"},"Id":"01WN00000005esGMAQ","SenderType":"CurrentUser","TemplateId":"00XN0000002LbV8MAK"}]}

 

Im trying to get ,"SenderType":"CurrentUser"  value but values is not returning: 

System.debug(deserialized.get('records')); --> [{"TemplateId":"00XN0000002LbV8MAK","SenderType":"CurrentUser","Id":"01WN00000005esGMAQ","attributes":{"url":"/services/data/v51.0/tooling/sobjects/WorkflowAlert/01WN00000005esGMAQ","type":"WorkflowAlert"}}]

 

How to get SenderType Value?

 

Thanks in Advance,

Hi Everyone,

problem statement: 
I am passing a SOQL query through a textArea of my Visualforce page. I want my controller to split the query and get a list of the queried coloums:

For ex. : InputQuery : 'Select Id, Name, Rating from Account' or 
'Select Id,Name,Rating from Account'(without space in fields)

Output result : List<String>= ['id', 'Name','Rating'];

I tried with InputQuery.split(' ') method but unable to get desired result. Please help me with this.
Hi,
I have written following apex class and test class. I'm getting an error saying "List has no rows for assignment to SObject" and my test class is getting failed though my code coverage is 91%. I'd appreciate any assistance.



public  class MMAResultReportController

{
    public List<DOAS_AVS_RESPONSE_LEVEL_1__c> avsresults {get;set;}
    public Test_MMA2__c avsRequest {get;set;}
    public string strRequestID{get;set;}
    
    //public string searchRef{get;set;}
    public  MMAResultReportController(){
        system.debug('####Printing page reference');
        system.debug(System.currentPageReference().getParameters().get('RequestID'));
        strRequestID=System.currentPageReference().getParameters().get('RequestID');
        
        getavsRequest();
    }
    public void getavsRequest(){
        avsRequest= new Test_MMA2__c();
        //system.debug ('####strRequestID is: '+strRequestID);
        //system.debug('####Variable is: ' + strRequestID);
        avsRequest = [select MMA_Request_ID__c,MMA_RecordType__c,MMA_Suffix__c,MMA_DOB__c,MMA_Middle_Name__c,MMA_Flag__c,MMA_Sex__c,MMA_SSN__c,MMA_First_Name__c, MMA_Last_Name__c, MMA_Family_ID__c, MMAReportDate__c,MMA_BENE_SSN1__c,
from Test_MMA2__c where MMA_Request_ID__c =:strRequestID];//                                                                 
    }
    
           
    
}


Test Class-

@isTest(SeeAllData=true)
public class MMAResultReportController_Test {
    @istest static void test(){

        Test_MMA2__c tes= new Test_MMA2__c ();
        tes.name='Sample';
        tes.MMA_First_Name__c='John';
        tes.MMA_Last_Name__c='Smith';
        tes.MMAReportDate__c=date.today();
        tes.MMA_Middle_Name__c='De';
       
        insert tes;
        test.startTest();
     
       MMAResultReportController ce= new MMAResultReportController();
      
        ce.getavsRequest();
        test.stopTest();
    }

 
I have two custom objecrt 1. stock_register__c 2. stock_regirser_line__c
i have master detail relation field quantity__c with stock_register__c(parent object) and  stock_regirser_line__c (chield)

I need to write a before insert and before update trigger to restrict the  sum of quantiy__in stock_regirser_line__c can not be more that  allocated_quanity__c in the parent object(stock_register__c)

Please help!!
thanks in advance!!
I'm trying to write an SOQL query that will pull information from the Contact object and the Event Object.  When I tried to use Event as the child object, I received an error message that Event could not be the child, so I switched the query around to this:
SELECT Event.whoid, Event.StartDateTime, Event.Subject, (select contact.id, contact.firstname, contact.lastname, contact.MailingStreet, contact.MailingCity, contact.MailingState, contact.MailingPostalCode from Contact)
from Event
Where Event.whoid = '0034M000020OgliQAC'

Unfortunately, it still isn't working.  It tells me "Didn't understand relationship 'Contact' in FROM part of query call.".  What am I doing wrong?

In SQL, the query would look like this:
Select Event.Whoid, Event.StartDateTime, Event.Subject, Contact.firstname, contact.lastname, contact.MailingStreet, Contact.MailingCity, contact.MailingState, contact.MailingPostalCode
from Event
Join Contact on Event.Whoid = Contact.id
where event.whoid = '0034M000020OgliQAC'

Any assistance would be greatly appreciated.
Hi All,
I am trying to cover wrapper class in calss. But it s not covering. I am sharing my class and test class.

Apex class
public class accountCController {
    @AuraEnabled (cacheable=true)
    public static List<accWrapper> getNameValues(List<string> acname){
        List<accWrapper> resultObject = new List<accWrapper>();
        string query = 'SELECT Id,Name FROM account  WHERE  Name';
        query+='=: acname';
        List<SObject> lstResult = Database.query(query);
        for (SObject res : lstResult) {
            accWrapper obj = new accWrapper();
            obj.testId = (String)res.get('Id');
            obj.testName = (String)res.get('Name');
            resultObject.add(obj);
        }       
        return resultObject;
    }
    public class accWrapper{
        @AuraEnabled
        public String testId;
        @AuraEnabled
        public String testName;
    }
	}

Test class:
@isTest
public class accountController_Test {
    static testMethod void testName(){  
        List<string> strList = new List<string>();
        strList.add('A');
        strList.add('B');
        accountCController.getNameValues(strList);
       
    }
}


Its covering "getNameValues" method but it is not covering wrapper class. Please help me on this.​​​​​​​

Thanks in advance

Regards,
​​​​​​​Ramana

trigger countTack on MyTask__c (after update) {
   List<MyTask__c> myTask = [SELECT Id,(SELECT Id,CountMyTask__с FROM Contact) FROM MyTask__c WHERE Id IN :Trigger.New];
   for(MyTask__c my :myTask){
      List<Contact> contactList = my.Contacts;
      my.CountMyTask__c = contactList.size();
   }
}
Dont work

Hi,
Iam new to apex. this is one of the trigger scenario bothering me.
Please help me with this.

I have a status checkbox field on accounts.
status picklist field with "open","closed" on contacts.
1) if status="closed" in all the related contacts then checkbox on account should be true.
2) if status="open" in any one of the related contacts then checkbox on account should be false.  
-------------------------------------------------------------------------------------------
Trigger:
trigger contactTrigg on contact(after insert, after update, after delete, after undelete){
    if(trigger.isInsert || trigger.isUpdate){
        accProgress.method1(trigger.new,trigger.old);
    }
}

-------
Handler:
public class accProgress{
    public static void method1(list<contact> newInsert, list<contact> oldInsert){
        
        set<id> conSet = new set<id>();
        
        for(contact con1 : newInsert){
            if(con1.Accountid != null){
                conSet.add(con1.accountid);
            }
        }
 for(contact con2 : oldInsert){
                conSet.add(con2.accountid);
        }

        List<account> accList =[SELECT id, progress_field__c,(SELECT id, progress_field_contacts__c FROM contacts) FROM account WHERE id IN :conSet];
        if(accList != null){
            for(account acc : accList){
                for(contact con : acc.contacts){
                    
                    if(con.progress_field_contacts__c == 'open' ){
                        acc.progress_field__c = false;
                    }
                    else{
                        acc.progress_field__c = true;
                    }
                }
            }
            update accList;
        }
    }
---------------------------------------------------------------------------------------------
1st one is working. i.e, whenever i make all related contacts "close" . the check box is getting checked(true).
2nd one is where iam failing. when i'm changing any contacts picklist values to open the account status checkbox is not unchecking(false).
please help me.

Need a query that basically says

(ExposeCase = true OR CreatedByID = UserInfo.getUserId()) AND isClosed = false

which would be in the following syntax and sort of a combination of these:

soql += ' Where CreatedById = \'' + UserInfo.getUserId() + '\' OR Expose_Case__c = true';

soql += ' Where Expose_Case__c = true AND isClosed = false';

I am unable to figure out the syntax. I've tried the following 

soql += ' Where CreatedById = \'' + UserInfo.getUserId() + '\' OR Expose_Case__c = true' + 'AND isClosed = false';

Hi,

I need to to change below code and use Database.insert() to insert records, iterate over the results, and persist information about any failures to the database ...reason to do above is I want to report Records in Batchable Salesforce apex code such that it should report where the Level2 or Level3 are NULL..Can some one edit the below Batch apex code to use Database.insert() to insert records, iterate over the results, and persist information about any failures to the database

here is current code
global class ertcopybatch3pm implements Database.Batchable<sObject> {
              
                global Database.QueryLocator start(Database.BatchableContext BC) {
                    // collect the batches of records or objects to be passed to execute
                    
                    String query = 'select Case__c, Level_1__c, Level_2__c,Level_3__c  FROM ERT_Case_Type__c';
                    System.debug('ERT Case No is =====>' +query);
                    return Database.getQueryLocator(query);
                }
                
                global void execute(Database.BatchableContext BC, List<ERT_Case_Type__c> exeList) {
                   
                    // process each batch of records
            List<Case_Type__c> listCTD = new List<Case_Type__c>();
                    System.debug('ERT Case No is =====>' +exeList);
                    for(ERT_Case_Type__c exe : exeList)
                    {        
                         listCTD.add(new Case_Type__c(Case__c=exe.Case__c,Level_1__c=exe.Level_1__c,Level_2__c=exe.Level_2__c,Level_3__c=exe.Level_3__c));
                       // System.debug('ERT Case No is =====>' +Case__c);
                    }
                    try {
                      System.debug('ERT Case No is =====>' +listCTD);
                        insert listCTD;
                    
                    } catch(Exception e) {
                        System.debug(e);
                    }
                    
                }   
                
                global void finish(Database.BatchableContext BC) {
                  // execute any post-processing operations
              }
            }

Your help is highly appreciated

Regards.
Fiona

Hi ,

I am new to Salesforce development, and I am doing my first project on integrating Salesforce and external systems. My remote system will use the REST API to create/update/delete data in Salesforce. I read the following in the Salesforce document :

"Error handling—All the remote call-in methods, standard or custom APIs, require the remote system to handle any subsequent errors, such as timeouts and the management of retries. Middleware can be used to provide the logic for error handling and recovery.

• Recovery—A custom retry mechanism needs to be created if quality-of-service requirements dictate it. In this case, it’s important to ensure idempotent design characteristics. Platform event enables subscribers to use the replay ID to fetch messages within a certain time period after those messages were published."

Can anyone please tell me what kind of errors and recovery I will have to take care of in my remote system? Any links will be very helpful for me. I am not using any middleware, in what cases should I consider using a middleware. 

Hello friends, need suggestion please.
I have inherited a trigger written by my predecessor which is throwing exception error. Can someone help in getting this sorted? What is the reason of getting this error ?

****** Code Start ******
trigger OnAccountTrigger on Account (before update, before insert) {
    // Create the map to store mappings
    //Map<String, String> objParentAccountMapping = new Map<String, String>();
    // Create set to store ids
    Set<Id> arParentAccountIds = new Set<Id>();
    // get all the Ids for the accounts that are inserted in that execution context.
    for(Account objAccount : Trigger.New) {
        // Check if we have a person
        if ((objAccount.Person_Account_Parent__c != null) && (objAccount.IsPersonAccount)) {
            // Retrieve the related contact
            // Retrieve the parent account from objAccount.Person_Account_Parent__c
            // Update the local contact from the objAccount.PersonContactId of that retrieved parent
            arParentAccountIds.add(objAccount.Person_Account_Parent__c);
        }
    }
   
    // Store the map   
    Map<Id, Account> objAccountChildContact = new Map<Id, Account>([select Id, PersonContactId from Account WHERE Id IN : arParentAccountIds]);
   
    System.debug('Map');
    System.debug(objAccountChildContact);

    // get all the Ids for the accounts that are inserted in that execution context.
    for(Account objAccount : Trigger.New) {
        // Check if we have a person
        if ((objAccount.Person_Account_Parent__c != null)) {
            // Retrieve the related contact
            // Retrieve the parent account from objAccount.Person_Account_Parent__c
            // Update the local contact from the objAccount.PersonContactId of that retrieved parent

            // Set the contact
           /*below in red is line 32*/
 objAccount.Parent__pc = objAccountChildContact.get(objAccount.Person_Account_Parent__c).PersonContactId; 
            System.debug('Updating contact parent for [' + objAccount.Id + '] to [' + objAccount.Parent__pc +']');
           
        }
    }
}


Error Message:
Apex script unhandled trigger exception by user/organization:
OnAccountTrigger: execution of BeforeUpdate

caused by: System.NullPointerException: Attempt to de-reference a null object

Trigger.OnAccountTrigger: line 32, column 1

***** Code End *****

Thanks in advance !


 
Hi,

I am looking for a email validation in lightning component.

1. Is that possible by using in a component ? without using controller or helper ?

2. If No, Can you guide me to get a following email validation.

3.  It should end with ( .COM). Let's say for example it should the validation if it's  in following format " abc@d.o " .


Regards,
Soundar.
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
Wondering if anyone has tackled this.
An Apex Trigger that looks at an inbound email (before insert, before update), and if there is an Attachment, and the Attachment is of certain File Types (.zip, .mp4, etc.) it does not create/update the case AND an email is sent to the sender notifying them that File Type is not accepted and to plesse resend their email with accepted File Type (.jpg, .png, .pdf).
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,
I have a custom object related to Case (lookup field)... I've created an LWC to edit some fields from my custom object on the Case record page.
Once the LWC is submitted I need to make the Case record page in Edit state and repopulate some field values.
Is it possible to do?
Thanks,
Good day. In my first tab the if statement is not running while in the second tab the if statement runs well.
 
FIRST TAB  
Trigger CaseUpdate on Case(Before Insert, Before Update, Before Delete, After Insert,
                             After Update, After Delete, After Undelete){
    if(Trigger.isAfter){
        if(Trigger.isUpdate){
            Set<Id> newIds = new Set<Id>();
            Set<Id> oldIds = new Set<Id>();
            for(Case newLooper : Trigger.new){
                newIds.add(newLooper.AccountId);
            }
            for(Case oldLooper : Trigger.old){
                oldIds.add(oldLooper.AccountId);
            }
            List<Case> newList = new List<Case>([Select Id, CaseNumber, Status from Case where AccountId=:newIds]);
            List<Case> oldList = new List<Case>([Select Id, Status from Case where AccountId=:oldIds]);
            List<Account> accList = new List<Account>([Select Id, Last_Updated_Cases__c from Account where Id=:newIds]);
            Case newCase = new Case();
            Case oldCase = new Case();
            Account accountObject = new Account();
            for(Case oldCaseLooper : oldList){
                oldCase = oldCaseLooper;
            }
                //System.debug('ID 1: ' + oldCase.Id);
            for(Account accountLooper : accList){
                accountObject = accountLooper;
            }
                //System.debug('ID 2: ' + accountObject.Id);
            for(Case newCaseLooper : newList){
                newCase = newCaseLooper;
                if(oldCase.Id == newCase.Id &&
                 oldCase.Status != newCase.Status){
                    accountObject.Last_Updated_Cases__c = newCase.CaseNumber;
                    update accountObject;
                }
            }
        }
    }                                
}
 
 
SECOND TAB
Trigger CaseUpdate on Case(Before Insert, Before Update, Before Delete, After Insert,
                             After Update, After Delete, After Undelete){
    if(Trigger.isAfter){
        if(Trigger.isUpdate){
            Set<Id> caseId = new Set<Id>();    
       
        for(Case caseIdLooper : Trigger.new){
            caseId.add(caseIdLooper.AccountId);
        }      
     
        //Calling the Account Obj to get the Last updated cases field
        List<Account> accountObject = new List<Account>([Select Id, Last_Updated_Cases__c from Account
                                                       where Id=:caseId]);
       
        Case oldListOfcase = new Case();
        Case newListOfCase = new Case();
        Account accObject = new Account();
       
        for(Account accLooper : accountObject){
            accObject = accLooper;
        }
       
        for(Case oldCaseLooper : Trigger.old){
            oldListOfCase = oldCaseLooper;
        }
        System.debug('ID: ' + oldListOfCase.Id);
        for(Case newCaseLooper : Trigger.new){
            newListOfCase = newCaseLooper;
            if(oldListOfCase.Id == newListOfCase.Id &&
               oldListOfCase.Status != newListOfCase.Status){
               accObject.Last_Updated_Cases__c = newListOfCase.CaseNumber;
                   update accObject;
            }
        }
    }
  }                                
}
  • October 18, 2021
  • Like
  • 0
Hello Team , 

I need to build a schedule flow , My scenario is i need to Unfollow the subscribers or Users  on the opportunties  which are closed won or closed lost after 1 day. 

In simple: Oppty which has followers need to unfollow after 1 day when ever the oppty are closed won or closed lost. 

Need corrections in Snip 1 and 2 
in 1: I have scheduled daily from Tommorow where it should run daily and take the oppty records.

In snip 2: I have doubt , I have took a formula field duedate which has Today()- closedate = 1 and Isclosed =true .

My flowIn descion i have written a formula duedate which has (today-closedate) equals to 1dayUser-added image

Can any one please correct this . 
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




 
How to assign value to primitive data type - Object.
Object data={abc=123,zyz=456};
 
  • October 10, 2021
  • Like
  • 0
public with sharing class CreateQuotePDFController {
    public list<QuoteLineItem> quoteLineItemsList{get;set;}
    public Id getid{get;set;} 
    public Double grandTotalTax{get;set;}
    public Double finalPO{get;set;}
    public Date expirationDate{get;set;}
    public CreateQuotePDFController(ApexPages.StandardController controller) {
        getid=ApexPages.currentPage().getParameters().get('id');
        Quote quote = [SELECT Account.Name, Account.BillingCountry,Account.BillingPostalCode,Account.BillingState,Account.BillingCity,Account.BillingStreet, Contact.Name, GrandTotal, ExpirationDate FROM quote where id=:getid ];
        quoteLineItemsList = [select id,product2id,Discount_Percentage__c, PricebookEntry.Product2.Name , UnitPrice, Quantity, Subtotal from quotelineitem where QuoteId=: getid];        
        System.debug('grand total is : ' +quote.GrandTotal);
        grandTotalTax = (quote.GrandTotal * 0.18).setScale(2);
        finalPO = (quote.GrandTotal+grandTotalTax).setScale(2);
        expirationDate = quote.ExpirationDate;
    }
}



Test Class :- 

@isTest
public class CreateQuotePDFController_Test {
@testsetup static void data_setup(){
Account acc1 = new Account();
        acc1.Name = 'test account';
        insert acc1;
        system.debug('insert acc1 is success');

        Opportunity Opp1 = new Opportunity();
        Opp1.Name = 'testOpp';
        Opp1.AccountId = acc1.Id;
        Opp1.StageName = 'Closed Won';
        Opp1.CloseDate = system.Today();
        insert Opp1;        
        system.debug('insert opp1 success');

        Product2 Pro1 = new Product2();
        Pro1.Name = 'SLA: Bronze';
        pro1.isActive = True;
        Insert pro1;
        system.debug('insert pro1 is success');        

        Pricebook2 pb = new pricebook2();
        pb.Name = 'Standard Price Book 2009';
        pb.description = 'Price Book 2009 Products';
        pb.isActive = True;
        insert pb;
        system.debug('pb value is'+ pb.Id);
        system.debug('insert pricebook2 is success');

        Id pricebookId = Test.getStandardPricebookId();        

        PricebookEntry StandardPriceBookEntry = new PricebookEntry();
        StandardPriceBookEntry.Pricebook2Id = pricebookId;
        StandardPriceBookEntry.Product2Id = pro1.Id;
        StandardPriceBookEntry.UnitPrice = 10000;
        StandardPriceBookEntry.IsActive =True;        
        insert StandardPriceBookEntry;
        system.debug('insert StandardPriceBookEntry');

        PricebookEntry pbe = new PricebookEntry(pricebook2id=pb.id, product2id=pro1.id, unitprice=10000, isActive = True);
        insert pbe;
        system.debug('insert pbe is success');

        Quote Quo1 = new Quote(); 
        Quo1.OpportunityId = Opp1.Id;
        Quo1.Pricebook2Id = pb.Id;
        Quo1.Name = 'test Quo1';      
        insert Quo1;       
        system.debug('insert Quo1 success');

        QuoteLineItem QLI  = new QuoteLineItem();
        QLI.Product2Id = pro1.Id;
        QLI.QuoteId = Quo1.Id;
        QLI.PricebookEntryId = Pbe.Id;
        QLI.Quantity = 2;
        QLI.UnitPrice = 150000.0; 
        insert QLI;    
        system.debug('insert QLI is success');
     
    PageReference pageRef = Page.CreateQuotePDF;
    Test.setCurrentPage(pageRef);
    pageRef.getParameters().put('id', String.valueOf(Quo1.Id));
     ApexPages.StandardController sc = new ApexPages.StandardController(Quo1);
        
     CreateQuotePDFController qpc = new CreateQuotePDFController(sc);
     
       
   } 
     
    
}